Handles can now be passed into subroutines and functions
Now Liberty BASIC code can pass a handle to a window, control, file, etc. into subroutines and functions. This makes it possible to make your code more flexible and reusable.
'file example
'Open a file for displaying
fName$ = "fileA.txt"
open fName$ for input as #firstFile
call displayFile fName$, #firstFile
close #firstFile
'Open another file for displaying
fName$ = "fileB.txt"
open fName$ for input as #secondFile
call displayFile fName$, #secondFile
close #secondFile
print
print "Done."
end
sub displayFile displayName$, #fHandle
print "Displaying the contents of "; displayName$
print "==============================================="
while eof(#fHandle) = 0
line input #fHandle, fileText$
print fileText$
wend
print "==============================================="
print
end sub