Toggle navigation
PxPlus User Forum
PxPlus User Forum
»
Main Board
»
Discussions
»
Language
»
Detecting a CALL
Likes
« previous
next »
Print
Pages: [
1
]
Author
Topic: Detecting a CALL (Read 298 times)
ChrisKCAi
Silver Member
Posts: 38
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!
Logged
keith.mcbride
Member
Posts: 12
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
Logged
ChrisKCAi
Silver Member
Posts: 38
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.
Logged
Mike King
Administrator
Diamond Member
Posts: 3770
Mike King
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.
Logged
ChrisKCAi
Silver Member
Posts: 38
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.
Logged
Print
Pages: [
1
]
« previous
next »
PxPlus User Forum
»
Main Board
»
Discussions
»
Language
»
Detecting a CALL