Reading, writing, and closing files
You can use LotusScript® to read and write files. To create a file, you open and write to a file that does not yet exist; LotusScript® creates it automatically.
LotusScript® provides three modes of file access:
- Sequential (input, output, or append)
Use sequential access to read and write unstructured text files or text files with variable-length records. You can use user-defined data type variables with variable-length string members to read and write variable-length records. Numerical data is stored in the file as text strings.
- Random
Use random access for files that contain fixed-length records. You can use the Seek statement and a record number for immediate read or write access to any record in the file. Each record can contain a scalar value or the members of a user-defined data type variable. If the record includes strings, use fixed-length string variables so that each record is the same length.
For a discussion about using user-defined data types to work with files, see "Working with data stored in files" in "User-defined Data Types and Classes."
- Binary
Binary access provides immediate access by number to any byte in the file. In general, you use binary access to read and write bytes of data. You can also use binary access to write a stream of characters to an unstructured text file.
This table summarizes the statements and functions that operate on Sequential, Random, and Binary files.
Statements & Functions |
Sequential |
Random |
Binary |
---|---|---|---|
Dir |
X |
X |
X |
EOF |
X |
X |
X |
FileCopy |
X |
X |
X |
FileDateTime |
X |
X |
X |
FileLen |
X |
X |
X |
FreeFile |
X |
X |
X |
GetAttr |
X |
X |
X |
Loc |
X |
X |
X |
LOF |
X |
X |
X |
Seek |
X |
X |
X |
SetAttr |
X |
X |
X |
Open (This is where you set the access mode.) |
X |
X |
X |
Close |
X |
X |
X |
Get |
X |
X |
X |
Input( ) |
X |
X |
|
InputB( ) |
X |
X |
|
InputBP( ) |
X |
X |
|
Input # |
X |
||
Line Input # |
X |
||
Print # |
X |
||
Put |
X |
X |
|
Write # |
X |