TTextFile

Navigation:  Les scripts > Les autres scripts > Procedure and function > Specifics > Objects >

TTextFile

Previous pageReturn to chapter overviewNext page

When a text file is opened, the external file is interpreted in a special way: It is considered to represent a sequence of characters formatted into lines, where each line is terminated by an end-of-line marker (a carriage-return character, possibly followed by a linefeed character). The type Text is distinct from the type file of Char.

 

TtextFile.FileOpenText constructor

 

Constructor FileOpenText(FileName: string);

 

 

Call FileOpenText to initialize a text file variable.  FileName is a string-type expression or an expression of type PChar if extended syntax is enabled.

 

TtextFile.FileOpenDayText constructor

 

Constructor FileOpenDayText(FileName: string);

 

 

Call FileOpenDayText to initialize a text file variable.  FileName is a string-type expression or an expression of type PChar if extended syntax is enabled.

The filename is the name of the file without specifying the path. The path is automaticly assigned to the actual day of the month. Exemple:

January 10, 2001 the path will be:  C:\VK-WinQV\WQVFiles\Report\2001\January\10\

 

TtextFile.FileOpenMonthText constructor

 

Constructor FileOpenMonthText(FileName: string);

 

 

Call FileOpenMonthText to initialize a text file variable.  FileName is a string-type expression or an expression of type PChar if extended syntax is enabled.

The filename is the name of the file without specifying the path. The path is automaticly assigned to the actual month of the year. Exemple:

January 10, 2001 the path will be:  C:\VK-WinQV\WQVFiles\Report\2001\January\

 

TtextFile.FileClose

 

Procedure FileClose;

 

Use the CloseFile procedure to terminate the association between a file variable and an external disk file.

 

The external file is completely updated and then closed.

 

 

TtextFile.FileErase

 

Procedure FileErase;

 

Erase deletes the external file .

 

Exemple:

 

F:=FileOpenDayText(‘Report.txt’);

F.FileErase;

F.free;

 

 

TtextFile.FileWrite;

 

Procedure FileWrite(s:string [,s2..s3:string]);

 

Write writes a file to a file component. Each S is a variable of  type String . For each variable written, the current file position is advanced to the next component. If the current file position is at the end of the file , the file is expanded.

 

Exemple:

 

F:=FileOpenDayText(‘Report.txt’);

F.FileWrite(‘Test d’un message’);

F.FileClose;

F.free;

 

TtextFile.FileRead;

 

Procedure FileRead(s:string[,s2..sn:string]);

 

Read reads all characters up to, but not including, the next end-of-line marker or until Eof(F) becomes True; it does not skip to the next line after reading. If the resulting string is longer than the maximum length of the string variable, it is truncated.

After the first Read, each subsequent Read sees the end-of-line marker and returns a zero-length string.

Use multiple Readln calls to read successive string values.