IBM Version 4 Universal Remote User Manual


 
PERFORM ERROR-FOUND,
ELSE MOVE TEST-FILE TO FILENAME,
WRITE LIST-LINE FROM NEWFIL.
ᑍ Write TEST-DATA to test.file via file descriptor from open
CALL "write" USING BY VALUE FILE-DESCRIPTOR,
BY VALUE ADDRESS OF TEST-DATA,
BY VALUE SIZE-TEST-DATA,
GIVING BYTES-WRITTEN.
ᑍ Check for error and report status.
IF BYTES-WRITTEN = -1 MOVE "Could not write to file"
TO LIST-LINE,
PERFORM ERROR-FOUND,
ELSE MOVE "Wrote to file successfully"
TO LIST-LINE,
WRITE LIST-LINE.
ᑍ Close test.file via file descriptor
CALL "close" USING BY VALUE FILE-DESCRIPTOR,
GIVING RETURN-INT.
ᑍ Check for error and report status.
IF RETURN-INT = -1 MOVE "Could not close file"
TO LIST-LINE,
PERFORM ERROR-FOUND,
ELSE MOVE "Successfully closed file"
TO LIST-LINE,
WRITE LIST-LINE.
ᑍ Open the file test.file for reading.
CALL "open" USING BY VALUE ADDRESS OF TESTFILE,
BY VALUE OFLAG-READ,
GIVING FILE-DESCRIPTOR.
ᑍ Check for error and report status.
IF FILE-DESCRIPTOR = -1 MOVE "Could not open file"
TO LIST-LINE,
PERFORM ERROR-FOUND,
ELSE MOVE "File open successful"
TO LIST-LINE,
WRITE LIST-LINE.
ᑍ Read from test.file via file descriptor from open
CALL "read" USING BY VALUE FILE-DESCRIPTOR,
BY VALUE ADDRESS OF BUFFER,
BY VALUE LENGTH-OF-BUFFER,
GIVING BYTES-READ.
ᑍ Check for error and report status.
Appendix B. Original Examples in Additional Languages B-181