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

Writing a ' to a text file

Status
Not open for further replies.

harrisonj

IS-IT--Management
Dec 16, 2003
12
US
List,

I'm writing to a textfile, but need to write out lines with a ' (quote) around certain values. For example I want a line in the textfile to read:
Diver_Acclimatized_at_Altitude='no'

What I get is:
Diver_Acclimatized_at_Altitude=no

Currently I have;

b :=AccToAlt.text;
Write (myfile2, 'Diver_Acclimatized_at_Altitude='+b);
WriteLn(myfile2);

b gets it's value from a radiogroup selection on the gui. The only 2 choices are 'no' or 'yes'.

How can I write out the proper text?

(The text file is for the input to a fortran program, so I need to preserve the input formatting)

Thanks in advance,
Harrison
 
You don't need both the write and the writeln. Try this:

Writeln(myfile2, 'Diver_Acclimatized_at_Altitude='''+b+'''');

Two ' characters inside a quoted string write the '.
 
Punchinello,

Thanks, that worked.

I'm using the additional WriteLn(myfile2); to terminate the line and move the curser to the next line.

Thanks again,
Harrison
 
I understand about your reason for using the writeln. What I'm saying is that this:
[tt]
Write(myfile2, 'Any text');
Writeln(myfile2);
[/tt]

and this:
[tt]
Writeln(myfile2, 'Any text');
[/tt]

will do exactly the same thing.
 
Thanks,
Did not know that.

Thanks again,
Harrison
 
you can write this also as :
Code:
Writeln(myfile2, 'Diver_Acclimatized_at_Altitude='+QuotedStr(b));


--------------------------------------
What You See Is What You Get
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top