View previous topic :: View next topic |
Author |
Message |
Little-Acorn
Joined: 06 Jul 2008 Posts: 111 Location: San Diego
|
Posted: Wed Jul 28, 2010 1:33 am Post subject: Picking a substring out of a string in FTN95 (Win32)? |
|
|
I'm running FTN95, with WIN32.
Years ago when I was running BASIC (don't laugh, it has its uses), it had a function where I could pick a group of character out of a string, and assign them into a substring. Something like:
SUBSTRING$=MID$("Fourscore and seven years ago",5,9)
would assign the characters "score and" into the string variable SUBSTRING$.
Can FTN95 do anything like that?
-----------------------------------------------------------
BASIC also had two related functions such as:
SUBSTRING$=LEFT$("Fourscore and seven years ago",6)
which would put the string "Foursc" into STRING$, and
SUBSTRING$=RIGHT$("Fourscore and seven years ago",7)
which would put the string "ars ago" into STRING$.
Do any functions similar to that, exist in FTN95?
Thanks in advance! |
|
Back to top |
|
|
JohnHorspool
Joined: 26 Sep 2005 Posts: 270 Location: Gloucestershire UK
|
Posted: Wed Jul 28, 2010 7:52 am Post subject: |
|
|
http://www.infis.univ.trieste.it/fortran/thetypec.html
An extract from the web page above:-
If the CHARACTER variable LANG has the value 'FORTRAN', some substrings are:
Code: |
Substring Value
LANG(1:1) 'F'
LANG(1:7) 'FORTRAN'
LANG(2:3) 'OR'
LANG(7:7) 'N'
LANG(:4) 'FORT'
LANG(5:) 'RAN' |
or you could write your own fortran routines to mimic basic |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Wed Jul 28, 2010 7:55 am Post subject: |
|
|
Use INDEX and then put the result into a Fortran character substring. |
|
Back to top |
|
|
Little-Acorn
Joined: 06 Jul 2008 Posts: 111 Location: San Diego
|
Posted: Wed Jul 28, 2010 9:39 pm Post subject: |
|
|
Great, thank you! |
|
Back to top |
|
|
|