It seems not, because the following does not work (I have a similar construct in another SuperBASIC program, where the WHEN ERRor is outside of a PROCedure/FuNction, and there this construct (which should simulate a C++ try {...} catch {...}) seems to work.
But the Following example just prints "In WHEN Error" and afterwards WHEN ERRor processing is still on. It seems the WHEN ERRor:END WHEN in 1210 does not switch off error processing. I have also tried a (IMHO not necessary) CONTINUE before the first END WHEN (line 1160), but this doesn't change the behaviour. The example program below is a stripped down version of a program, I want to develop. In reality the user should be able to specify the CON channel, the CON channel con$ in 259 is only the initial CON channel which can be opened on any QL. In the real program the user can input the CON channel (with my improved EDLINE$-function) and retry or quit with ESC.
Code: Select all
100 REMark Test Program for WHEN ERRor in FuNction
140 :
180 REMark SB channels:
220 c%=5: REMark SB CONsole-channel for normal in-/output (from/to screen)
259 con$='CON_252x200a0x0':OPEN#c%,con$:REMark Initial CON channel
500 init
540 PRINT#c%,'Hello in new CON channel'
660 CLOSE#c%
10000 :
10040 DEFine PROCedure init
10050 REPeat _setCon_
10160 newcon$='CON_454x460a512x30'
10200 IF checkCONchan$(newcon$)=''
10240 PRINT#c%,'Bad CON channel specification':stop
10320 END IF
10360 EXIT _setCon_
10400 END REPeat _setCon_
10440 CLS#c%:PAPER#c%,4:INK#c%,0:CLS#c%
10480 PAPER#c%,4:in:PRINT#c%,'Just a test program for WHEN ERRor'
10920 END DEFine init
10960 :
11000 DEFine FuNction checkCONchan$(con_$)
11040 LOCal _catch%
11080 REMark REPeat _checkCon_
11120 _catch%=0
11160 WHEN ERRor :catch%=1:PRINT'In WHEN ERRor':CONTINUE:END WHEN
11200 OPEN#c%,con_$&'_512'
11210 WHEN ERRor :END WHEN
11220 PRINT'Before IF _catch%'
11240 IF _catch%
11320 PRINT"Before RETurn ''":RETurn ''
11330 END IF
11360 REMark EXIT _checkCon_
11400 REMark END REPeat _checkCon_
11440 PRINT'Before ...:RETurn con_$':con$=con_$:RETurn con_$
11450 END DEFine checkCONchan$