Instead of:
err: try [
file: open %bigdata.dat
da-head: read/part file 4000
da-body: read/seek/part file 12000 10000
da-tail: read/seek/part file 56000 4000
]
close file
if error? err [
print ["Port error:" form err]
]
there should be:
err: try [
file: open %bigdata.dat
da-head: read/part file 4000
da-body: read/seek/part file 12000 10000
da-tail: read/seek/part file 56000 4000
close file
]
if error? err [
print ["Port error:" form err]
]
Because is something is going to fail in the try code, than it is the file opening. If it fails, the file would be none and one would receive uncatched error, because close does not handle none value.
Or even better:
err: try [
file: open %bigdata.dat
da-head: read/part file 4000
da-body: read/seek/part file 12000 10000
da-tail: read/seek/part file 56000 4000
]
if file [close file]
if error? err [
print ["Port error:" form err]
]
Which will close the file in case, when fails the reading in the try block above.