Chapter Contents

Previous

Next
SAS Component Language: Reference

Opening Files

To complete the communication link between an application and an external file, use the FOPEN function to open the file. Opening a file does not access the information in the file. It simply makes the file available to the program.

When you open an external file, a unique identifier is assigned to the external file. This identifier is used by any other SCL functions that manipulate the file. In addition, a temporary storage buffer is automatically created for the external file. This storage area is used to store copies of file records.

The FOPEN function returns the program's identification number for that file. This unique number is called the file identifier. You use this identifier by storing it in an SCL variable and passing the variable name as an argument to all the SCL functions that manipulate that file or directory. This technique enables you to open and manipulate multiple files at the same time and to clearly identify which file to manipulate.

When you open a file, you specify an open mode. The open mode determines the actions that can be performed on the file. With the FOPEN function, you can also specify the file's record length. If you specify a record length of 0, the existing record length is used. For details about the modes and record lengths and how to specify them, see FOPEN.


Making an Open File Available to Other Programs

After you open an external file, its contents are available to all programs in your application. However, you must link the file to the programs by using one of the following techniques to pass them the variable that contains the file identifier.


Number of Open Files Allowed

SCL allows a maximum of 999 external files to be open simultaneously in an application. However, your operating system may impose other limits. For further details, refer to the documentation provided by the vendor for your operating system.

Although SCL allows you to have a large number of files open simultaneously, you should be aware that memory is allocated for each file from the time the file is opened until it is closed. Therefore, you should try close files as soon as your program is finished with them.


Chapter Contents

Previous

Next

Top of Page

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