IBM Version 4 Universal Remote User Manual


 
1 TESTFILE.
5 TEST-FILE PIC X(9) VALUE "test.file".
5 NULL-TERMINATE PIC X(1) VALUE LOW-VALUE.
1 OFLAG PIC X(4) VALUE X"1A".
1 OFLAG-READ PIC X(4) VALUE X"1".
1 OMODE PIC X(4) VALUE X"1C".
1 TEST-DATA PIC X(12) VALUE "Hello World!".
1 SIZE-TEST-DATA PIC S9(9) BINARY VALUE 12.
1 FILE-DESCRIPTOR PIC S9(9) BINARY.
1 BYTES-READ PIC S9(9) BINARY.
1 BYTES-WRITTEN PIC S9(9) BINARY.
1 RETURN-INT PIC S9(9) BINARY.
1 RETURN-PTR POINTER.
ᑍ Beginning of mainline
PROCEDURE DIVISION.
MAIN-LINE.
OPEN OUTPUT LISTING.
ᑍ Get and print the real user id with the getuid function.
CALL "getuid" GIVING RETURN-INT.
ᑍ Check for error and report status.
IF RETURN-INT = -1 MOVE "Error getting real user id"
TO LIST-LINE,
PERFORM ERROR-FOUND,
ELSE MOVE RETURN-INT TO USER,
WRITE LIST-LINE FROM REALID.
ᑍ Get the current working directory and store it in BUFFER
CALL "getcwd" USING BY VALUE ADDRESS OF BUFFER,
BY VALUE LENGTH-OF-BUFFER,
GIVING RETURN-PTR.
ᑍ Check for error and report status.
IF RETURN-PTR = NULL MOVE "Error getting real current dir"
TO LIST-LINE,
PERFORM ERROR-FOUND,
ELSE MOVE BUFFER TO INITIALDIR,
WRITE LIST-LINE FROM CURDIR.
ᑍ Create the file test.file for writing. If it does not exist,
ᑍ give the owner authority to read, write, and execute.
CALL "open" USING BY VALUE ADDRESS OF TESTFILE,
BY VALUE OFLAG,
BY VALUE OMODE,
GIVING FILE-DESCRIPTOR.
ᑍ Check for error and report status.
IF FILE-DESCRIPTOR = -1 MOVE "Could not create file"
TO LIST-LINE,
B-180 System API Programming V4R1