Is there any way to set a function as "global" so that it can be called from any handler in the same stack or subsequent substacks in similar fashion as global variables?
There are other ways of doing a similar thing, but this would be very useful since I'd rather not change it to an "on ..." or need to copy the same code to every handler of my program in order to use the function, and sending the function's name and parameters (as a message) just gives errors.
If it's not possible, then I'll just find a different way to make it work.
Global Functions?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Global Functions?
You can call a function remotely using this syntax:
put value("myfunction(param)",<script reference>)
For example, to call a function named "myFunction" with two parameters, where the function is in the second card of the stack, do this:
put 1 into a
put "dog" into b
put value("myFunction(a,b)",card 2 of this stack)
put value("myfunction(param)",<script reference>)
For example, to call a function named "myFunction" with two parameters, where the function is in the second card of the stack, do this:
put 1 into a
put "dog" into b
put value("myFunction(a,b)",card 2 of this stack)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Global Functions?
Why not to put the function as main stack function and call it directly?
Marek.
Marek.
Re: Global Functions?
If the function is only used in a single stack, that is what I would do too. The remote call is handy if you want to use a function from a different stack and you don't have a library in use.snm wrote:Why not to put the function as main stack function and call it directly?
put 1 into a
put "dog" into b
put value("myFunction(a,b)",card 2 of stack "otherStack")
It's as close as we get for a "global" function. If there's a library in use, then that's where I would put it instead.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com