D3 and mvBase

 View Only
  • 1.  Test and trapping execute "level"

    Posted 07-20-2022 12:08
    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
    ------------------------------


  • 2.  RE: Test and trapping execute "level"

    ROCKETEER
    Posted 07-20-2022 12:28
    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
    ------------------------------



  • 3.  RE: Test and trapping execute "level"

    Posted 07-20-2022 12:52
    Perfetto thanks 😉




  • 4.  RE: Test and trapping execute "level"

    Posted 07-21-2022 03:43
    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
    ------------------------------



  • 5.  RE: Test and trapping execute "level"

    ROCKETEER
    Posted 07-21-2022 10:05
    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
    ------------------------------



  • 6.  RE: Test and trapping execute "level"

    Posted 07-22-2022 09:43
    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
    ------------------------------



  • 7.  RE: Test and trapping execute "level"

    ROCKETEER
    Posted 07-22-2022 10:11
    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
    ------------------------------



  • 8.  RE: Test and trapping execute "level"

    ROCKETEER
    Posted 07-22-2022 11:30
    Edited by Brian Cram 07-22-2022 11:31
    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
    ------------------------------



  • 9.  RE: Test and trapping execute "level"

    Posted 07-22-2022 11:46

    Hy now. i have a questions about levels...

    how to use?  why to use ?  when to use ? what de advantages ?



    ------------------------------
    Alberto Leal
    System Analyst
    Millano Distribuidora de Auto Pecas Ltda
    Varzea Grande MT BR
    ------------------------------



  • 10.  RE: Test and trapping execute "level"

    ROCKETEER
    Posted 07-22-2022 13:38
    That's the thing about levels. YOU don't use them, D3 does. It pushes a level whenever you do an EXECUTE in a BP. On D3 Unix a CALLX will push a level to run the trigger. I can't remember other things that trigger a level push. Again, it's a D3 thing, not a developer thing.

    The only thing you should do about levels is to make sure your code doesn't create a max level condition. D3 can only push 15 on one PIB. If you're concerned, monitor WHERE L as well as monitoring LIST-ERRORS for B211 : Line ###: TCL level-push limit exceeded. There may be others that I can't remember.​

    ------------------------------
    Brian S. Cram
    Principal Technical Support Engineer
    Rocket Software
    ------------------------------