FUNCTION and SUB definitions cannot have line numbers
Jump to navigation
Jump to search
Description
Liberty BASIC supports the use of line numbers, for compatibility with traditional BASICs. However it is not always permissible to use a line number, for example if a FUNCTION or SUB statement has a line number an error will result.
Example code to demonstrate the bug
10 CALL MySub 20 PRINT MyFunction$() 30 END 40 50 SUB MySub 60 print "Hello "; 70 END SUB 80 90 FUNCTION MyFunction$() 100 MyFunction$ = "world!" 110 END FUNCTION
This program should run, but in fact an error is reported.
Example code to work around the bug
Delete the line numbers from any FUNCTION or SUB statements:
10 CALL MySub
20 PRINT MyFunction$()
30 END
40
SUB MySub
60 print "Hello ";
70 END SUB
80
FUNCTION MyFunction$()
100 MyFunction$ = "world!"
110 END FUNCTION