WriteSeqF Function

Writes a new line to a file that is open for sequential processing, advances a pointer to the next position in the file, and saves the file to disk.

Syntax

WriteSeqF line To file.variable 
[On Error statements]
{[Then statements [Else statements]] | [Else statements]}

line is the line to write to the sequential file. WriteSeqF writes a newline at the end of the line.

To file.variable specifies the sequential file. file.variable is the variable name assigned to the file by the preceding OpenSeq statement.

On Error statements specify the action to take if there is a fatal error. A fatal error occurs if the file is not open, or file.variable is a null value. If you do not specify an On Error clause, the job aborts and an error message is written to the job log file.

Then statements specify the action the program takes after the line is written to the file. If you do not specify a Then clause, you must specify an Else clause.

Else statements specify the action the program takes if the line cannot be written to the file, for example, if the file does not exist. If you do not specify an Else clause, you must specify a Then clause.

Remarks

WriteSeqF works in the same way as WriteSeq, except that each line is written directly to disk instead of being buffered and then being written in batches. A WriteSeqF statement after several WriteSeq statements writes all buffered lines to disk.

Note: Use the WriteSeqF statement for logging operations only as the increased disk I/O slows down program performance.

You can use the Status function after WriteSeqF to determine the success of the operation. Status returns 0, if the file was locked, -2 if the file was not locked, and an error code if the On Error clause was taken.

Example

The following example appends to a sequential file by reading to the end of it, then force-writing a further line:

OpenSeq PathName To FileVar Then
   Loop
      ReadSeq Dummy From FileVar Else Exit ;* at end-of-file
   Repeat
   WriteSeqF "Extra line" To FileVar Else
   On Error
      Call DSLogWarn("Error from ":PathName:"
      → status=":Status(),                  "MyRoutine")
      GoTo ErrorExit
   End
   Call DSLogFatal("Cannot write to ":Pathname, "MyRoutine") 
      GoTo    ErrorExit
   End
End Else
   Call DSLogFatal("Cannot open file ":Pathname, "MyRoutine")
   GoTo ErrorExit
End