Getting values back from execLink

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
nirkedar
Cave Troll
Posts: 52
Joined: Tue Sep 21, 2010 3:13 pm

Getting values back from execLink

Post by nirkedar »

Is there a way to fetch a returning value from execLink() like macro.return does for MACRO() ?

In other words: after calling a certain macro, I can read the returned result by:
[H: MACRO(macroLinkText): params]
[H: Result = macro.return]

How do I retrieve the results of an execLink(macroLinkText)?

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Getting values back from execLink

Post by wolph42 »

Nope. Unless you make a circular reference (so the macro in the execlink calls the. Other macro with the right parameters). To get anything returned directly you should use UDFs or [macro:]


nirkedar
Cave Troll
Posts: 52
Joined: Tue Sep 21, 2010 3:13 pm

Re: Getting values back from execLink

Post by nirkedar »

Thanks for the replies. I saw both of these suggestions beforehand.

I got around it, but UDF does not work for me here because the macro name is unknown (i.e. has to be determined) before execution. It's complicated.
But thanks anyways.

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Getting values back from execLink

Post by CoveredInFish »

I can understand that dynamically build/choosen macro name/selection.

Could you explain why you choose Wiki: execLink() over [macro:]? If we see the reason behind that we might be able to offer a workaround.

I dont think wolph nor me get scared from a complicated macro ;-)

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Getting values back from execLink

Post by wolph42 »

yup same here, I have several routines where I execute an 'undetermined' macro based on the input of the user (or circumstances). I've devised two methods for that
1. [macro:]. Pretty obvious, just construct a string that resembles the name of the macro to execute and cram it in [macro:] and execute.
2. UDF, slightly trickier but not much. Same method as with one but now use eval("buildMacroName()"). Obviously the function names need to be defined for this to work.

nirkedar
Cave Troll
Posts: 52
Joined: Tue Sep 21, 2010 3:13 pm

Re: Getting values back from execLink

Post by nirkedar »

I ended up using the macro function in the end. For some strange reason it didn't work for me at first as far as using the original calling token's properties. Only after I manually called switchToken() to the original token did it use the correct properties.

LIB:A was calling a macro on LIB:B

On LIB:A the code went something like this:
[H, macro(ABC@LIB:B): params]
[H: X = macro.return]

All the property values were missing in the called macro (ABC@LIB:B).
When I checked why in ABC@LIB:B, by using
[H: broadcast(getName())],
I got "LIB:B" broadcasted???
Which explains why there were no property values.

All I had to do was add one line of code before the macro() call on LIB:A:
[H: switchToken("LIB:A")]
[H, macro(ABC@LIB:B): params]
[H: X = macro.return]

Makes no sense, but it worked.

Post Reply

Return to “Macros”