Cᑍ
C eval FileName = %TRIMR(test_file) + Null
C eval FileDesc = open(%ADDR(FileName)
C : x'1A' : x'1C')
Cᑍ
Cᑍ Check for error and report status.
Cᑍ
C if FileDesc = -1
C eval PrintLine = 'Could not create file'
C exsr error
C eval ᑍINLR = '1'
C return
C else
C eval PrintLine = 'File '
C + %TRIMR(test_file)
C + ' created successfully'
C except
C end
Cᑍ
Cᑍ Write test_data to test_file via FileDesc returned by open
Cᑍ
C eval BytesWrt = write(FileDesc
C : %ADDR(Test_Data)
C : %SIZE(Test_Data))
Cᑍ
Cᑍ Check for error and report status. If an error occurs,
Cᑍ attempt cleanup.
Cᑍ
C if BytesWrt = -1
C eval PrintLine = 'Could not write to file'
C exsr error
C eval ReturnInt = close(FileDesc)
C eval ReturnInt = unlink(%ADDR(FileName))
C eval ᑍINLR = '1'
C return
C else
C eval PrintLine = 'Wrote to '
C + %TRIMR(test_file)
C + ' successfully'
C except
C endif
Cᑍ
Cᑍ Close test_file via FileDesc
Cᑍ
C eval ReturnInt = close(FileDesc)
Cᑍ
Cᑍ Check for error and report status. If an error occurs,
Cᑍ attempt cleanup.
Cᑍ
C if ReturnInt = -1
C eval PrintLine = 'Could not close file'
C exsr error
C eval ReturnInt = close(FileDesc)
C eval ReturnInt = unlink(%ADDR(FileName))
C eval ᑍINLR = '1'
C return
C else
C eval PrintLine = 'File '
Appendix B. Original Examples in Additional Languages B-185