Home > Archive > Fortran > February 2005 > very trivial question: writing on files
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
very trivial question: writing on files
|
|
| Steve_Vai 2005-02-21, 8:59 pm |
| I need to write on files.
I can use the command write in trivial way:
write (34,*)'/GRAPHICS/HPLOT/NULL 2 50 2 50'
but I got some problems trying to write on file the character: " ' ", as
the program reads it as a command as weel.
What I mean to write is something like
/GR/PR/TEXT 4 4 '1,3' 0.3
but at the moment, with ordinary write syntax, I can just write
/GR/PR/TEXT 4 4 1,3 0.3
with this:
write (34,*)'/GR/PR/TEXT',4,4, 1, ',', 3, 0.3
As you can see, it's a very trivial problem (at the moment I solve it with
some gvim hand made activity ;-), but it's very boring!
I would appreciate any help :-)
Have a good day!
| |
| beliavsky@aol.com 2005-02-22, 8:58 am |
| Steve_Vai wrote:
> I need to write on files.
> I can use the command write in trivial way:
>
> write (34,*)'/GRAPHICS/HPLOT/NULL 2 50 2 50'
>
>
> but I got some problems trying to write on file the character: " ' ",
as
> the program reads it as a command as weel.
>
> What I mean to write is something like
>
> /GR/PR/TEXT 4 4 '1,3' 0.3
> but at the moment, with ordinary write syntax, I can just write
>
> /GR/PR/TEXT 4 4 1,3 0.3
>
> with this:
>
> write (34,*)'/GR/PR/TEXT',4,4, 1, ',', 3, 0.3
In Fortran 90/95/2003, double quotes can be used to enclose strings, so
just
write (*,"(1x,a,i0,',',i0,a)") "'",1,3,"'"
produces output
'1,3'
| |
| s8ngsu3@yahoo.com 2005-02-22, 8:58 am |
| Repeat the single quote twice inside a string to get one single quote
printed:
write (34,*) '/GR/PR/TEXT 4 4 ''1,3''
0.3'
Or use double quotes ("):
write (34,*) "/GR/PR/TEXT 4 4 '1,3' 0.3"
| |
| Steve_Vai 2005-02-22, 8:58 am |
| beliavsky@aol.com wrote:
> Steve_Vai wrote:
> as
>
> In Fortran 90/95/2003, double quotes can be used to enclose strings, so
> just
>
> write (*,"(1x,a,i0,',',i0,a)") "'",1,3,"'"
>
> produces output
>
> '1,3'
Thanks a lot :-)
| |
| Steve_Vai 2005-02-22, 8:58 am |
| s8ngsu3@yahoo.com wrote:
> Repeat the single quote twice inside a string to get one single quote
> printed:
>
> write (34,*) '/GR/PR/TEXT 4 4 ''1,3''
> 0.3'
>
> Or use double quotes ("):
>
> write (34,*) "/GR/PR/TEXT 4 4 '1,3' 0.3"
Thanks a lot, this will be very useful :-)
Ciao :)
|
|
|
|
|