Liberty BASIC Help Online

File Operations
Liberty BASIC supports sequential, binary and random access file operations. 
 
See also:  OPEN, Sequential Files, Binary Files, Random Access Files, CLOSE, INPUT, INPUT$, INPUTTO$, LINE INPUTPRINT
 
Files can be created with the  OPEN command.
 
Files can be renamed with the NAME command.
 
Files can be removed with the KILL command.
 
When a file is being read, the EOF function returns 0 if the end of the file has been reached, otherwise it returns -1.
 
The length of a file can be retrieved with the LOF function.
 
The drive specifications for the computer on which a program is running are contained in the special variable Drives$.
 
The directory in which a program resides on disk is contained in the special variable DefaultDir$.
 
Folders, also called Directories, can be created with the MKDIR command.
 
Folders, also called Directories, can be removed with the RMDIR command.
 
 
Different Methods of File Access
 
Sequential Files
Sequential Files are accessed from beginning to end, sequentially.  It is not possible to read or write a piece of data to the center of the file. Files opened for INPUT can only be read.  Files opened for OUTPUT or APPEND can only be written.  For more, see Sequential Files.
 
Binary Files
Files opened for binary access may be read or written, beginning at any location within the file.  For detailed information on using binary files, see Binary Files.
 
Random Files
Files opened for random access are read or written one record at a time.  The length of records in the file is determined in the OPEN statement.  For detailed information on using random files see Random Access Files.
 
String and Numeric Data
All data, whether strings of text or numbers, is printed as ASCII text characters in files, as the following example illustrates:
 
open "test.txt" for output as #f
print #f, "12345"
print #f, 12345
close #f
 
open "test.txt" for input as #g
txt$ = input$(#g, lof(#g))
close #g
 
print txt$
end
 
'produces
12345
12345


Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/