Appendix B. Original Examples in Additional

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 op￿en

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 '

BLanguages-185

Page 463
Image 463
IBM Version 4 manual BLanguages-185