Skip to main content
Inspiring
November 22, 2009
Answered

Calling action/script...is it possible to determine?

  • November 22, 2009
  • 1 reply
  • 535 views

I'm just wondering if it's possible to determin within a script what the calling script or action is.

Example: Let's say I have Action 1 and Action 2 both call the same script. For Action 1 I'd prefer the script to do one thing while Action 2 I'd prefer something slightly different. Is it possible for the script to know that Action 1 activated it?

The same for when a script calls another script. Without the calling script setting anything external that the called script reads, can the called script know which script activated it?

This topic has been closed for replies.
Correct answer xbytor2

Take a look at $.stack. The last line should contain the top level script's name.

As for actions, you can't tell what action a script has been called from. I suggest creating wrapper scripts for the actions. Put the name of the action in the name of the script and have it include the real script. Create one per action. You can then use the $.stack trick to figure out which action was the caller.

-X

1 reply

xbytor2Correct answer
Inspiring
November 22, 2009

Take a look at $.stack. The last line should contain the top level script's name.

As for actions, you can't tell what action a script has been called from. I suggest creating wrapper scripts for the actions. Put the name of the action in the name of the script and have it include the real script. Create one per action. You can then use the $.stack trick to figure out which action was the caller.

-X

jugenjuryAuthor
Inspiring
November 22, 2009

Thank you, xbytor.

This solution is good enough for me.

My current method using actions is to have the action create a layer and give it a specific name, then have the called script check the layer name in a switch(case) argument. This works, but if the script could determine the calling action that would be easier.

Thank you again.

Mike