Parameter passing between stacks
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Parameter passing between stacks
Hi,
On this page I found the explanation about the command dispatch for passing a value to another stack.
I don't find how to catch the parameter in the
put "hello" into SampleField
dispatch SampleField to newstack
on open newstack
-- How can I catch the value of dispatched value???
end open
Any hints?
Thanks!
On this page I found the explanation about the command dispatch for passing a value to another stack.
I don't find how to catch the parameter in the
put "hello" into SampleField
dispatch SampleField to newstack
on open newstack
-- How can I catch the value of dispatched value???
end open
Any hints?
Thanks!
Re: Parameter passing between stacks
You need a message receiver in the target stack, as in:
Walt
Code: Select all
on Hello
put "Hello" into fld "fResults"
end Hello
Walt Brown
Omnis traductor traditor
Omnis traductor traditor
Re: Parameter passing between stacks
This concerns the sending of the field fResults - or not?Code: Select all
on Hello put "Hello" into fld "fResults" end Hello
So, how do I make the message receiver in the target stack?
Re: Parameter passing between stacks
No no, you have despatched the message "hello" to the new stack. In the new stack script you just need a handler to catch the message. So
Code: Select all
on hello
Answer "this is the response to the message despatched from the first stack"
End hello
Re: Parameter passing between stacks
or perhaps what you want is the SampleField to contain arguments to use in the destination stack. Something like
in the newstack stack script
Code: Select all
put "hello" into field "SampleField" --would have been typed by the user
dispatch "handleThis" to stack "newstack" with (field "SampleField")
Code: Select all
on handleThis pArgument
if pArgument is "hello" then
answer "you passed the argument 'hello' to the new stack"
else
answer "the argument" && pArgument && "is not recognised"
end if
end handleThis
Re: Parameter passing between stacks
Thats it! Thanks!SparkOut wrote:or perhaps what you want is the SampleField to contain arguments to use in the destination stack. Something like

Re: Parameter passing between stacks
… Execution error at line 2 (Chunk: no such object), char 1SparkOut wrote:Code: Select all
put "hello" into field "SampleField" --would have been typed by the user

(Strict compilation mode is turned off)
Re: Parameter passing between stacks
I'm assuming you have a field on your first card called "SampleField"
I'm assuming that you would expect to be able to type something in the field "SampleField" to be used as the argument to pass to the new stack.
I'm assuming you realise that the statement
put "hello" into field "SampleField"
is not necessary if you have such a field that you have typed "hello" (or anything else) into
I'm assuming that you would expect to be able to type something in the field "SampleField" to be used as the argument to pass to the new stack.
I'm assuming you realise that the statement
put "hello" into field "SampleField"
is not necessary if you have such a field that you have typed "hello" (or anything else) into