OK, Stefano, nice talk on the phone.
Summary: In a BP, EXECUTE anything pushes a level to do whatever you execute, including the WHERE in the example program below. Notice that the WHERE status shows the level number of each level.
Execution of the BP does not continue until whatever is executed is complete, wrapped up, and level terminated ( "popped" ). Then the BP continues at the next statement that logically follows the EXECUTE.
Sample program and output:
* Program: levels
*
lvl = system(16)
crt "Here I am at level ":lvl
execute \where \:@pib:\ l\
if lvl < 3 then
crt "Executing myself again"
execute \run bp levels\
crt "Now I'm back at level ":lvl
end
:run bp levels
Here I am at level 0
Ln PCB PIB ABS Stat R1 & Return stack contents 22 Jul 2022
FID Stat Base 08:19:12
*0001 00003728 FF90 000018 1 WS_WHERE1:000 WS_WHATWHERE:000
00000081 FF90 000018 0 PP_NEWLEVEL:000 BR_NOITMOUT:000
Executing myself again
Here I am at level 1
Ln PCB PIB ABS Stat R1 & Return stack contents 22 Jul 2022
FID Stat Base 08:19:12
*0001 00003378 FF90 000018 2 WS_WHERE1:000 WS_WHATWHERE:000
00003794 FF90 000018 1 PP_NEWLEVEL:000 BR_NOITMOUT:000
00000081 FF90 000018 0 PP_NEWLEVEL:000 BR_NOITMOUT:000
Executing myself again
Here I am at level 2
Ln PCB PIB ABS Stat R1 & Return stack contents 22 Jul 2022
FID Stat Base 08:19:12
*0001 0000359E FF90 000018 3 WS_WHERE1:000 WS_WHATWHERE:000
0000337B FF90 000018 2 PP_NEWLEVEL:000 BR_NOITMOUT:000
00003794 FF90 000018 1 PP_NEWLEVEL:000 BR_NOITMOUT:000
00000081 FF90 000018 0 PP_NEWLEVEL:000 BR_NOITMOUT:000
Executing myself again
Here I am at level 3
Ln PCB PIB ABS Stat R1 & Return stack contents 22 Jul 2022
FID Stat Base 08:19:12
*0001 0000361B FF90 000018 4 WS_WHERE1:000 WS_WHATWHERE:000
000035A1 FF90 000018 3 PP_NEWLEVEL:000 BR_NOITMOUT:000
0000337B FF90 000018 2 PP_NEWLEVEL:000 BR_NOITMOUT:000
00003794 FF90 000018 1 PP_NEWLEVEL:000 BR_NOITMOUT:000
00000081 FF90 000018 0 PP_NEWLEVEL:000 BR_NOITMOUT:000
Now I'm back at level 2
Now I'm back at level 1
Now I'm back at level 0
Hope this clears up any questions about level pushing.
------------------------------
Brian S. Cram
Principal Technical Support Engineer
Rocket Software
------------------------------
Original Message:
Sent: 07-22-2022 10:11
From: Brian Cram
Subject: Test and trapping execute "level"
OK, one of us is really confused. You have my bcram@rocketsoftware.com email address. Please email me a direct phone number at which I can call you. It's time to talk this through.
------------------------------
Brian S. Cram
Principal Technical Support Engineer
Rocket Software
Original Message:
Sent: 07-22-2022 09:43
From: Stefano Gallotta
Subject: Test and trapping execute "level"
Hi Brian
Concerned to execute "Stop" which would then terminate the process, that's why I stated execute "end" - but please test.
Thanks
------------------------------
Stefano Gallotta
Managing Member
Simply Red Open Systems
Milnerton ZA
Original Message:
Sent: 07-21-2022 10:04
From: Brian Cram
Subject: Test and trapping execute "level"
First of all, the maximum number of levels is 16. As far as exiting a level from a BP, "STOP" should do it ( I'll test that ). The main thing is probably to review your code and figure out why you're pushing so many levels in the first place. Any "EXECUTE" in a BP will do it. SELECT from TCL will do it. Haven't thought much about what else will.
------------------------------
Brian S. Cram
Principal Technical Support Engineer
Rocket Software
Original Message:
Sent: 07-21-2022 03:43
From: Stefano Gallotta
Subject: Test and trapping execute "level"
Hi Chris, so just one more thing ...
Would I just execute an "END" (execute 'end') at any stage where SYSTEM(16) gets larger than what, 10?
Is this the "preferred" method? or is there one more elegant?
Thanks
------------------------------
Stefano Gallotta
Managing Member
Simply Red Open Systems
Milnerton ZA
Original Message:
Sent: 07-20-2022 12:28
From: Chris Macadam
Subject: Test and trapping execute "level"
Hi Stefano,
In BASIC you can use the system() function to retrieve the level:
level = system(16)
Cheers.
------------------------------
Chris Macadam
Technical Support Engineer
Rocket Software
Original Message:
Sent: 07-20-2022 12:08
From: Stefano Gallotta
Subject: Test and trapping execute "level"
Hi all
Is there a way to test the "level" that one has arrived at when the "execute" (verb) is used in code?
It is of my opinion, that if one reaches past a certain level, this may cause the code to break (and falls into debug)
I remember with the ADDS Mentor implementation, there was a check (some system(??) ) which one could test and take the appropriate action.
Failing which, I guess, a simple stack_pointer counter may have to be implemented before such an (execute) statement - but that's messy :)
Thanks
------------------------------
Stefano Gallotta
Managing Member
Simply Red Open Systems
Milnerton ZA
------------------------------