ibec_fs_OpenFile

Opens a file for reading or writing.

Syntax

  function ibec_fs_OpenFile(FileName : string; Mode : integer): variant;

Description

The ibec_fs_OpenFile function opens file specified by FileName for reading or writing.

The Mode parameter indicates how the file is to be opened. The Mode parameter consists of an open mode and a share mode stored together. The open mode must be one of the following values:

ValueMeaning
__fmCreateCreate a file with the given name. If a file with the given name exists, open the file in write mode.
__fmOpenReadOpen the file for reading only.
__fmOpenWriteOpen the file for writing only. Writing to the file completely replaces the current contents.
__fmOpenReadWriteOpen the file to modify the current contents rather than replace them.

The share mode must be one of the following values:

ValueMeaning
__fmShareCompatSharing is compatible with the way FCBs are opened.
__fmShareExclusiveOther applications can not open the file for any reason.
__fmShareDenyWriteOther applications can open the file for reading but not for writing.
__fmShareDenyReadOther applications can open the file for writing but not for reading.
__fmShareDenyNoneNo attempt is made to prevent other applications from reading from or writing to the file.

If the file cannot be opened, ibec_fs_OpenFile returns NULL. Otherwise it returns the handle for the file just opened.

To close the file opened with ibec_fs_OpenFile use the ibec_fs_CloseFile function.

GThis function now supports files larger than 2 GB and Unicode (UTF8) file names. You can still use ANSI names, necessary checks and conversion are performed automatically.

Example

  execute  IBEBlock
  as
  begin
    FileName = 'C:\mydata.txt';
    FH = ibec_fs_OpenFile(FileName, __fmCreate);
    if (not FH is NULL) then
    begin
      ibec_fs_Writeln(FH, 'just a test');
      ibec_fs_CloseFile(FH);
    end
  end

See also:
Creating an UPDATE script with domain descriptions
Example: Importing data from a CSV file

back to top of page
<< ibec_fs_Eof | IBEBlock | ibec_fs_Position >>