Adding a message at the end of a text file.

 

Syntax

function AddLineToFile(sMsg, sFileName: string; iEncodingType: integer): int64;

 

Parameters and return values

Parameter

Type

Value

sMsg

string

message text;

sFileName

string

name of a text file with a path to it.

iEncodingType

integer

file encoding type, number.

 

Function result

>=0

no errors, file's final size in bytes;

-1

error writing to file, error creating new file or invalid path to the file.

 

Example


var
  i: integer;
  s: string;
begin
  DeleteFile('c:\temp\log.txt'); // delete a file with result if it exised before
    for i := 1 to 1000 do 
      if i mod 100 = 0 then 
        AddLineToFile(inttostr(i), 'c:\temp\log.txt', 0);
end.


Script work result
 

A result of AddLineToFile function work in MyChat Scripts Engine

 

See also

DeleteFile

IntToStr