Catherine Moroney wrote:
>
> Thanks to all those responded to my question about constructing
> a variable length character string. I followed the suggestions
> about constructing a character string to serve as my format
> instruction and it worked like a charm.
>
> Now another question about character strings and formats:
>
> I have to construct a character string that spans multiple lines.
> (In order to provide file annotation in HDF version 4, I have
> to write out the entire multi-line annotation as a single character
> string). Is there some way to embed a new-line (as in "C") within
> a character string without having it mark the end of the string?
I may be misunderstanding your question here (but that won't stop me
from answering ;-{ ).
You can put anything you want into a character variable. Some things,
like "newline" characters are harder to put in than others. There
are problems with some output devices, like printers, that interpret
"newline" as something special, but that doesn't mean you can't put
it in a string.
Something like
character(len=3*(10+1)) :: lines
...
lines = "some stuff"//achar(newline_value)// &
"more stuff"//achar(newline_value)// &
"last stuff"//achar(newline_value)
Where you'll have to look up the ascii "newline_value" in a book
somewhere (I don't remember what it is-another senior moment). Be
careful, most books give it in octal or hex, achar wants decimal.
That'll give you a single character variable with three 10 character
fields, separated and terminated by \n.
You and I are both using the word string loosely. Fortran character
variables are not strings in the C sense. They are fixed length
things and the length is independent of what's in them.
Dick Hendrickson
>
> Thanks,
>
> Catherine
>
> --
> -------------------------------------------------------------------------
> Catherine Moroney phone : (818) 393-3392
> Jet Propulsion Laboratory fax : (818) 393-4802
> MailStop 169-315 email : [log in to unmask]
> 4800 Oak Grove Drive
> Pasadena, CA 91109-8099
|