User`s guide

reads (from the open file on dlun) up to the first CR/LF (or end of file if it is encountered) and
store the result in $in.string. When the end of file is reached, V+ error number -504
Unexpected end of file is generated. The IOSTAT() function must be used to recognize this
error and halt reading of the file:
DO
READ (dlun) $in.string
TYPE $in.string
UNTIL IOSTAT(dlun) == -504
The GETC function reads the file byte by byte if you want to examine individual bytes from
the file (or if the file is not delimited by CR/LFs).
Detaching
When a disk logical unit is detached, any disk file that was open on that unit is automatically
closed. However, error conditions detected by the close operation may not be reported.
Therefore, it is good practice to use the FCLOSE instruction to close files and to check the
error status afterwards. FCLOSE ensures that all buffered data for the file is written to the
disk, and updates the disk directory to reflect any changes made to the file. The DETACH
instruction frees up the logical unit. The following instructions close a file and detach a disk
LUN:
FCLOSE (dlun)
IF IOSTAT(dlun) THEN
TYPE $ERROR(IOSTAT(dlun))
END
DETACH (dlun)
When a program completes normally, any open disk files are automatically closed. If a
program stops abnormally and execution does not proceed, the KILL monitor command
closes any files left open by the program.
CAUTION: While a file is open on a floppy disk, do not replace the
floppy disk with another disk: Data may be lost and the new disk
may be corrupted.
Disk I/O Example
The following example creates a disk file, writes to the file, closes the file, reopens the file,
and reads back its contents.
AUTO dlun, i
AUTO $file.name
$file.name = "data.tst"
; Attach to a disk logical unit
ATTACH (dlun, 4) "DISK"
Disk I/O
(Undefined variable: Primary.Product_Name_V)Language User's Guide, version
17.x
Page 217