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