Please enable JavaScript to view this site.

ESL Documentation

FILEIO Subroutine

Output a string value to a file.

call WriteString(FILE_ID_IV, SOURCE_SV)

FILE_ID_FID

A integer variable for the file id.

SOURCE_SV

A string variable that can contain embedded newline characters (\n) and carriage returns (\r). The record can contain strings that have embedded newlines as fields, so a single call to an output subroutine can result in several lines being written to the file. Use \n\r to separate lines.

Description

This output subroutine allows you to create an ASCII or EBCDIC file on disk.

Errors

FIO_E_DISKFULL

Disk has no more space for writing. The disk to which the file is being written is full.

FIO_E_FILEHANDLE

Invalid file handle--internal error.

FIO_E_FILELOCKED

File locked by another program.

FIO_E_LONGSTRING

String length exceeded 2Gb.

FIO_E_NOTOPEN

File has not been opened. A file must be opened before a read attempt is made.

FIO_E_OPENFORREAD

Writing to file open for reading only.

FIO_E_WRITEACC

Write access violation. Should never happen during output.

FIO_E_WRITEERR

Unknown write error occurred.

Example

integer FileID_IV

string FileNameOut_SV is "myfile.txt"

string FileMode_SV

string Source_SV is "This is a string."

string Line_SV is "This is a line."

string NewLine_SV is "\n"

record Out_Rec is

filler 10

Line 80

NewLine 1

end record

include "fileio.inc"

 

# To be brief, error handling is omitted

response to line "Open Myfile" from keyboard

 copy "w" to FileMode_SV

 call OpenFile ( FileID_IV, FileNameOut_SV, FileMode_SV )

 

response to line "Close Myfile" from keyboard

 call CloseFile ( FileID_IV )

 

response to line "Write String" from keyboard

 call WriteString ( FileID_IV, Source_SV )

 

response to line "Write Record" from keyboard

 call WriteRecord ( FileID_IV, Out_Rec )

See Also

WriteByte( ) subroutine.

WriteWord( ) subroutine.