From what I remember, you can do this almost with colan to have multiple commands on the same line. Not the most elegant solution, but will allow you to figure out:
10 def fn X(n) = 20 n = n + 1 30 print n 40 rem I'd like the definition of function X to end at line 30 above 50 fn X(5) rem Produces syntax error on line 40
becomes
10 n=n+1: print n
Note that you cannot pass arguments, so you have to declare things and let the BASIC stack take care of this for you. Usually I would structure such programs:
1 rem lines 1-99 are definitions. 2 n% = 0 : rem this declares the variable n as an integer, initializing it to 0 100 rem lines 100-59999 are the core code 101 n%=5 : gosub 60100 59999 end : rem explicit end of the program to ensure we don't run into our subroutine block 60000 rem lines 60000+ are my subroutines.. 60100 n% = n% + 1 : print n% : return
It has been a while; from memory, the% symbol is what declares the variable as an integer, like $ declaring it as a string.
source share