- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi folks
I need to read the following into variable from a text file: 'xml_input'C
The read needs to include the apostrophes and the C appended on the end, yet a simple READ of the line only returns the text within the apostrophes. I'm assuming the READ statement is ignoring the apostrophes and assuming that they are simply indicative of the boundaries of the text of interest. In our case they are not, and I need to include them as well as what appears outside of the apostrophes, in this case the "C".
Anyone know a sneaky way to achieve this?
Many thanks!
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have tried only list-directed read, you'll probably need to read the entire line to a CHARACTER string usng A format, then find your string and copy it out by a CHARACTER assignment. Not very sneaky, somewhat old-fashioned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - tim18
If you have tried only list-directed read, you'll probably need to read the entire line to a CHARACTER string usng A format, then find your string and copy it out by a CHARACTER assignment. Not very sneaky, somewhat old-fashioned.
If so, you can use the DELIM attribute on the READ so that the single-quotes are ignored as text delimiters.
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You cannot use list-directed input for this. I would agree with Tim's advice - read the whole line into a character variable and then "parse" it yourself, looking for delimiters that are correct for your line's syntax. It doesn't match anything Fortran can provide for you automatically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks everyone
I eventually used a formatted read (A) that picked up all the necessary characters. Thanks very much for the help :-)

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page