Listing 2.
function readfile which
local zeroLoc
open file which for read
if the result is not empty
then return empty # file wasn't there!
read from file which until empty
close file which
# find any 0 bytes and convert them to spaces
# the offset function returns 0 if not found
put offset(numToChar(0), it) into zeroLoc
repeat until zeroLoc is 0
put space into char zeroLoc of it
put offset(numToChar(0), it) into zeroLoc
end repeat
return it
end readfile
Copyright © 1994 - 2018 Linux Journal. All rights reserved.