Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function to get part of a string 1

Status
Not open for further replies.

manavo

Programmer
Jan 10, 2004
3
0
0
GR
Hey everyone :)

Is there a function in fortran 90 so I can get seperatelly part of a string? Something like the mid function in VB if that helps...

Thanks
 
Also works in F77 but note how you declare the string. It should be declared as CHARACTER*80 ST and not CHARACTER ST(80)
 
Or CHARACTER ST * 80 (Maybe CHARACTER ST(80) is an implied
DIMENSION statement ?)
 
CHARACTER ST(80) would make an array, right?

Thanks for the suggestions :)
 
Yes , CHARACTER ST(80) would make an array of 80 elements. But as the length is not specified, each element would contain only one character. (If you wish to select one character at a time, the above declaration may be convenient.)
 
You should try to read in the string (as you do it in a file)

character(80) :: line
character(20) :: subseq

read(*,*) line

read(line,'(a20)') subseq
! for the first 20 character of the string 'line'

subseq=line(23:43)

ciao
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top