Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.4j

Application v 5.22b

  

 

Chapter SixFile Functions (continued)

OpenFile Function

Overview

The OpenFile function opens an existing file as a Basic File Object.

Syntax/Parameters

Syntax

handle = OpenFile ( string name, [dword mode] );

Parameters

name

A string containing a fully qualified path and filename. This parameter supports UTF encoding for filenames with Unicode characters.

mode

An optional dword specifying rights to the file. The parameter can be a combination of bitwise flags. See Remarks for modes. If omitted, the file is created with read access exclusive.

Return Value

Returns a handle to a Basic File Object or NULL_HANDLE on failure. Use the GetLastError function to retrieve error information. The GetLastErrorMessage function may contain information to supplement the error code. Error codes match Windows system error codes (for a list, see Appendix A — Legato SDK Standard Definitions or MSDN).

Remarks

The OpenFile function is a low-level function that allows for direct access to files located on a variety of devices. The files can be located on an NTFS or FAT file system. Access rights to the file are dependent on the user permissions set within the operating system. Files cannot be located on HTTP or FTP routines unless there is access via the VFC.

Access is controlled via the mode flags which can be a series of bitwise flags:

  Definition   Bitwise Value   Description  
  FO_READ   0x00000000   Read-Only  
  FO_WRITE   0x00000001   Read and Write  
  FO_SHARE_READ   0x00000010   Allow Others to Open as Read  
  FO_SHARE_WRITE   0x00000020   Allow Others to Open as Write  
  FO_TEMP_FILE   0x00010001   Create/Delete Temp File Exclusive  
  FO_DELAY_CREATE   0x00020001   Create Only, Delay on Share  
  FO_CREATE_HIDDEN   0x00080000   Make Hidden on Create  
  FO_WAIT_OPEN   0x00200000   Delay on Share (open)  
  FO_FORCE_SPOOL   0x00800000   Forces Spool Out (requires create or FO_WRITE)  

 

The function returns a handle to the file that can be used for various types of I/O. The handle should be closed using the CloseFile or DeleteFile functions.

For significantly more flexibility in editing a file that is organized in lines of text, use a Mapped Text Object. Mapped Text Objects can be created through the CreateMappedTextFile and CreateMappedTextString functions.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic