Equinox Online Help - Language Reference - A to Z

Home

FilePrint

Applies to
SyntaxFilePrint HandleItem, Item1[, Item2, Item3 ... ]
Action[Statement] Writes a delimited list of items to a sequential file.
ScopeUsable anywhere
NotesThis statement writes items into a file using the delimiters specified in the FileDelimiters statement. If the FileDelimiters statement has not been used on the file, the inter-item delimiter defaults to a comma, the delimiter at the beginning and end of a string defaults to a double quote and the end of line delimiter defaults to a carriage return line feed sequence. The delimiters used in the argument list further determine how each item is written to the file. If an item is followed by a comma, the configured delimiter (usually a comma) will be used. If it is followed by two semicolons, an end of line delimiter will be used. If it is followed by a semicolon, no delimiter will be used.

At the end of the list, if there is no delimiter an end of line sequence is used. If a semicolon is placed at the end of the list, nothing is appended to the line.

Arrays or vector expressions can be specified as arguments. If there are two delimiters after the array, the first delimiter is used between elements and the second at the end of the array. If there is only one, it is used in both places.

The HandleItem parameter must be of Equinox variable type Handle and is the handle of the file which was opened with the FileOpen statement. SysError is non-zero if the file write did not succeed and SysReply will hold the value of the number of items written.

This statement will not work if the file has been opened as a random file.

The system workarea SysError is set to a non-zero value if an error occurs, otherwise zero.

CategoryFile IO
See Also FileClose, FileCloseAll, FileDelimiters, FileInput, FileInputLine, FileLock, FileMovePosition, FileOpen, FilePosition, FilePrint, FileRead, FileReadLine, FileReadBinary, FileReadFile, FileUnlock, FileWrite, FileWriteBinary, FileWriteFile
Example

If the following example is placed in the Before save (insert) event on a form, it will write a log of records inserted in a database together with who inserted them to a sequential file. RecordNo contains a unique identifier for that record.

handle hnd

| Open the file and test for error
FileOpen "MYDATA.DAT", StreamAppend, hnd

if hnd = -1 then
Alert "File Opening Error"
exit method
end if

| Prints the list with no end of line chars
FilePrint hnd, "Insertion", SysUser, RecordNo;
FileClose hnd

The next example demonstrates the different ways arrays can be written to a file.

int a[4], n

a=1,2,3,4
FilePrint a,42

| File contains: 1,2,3,4,42
FilePrint a;,42

| File contains: 1234,42
FilePrint a;;42

|* File contains:
1
2
3
4
42
*|