beautypg.com

Fopen, Fopen, fread, frename – Visara Master Console Center Scripting Guide User Manual

Page 109

background image

Chapter 5 Script Commands

Scripting Guide

109

FOPEN

Syntax:

FOPEN( $FileName[, %Mode]) ==> %FileHandle

Description:

Opens a file for I/O access.

Action:

FileName is opened for read/write access in the mode defined by the

Mode parameter.

Parameters:

$FileName. String expression. The case sensitive name of the file to

open as a data file. Include any necessary file path.
%Mode. Numeric expression. Optional. The mode in which to open
the file. Valid constants are OVERWRITE, APPEND, and

READONLY. If not specified, the default mode is OVERWRITE.

Mode Constant
OVERWRITE

APPEND

READONLY

Description
FWRITE
() always places new entries at the current

record pointer. If the current record pointer is at the
end of the file, no data is overwritten. If the current

record pointer is not at the end of the file, the data at

the current position is overwritten and the data after
the written position is of a questionable state.
FWRITE() always places new entries at the end of the
file, no matter where the current record pointer is. No

data is overwritten.
FOPEN() opens the file in read only mode. No write
operations are allowed to the file.

Returns:

Numeric value, as follows:
Value

Meaning

-1

Error occurred while attempting to open

the file.

Any other value

A unique number used for subsequent

access to the file in the current script

(commonly

referred

to

as

the

“file

handle”

or

the

“file

number”).

Notes:

1. Refer to Manifest Constants on page 42 for the constants reference

list.

2. The file handle obtained from an FOPEN() call is only valid in the

same script that contains the FOPEN().

3. If the file specified to open does not exist, a new one is created.
4. If the file to be opened already exists, the Mode parameter

determines whether the current data in the file may be
overwritten.

5. The maximum number of files that can be opened per script thread

is 60.

6. FOPEN() can be used to access any file on the MCC unit.
7. Using NFS, it is possible to access virtually any file on any server

or mainframe from the MCC unit.

8. Using FOPEN() on the same file twice in succession returns

different numeric values, but both handles refer to the same file.