Home › Forums › HTBasic Forum › SUBRoutine Question › Reply To: SUBRoutine Question
April 24, 2024 at 4:18 pm
#9333
Hi Jesus,
A SUB program is different from a subroutine that you GOSUB to and RETURN from. A SUB program must be placed after the main program’s END statement. And each SUB program (or DEF FN) you add after this must be added after any other existing SUBs or DEF FNs. A SUB program can have arguments and can be called with or without the CALL keyword. For example:
Mysub("Hello")
M$="There"
CALL Mysub(M$)
GOSUB Mysub
BEEP
STOP
Mysub:!
PRINT "Hi"
RETURN
END
SUB Mysub(A$)
PRINT A$
SUBEND
Note that the name of a SUB program can be the same as the label name for a subroutine, as above, but this is not good practice since it can be confusing.
Ralph