Syntax
WriteText( FileName:String, Text:String, Append:Integer [optional] )
Parameters
FileName:String
Full path to file
Text:String
Text to write
Append:Integer [optional]
If this param is 1 Text will be append to end of file. Otherwise, if this param is 0 file will be cleared and then Text will be writed. Default value is 0.
Example
For these example you must create text file with content
i=1
s=Hello world!
(or download it from here)
and save it as ‘c:\sometext.txt’.
nl := NewLine + NewLine;
s := GetFileContent('c:\sometext.txt');
MsgBox('old file content'+ nl + s);
WriteText('c:\sometext.txt',NewLine + 'c=3',1);//adding text to file
s := GetFileContent('c:\sometext.txt');
MsgBox('file content after append string'+ nl + s);
WriteText('c:\sometext.txt','new textfile content');//rewriting text in file
s := GetFileContent('c:\sometext.txt');
MsgBox('file content after rewriting'+ nl + s);
Download example WriteText
Leave a Reply