User`s guide

IF IOSTAT(dlun) < 0 GOTO 100
; Open a new file and check status
FOPENW (dlun) $file.name
IF IOSTAT(dlun) < 0 GOTO 100
; Write the text
FOR i = 1 TO 10
WRITE (dlun) "Line "+$ENCODE(i)
IF IOSTAT(dlun) < 0 GOTO 100
END
; Close the file
FCLOSE (dlun)
IF IOSTAT(dlun) < 0 GOTO 100
; Reopen the file and read its contents
FOPENR (dlun) $file.name
IF IOSTAT(dlun) < 0 GOTO 100
READ (dlun) $txt
WHILE IOSTAT(dlun) > 0 DO
TYPE $txt
READ (dlun) $txt
END ;End of file or error
IF (IOSTAT(dlun) < 0) AND (IOSTAT(dlun) <> -504) THEN
100 TYPE $ERROR(IOSTAT(dlun)) ;Report any errors
END
FCLOSE (dlun) ;Close the file
IF IOSTAT(dlun) < 0 THEN
TYPE $ERROR(IOSTAT(dlun))
END
DETACH (dlun) ;Detach the LUN
1
A variable-length record is a text string terminated by a CR/LF (ASCII 13/ASCII 10).
2
When accessing files on a remote system (for example, when using Kermit), the unit can be
any name string, and the file name and extension can be any arbitrary string of characters.
Disk I/O
V+Language User's Guide, v17.0
Page 218