PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Detecting a CALL  (Read 543 times)

ChrisKCAi

  • Silver Member
  • ***
  • Posts: 38
    • View Profile
Detecting a CALL
« on: January 12, 2023, 10:07:59 AM »
Is there a way to detect (within the program itself) that a program was CALLed - even if there are no arguments passed (i.e. tcb(20)=0)?
I know we can probably try to leverage the STK contents to try and figure it out but was wondering if there was something more straighforward/foolproof that we could use.

Thanks!

keith.mcbride

  • Member
  • **
  • Posts: 12
    • View Profile
Re: Detecting a CALL
« Reply #1 on: January 12, 2023, 10:13:51 AM »
I've always used TCB(13) - Current Program Level
If 1 then the program is being RUN
If > 0 then you are in a CALL, PERFORM, or object function

ChrisKCAi

  • Silver Member
  • ***
  • Posts: 38
    • View Profile
Re: Detecting a CALL
« Reply #2 on: January 12, 2023, 10:50:35 AM »
We had been using TCB(13) but in this particular case we have this scenario:
A lead-in program (lpg) PERFORMs program A which RUNs program B so TCB(13) is > 0 even though the program B was RUN.

Mike King

  • Diamond Member
  • *****
  • Posts: 3799
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Detecting a CALL
« Reply #3 on: January 12, 2023, 11:05:21 AM »
There is no way to determine the difference between a direct CALL versus a PERFORM/RUN.  Internally the only difference is that the variable table is not passed in on a CALL whereas the variable table is passed in on a PERFORM. 

Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

ChrisKCAi

  • Silver Member
  • ***
  • Posts: 38
    • View Profile
Re: Detecting a CALL
« Reply #4 on: January 12, 2023, 11:22:10 AM »
Thanks, Mike. Pretty much what I had suspected and we will have to manufacture something for this use case.