[21 Feb 2008] Tracking Function Calls

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
PEB
Posts: 576
Joined: Sun Feb 21, 2010 1:28 am

[21 Feb 2008] Tracking Function Calls

Post by PEB »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 21 Feb 2008 02:01:44 -0000

Is there a way---not using DebugOutput()---to identify which function called a new function, and what input position of the first function initiated the call to the second function?

By way of example, if I have these two functions...

Code: Select all

Function p_FirstFunction(x, y)
    x=y/4
EndFunction

Function p_SecondFunction(x)
    x=x*2
EndFunction
...and if I would then do this...

p_FirstFunction(3, p_SecondFunction(7))

...is there a way that I can add some code to p_SecondFunction(x) so that it knows that it was p_FirstFunction(x, y) that called it, and that the call came from the second input position?

Thanks,
User avatar
Allanon
Posts: 742
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

[21 Feb 2008] Re: Tracking Function Calls

Post by Allanon »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 21 Feb 2008 09:14:13 -0000

Hello, I'm not sure if I've understood correctly, are looking for a method to recognise a function call by another function?

Maybe you can expand p_SecondFunction like this:

Code: Select all

Function p_SecondFunction(x, fname, ipos)
   if fname = p_FirstFunction
      NPrint("I was colled by p_FirstFunction:", fname)
      if pos = 1 Then NPrint("First argument")
      if pos = 2 Then NPrint("Sencond argument")
      x = x + 1
   else
      NPrint("What is this?", fname)
      x = 0
   endif
   
   x = x * 2
   return(x)
EndFunction

NPrint(p_FirstFunction(3, p_SecondFunction(7, p_FirstFunction, 2)))
If this method can help remember that all your function you want to check must be defined before p_SecondFunction definition.

Greets, Fabio
----------------------------
[Allanon] Fabio Falcucci | GitHub (leaving) | Gitea (my new house) | My Patreon page | All my links
PEB
Posts: 576
Joined: Sun Feb 21, 2010 1:28 am

[21 Feb 2008] Re: Re: Tracking Function Calls

Post by PEB »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 21 Feb 2008 14:46:57 -0800 (PST)

Hi Fabio,

Yes, I think you understand what I am trying to do; but I'm actually looking for a way that I could have Hollywood tell me what function called another, without ME having to specify it in the function call itself.
User avatar
airsoftsoftwair
Posts: 5834
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[22 Feb 2008] Re: Re: Tracking Function Calls

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 22 Feb 2008 11:26:49 +0100
Hi Fabio,

Yes, I think you understand what I am trying to do; but I'm actually looking for a way that I could have Hollywood tell me what function called another, without ME having to specify it in the function call itself.
No, that's not possible via the Hollywood API.
Locked