OPTION STACK |
![]() ![]() |
OPTION STACK size
Sets the call stack size. This will allow calls up to size levels or the size number of recursive calls. The default size is 255. You can increase this size if needed but you may run into unexpected MyBASIC2 failures. The max size depends on your system configuration.
Example:
OPTION STACK 8 ' Set call stack to 8 ON ERROR GOTO _ERR_HANDLER
'''''''''''''''''''''''''''''''''''''''''''''''''''
SUB PrintArray( arr AS INTEGER ) PRINT "CALLS: ";arr, arr = arr + 1 ' Keep calling until overflow IF NOT bOverflow THEN CALL PrintArray( arr ) ENDIF END SUB
'''''''''''''''''''''''''''''''''''''''''''''''''''
DIM bOverflow AS INTEGER
PRINT "[RUN]", bOverflow = FALSE CALL PrintArray( 1 ) PRINT "[END]",
END
'''''''''''''''''''''''''''''''''''''''''''''''''''
_ERR_HANDLER: PRINT ERRM(), ' Check if stack overflow error IF ERR() = 182 THEN ' Signal end bOverflow = TRUE ENDIF RESUME NEXT
|