PxPlus User Forum

Main Board => Discussions => Language => Topic started by: ChrisKCAi on January 12, 2023, 10:07:59 AM

Title: Detecting a CALL
Post by: ChrisKCAi 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!
Title: Re: Detecting a CALL
Post by: keith.mcbride 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
Title: Re: Detecting a CALL
Post by: ChrisKCAi 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.
Title: Re: Detecting a CALL
Post by: Mike King 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. 

Title: Re: Detecting a CALL
Post by: ChrisKCAi 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.