##- # Author: Brian Tiffin # Dedicated to the public domain # # Date: September, 2016 # Modified: 2016-10-03/22:40-0400 ##+ # # close.icn, demonstrate the close function # procedure main() # open the source file resource f := open(&file, "r") # show the first meaningful comment line read(f) write(read(f)) # close the resource, display the expression value write(image(close(f))) &error := 1 # next line will cause a runtime error, converted to failure write(read(f)) write("Error: ", &errornumber, " - ", &errortext) # open a pipe and check exit status write() write("open an 'ls' pipe, show first few entries, skip the rest") p := open("ls", "p") # show first few entries every 1 to 6 do write(read(p)) # spin past the rest while read(p) # display the close expression value write("Exit status from ls pipe: ", image(close(p))) end