Was Program Called

Started by Jeffrey Ferreira, June 16, 2021, 10:53:39 AM

Previous topic - Next topic

Jeffrey Ferreira

Hi List

To determine if a program was called:
Thru the years, i've seen programs check tcb(13)<>0 but I have had problems with that.
Then i saw check tcb(20) but then I encountered programs called with no arguments.

Is there any sure fire fool proof way to know if a program was called.

jeff

Mike King

Check STK(-1) == it will error out if you were not called.
Mike King
President - BBSysco Consulting - http://www.bbsysco.com
eMail: mike.king@bbsysco.com

Jeffrey Ferreira

Hi Mike would this work if the called program was a few level deeps like this

run "TEST01"
   perform "TEST02;GET_ORDER_NUMBER"
          perform "TEST03;SEQUENCE_NUMBER_MAIN"
                  call "TEST03;GET_NEXT_SEQUENCE"

Mike King

STK(-1) returns the program name and line number that called/performed the current program.  The -1 indicates the relative level with -1 being the program above you in the stack (i.e. the program/line to return to when an EXIT/END is executed.  STK(-2) would get the program above that, and so on.
Mike King
President - BBSysco Consulting - http://www.bbsysco.com
eMail: mike.king@bbsysco.com