Silverfrost Forums

Welcome to our forums

Picking a substring out of a string in FTN95 (Win32)?

28 Jul 2010 12:33 #6694

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!

28 Jul 2010 6:52 #6697

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:

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

28 Jul 2010 6:55 #6698

Use INDEX and then put the result into a Fortran character substring.

28 Jul 2010 8:39 #6703

Great, thank you!

Please login to reply.