PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Was Program Called  (Read 985 times)

Jeffrey Ferreira

  • Diamond Member
  • *****
  • Posts: 175
  • I must have taken a wrong turn at Albuquerque.
    • View Profile
Was Program Called
« on: June 16, 2021, 10:53:39 AM »
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

  • Diamond Member
  • *****
  • Posts: 3811
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Was Program Called
« Reply #1 on: June 16, 2021, 11:02:52 AM »
Check STK(-1) == it will error out if you were not called.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Jeffrey Ferreira

  • Diamond Member
  • *****
  • Posts: 175
  • I must have taken a wrong turn at Albuquerque.
    • View Profile
Re: Was Program Called
« Reply #2 on: June 16, 2021, 11:11:43 AM »
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

  • Diamond Member
  • *****
  • Posts: 3811
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Was Program Called
« Reply #3 on: June 16, 2021, 11:21:56 AM »
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
eMail: mike.king@bbsysco.com