Chapter Contents

Previous

Next
FOPEN

FOPEN



Opens an external file

Category: External File


Syntax
Details
Examples
Example 1: no-title for topic with id=z1124207
See Also

Syntax

file-id=FOPEN(fileref<,open-mode<,record-length
<,record-format>>>);

file-id
contains the identifier for the file, or 0 if the file could not be opened.

Type: Numeric

fileref
is the fileref that is assigned to the external file.

Type: Character

open-mode
specifies the type of access to the file:
'A' APPEND mode, which allows writing new records after the current end of the file.
'I' INPUT mode, which allows reading only. (This is the default.)
'O' OUTPUT mode, which defaults to the OPEN mode specified in the host option in the FILENAME statement or function. If no host option is specified, it allows writing new records at the beginning of the file. If the file exists, its contents are overwritten, destroying any previous contents. If the file does not exist, it is created.
'S' Sequential input mode, which is used for pipes and other sequential devices such as hardware ports.
'U' UPDATE mode, which allows both reading and writing records.
'W' Sequential output mode, which is used for pipes and other sequential devices such as hardware ports.

Type: Character

record-length
is the logical record length of the file. To use the existing record length for the file, either specify a length of 0 or do not provide a value here.

Type: Numeric

record-format
is the record format of the file. To use the existing record format, do not specify a value here.
'B' The data is to be interpreted as binary data.
'D' Use the default record format.
'E' Use an editable record format.
'F' The file contains fixed-length records.
'P' The file contains printer carriage-control characters in a host-dependent record format.
'V' The file contains variable-length records.

Type: Character


Details

CAUTION:
Use OUTPUT mode with care. Opening an existing file in OUTPUT mode overwrites the current contents of the file without warning.  [cautionend]

The FOPEN function opens an external file for reading or updating and returns a file identifier value that can then be used to identify the open file to other functions. You must associate a fileref with the external file before calling the FOPEN function.

In SCL you can assign filerefs by using either the FILENAME statement or the FILENAME function. Under some operating systems, you can also use operating system commands to assign filerefs.

Operating Environment Information:   OS/390

For OS/390 data sets that have the VBA record format, specify `P' for the record-format argument.  [cautionend]


Examples


See Also

DOPEN

FCLOSE

FILENAME

FILEREF

MOPEN


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.