Page 1 of 1

embedded FUNCTION/SUB

Posted: Thu Aug 06, 2020 12:01 pm
by olzeke51
BasicChip - mornin'
Ran into an issue with a FUNCTION(or a SUB) inside a SUB - is it legal??
"I was hoping to keep everything in the SUB task3 - so it could be transferred easily"
'
the following statements would imply [to me] that it is possible
'
Help File re: SUB says this"
Code labels for goto/gosub declared within the SUB procedure are also in the local scope. "
[am I misinterpreting 'Code labels for goto/gosub declared within '??]

Help File re: FUNCTION
"FUNCTIONs are an extension of SUB that will return a value. "
'
BTW if I move the FUNCTION outside of the SUB it works
' and the 'GOTO work3 will jump over some following code.
Thanks for clarifying this - Gary
code and compile results
code and compile results
FUNC_in_SUB_err.gif (228.99 KiB) Viewed 707 times

Re: embedded FUNCTION/SUB

Posted: Thu Aug 06, 2020 3:02 pm
by basicchip
nested FUNCTION or SUB are NOT allowed in BASIC, not sure I have ever seen that in any BASIC

Labels within FUNCTION/SUB are local to that FUNCTION/SUB. That is the way symbols are handled.