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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write a piece of a string contained in an array 1

Status
Not open for further replies.

sleepingSatellite

Programmer
May 13, 2002
20
DE
I have an array of strings.
I want to write only characters from 5 to 14 of one of the elements of the array.

Intuitively, I should do something like:

write(11,FMT='(A10)')array(3)(5:14)

where 3 is the array's index, and (5:14) indicates the characters to write.
But of course it's not accepted.

Using an intermediate variable would't be very elegant.
There must be a feature of the syntax I don't know.

Thank you
 
Can't see why it is not accepted. Works in MS Fortran 5.1 (F77), G77 and G95. One thing to watch out for: some compilers want carriage control so you need a 1X before your A10.
Code:
      program writestr
      character*15 array(10)
      array(3) = 'abcdefghijklmno'
      write (*,'(1X,A10)') array(3)(5:14)
      stop
      end
 
You're perfectly right.
I tried something like this some time ago and I had the remember that it didn't work. But apparently it was not exactly this, because this actually works (and this is what I need now), as you have shown.

I have no words to apologize.
Sorry for the waste of time.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top