fileReadRecord
|
The fileReadRecord function reads end-of-line terminated records from
a buffered file {fileID} returning record String Object {record}.
If no buffer size {bufferSize} is specified, one will be created, of a default size,
to hold the data that is read from the file. Data is entered into a file with the fileWrite, fwriteln, or fdisplay
functions, however, records are not actually committed to the file until the file
is closed. Thus, attempting to read a record immediately after a fileWrite or
fdisplay will result in an error. In order to verify records that have been
written, it is necessary to close the file and save the file (fileClose
with an option argument equal to 1) . The file can then be re-opened and read
with the fileReadRecord function. For example here is example code which writes a file and then reads records from it. (writeTestFile) (readTestFile) Where readTestFile is defined as follows. (defun readTestFile()     vars:(n N aEOF aBuffer (aLine ""))     (setq aFile (fileOpen aFileName 0 0))     (setq aBuffer (fileReadRecord aFile))     (while (<> aLine #void) do       (setq aLine (fileReadRecord aFile aBuffer))       (writeln aLine)     ) ; end of while     (setq aFile (fileClose aFile 1))     true) And where writeTestFile is defined as follows. (defun writeTestFile()     vars:(n N)     (setq aFile (fileOpen aFileName 1 0))     (loop for n from 0 until 10 do       (fileWriteln aFile n #\tab "some text" )     ) ; end of loop     (setq aFile (fileClose aFile 1))     true) ;;Main Code (writeTestFile) (readTestFile) Usage The fileReadRecord function is used to read end-of-line terminated
text data from an existing file (One that have been previously written and closed).
See the fileOpen fileWrite and fileClose functions.
(fileReadRecord fileID) (fileReadRecord fileID buffer) If no buffer argument is passed, the buffer object to parse looking for the next record.
If a buffer argument is passed, the next sequential record in the file.
If no buffer argument is passed and there are no more records, a void object is returned.
Expression:
Arguments
Name
Type
Description Argument: fileID Integer
An Integer representing the fileID to be read (must be the fileID returned from a previous fileOpen function). Argument: buffer ByteVector
(Optional) The file buffer to parse looking for the next record (must be the buffer returned from the first call to the fileReadRecord function).
Returns:
Here are a number of links to Lambda coding examples which contain this instruction in various use cases.
Here are the links to the data types of the function arguments.
Integer | String |
Here are also a number of links to functions having arguments with any of these data types.
Analytic Information Server (AIS)AIS Component Systems
|