File.SaveText

Top  Previous  Next

 

Syntax

function File.SaveText(Filename: string; Text: string; Filemode: integer [; Encoding: integer]): boolean

 

Alternative Names

ibec_SaveToFile

 

Description

Saves a string Text to the file Filename

 

If you want to read or write binary files or want to control what you're loading and saving, use file-stream function File.Open and its related functions.

 

The FileMode parameter is one of the following:

__fmCreate

Create a file, if the file already exists, overwrite the file. The stream is opened in write mode.

__fmOpenRead

Open a file for reading only.

__fmOpenWrite

Open a file for writing only.

__fmOpenReadWrite

Open a file for reading and writing, replacing the contents instead of the file itself.

__stfOverwrite

A combination of Create and OpenWrite, resulting in overwrite of the file.

 

The following additional options are available and can be combined with the previous options:

__fmShareCompat

Sharing is compatible with the way file control blocks are opened.

__fmShareExclusive

Other applications cannot open the file.

__fmShareDenyWrite

Other applications can open the file for reading only.

__fmShareDenyRead

Other applications can open the file for writing only.

__fmShareDenyNone

Other applications can read and write the file while the current application is doing the same.

 

The optional Encoding parameter is one of the following:

__encNONE

No encoding, used for binary streams.

__encANSI

No specific encoding, using the system code page.

__encUTF8

UTF8 encoding.

__encUTF16

UTF16 or Unicode encoding.

__encUTF16BE

Big-endian UTF16 or Unicode encoding.

 

If no encoding is given, the system default ANSI code page is used.

 

See also

File.LoadText
File.SaveFile

 

Example

execute udsblock

as

begin

  File.SaveText('c:\data\utf8text.txt', 'This is UTF8 text', __stfOverwrite, __encUTF8);

 

  resulttext = File.LoadText('c:\data\utf8text.txt');

end