Update a global when going to a stack as modal
Frank Leahy
frank at backtalk.com
Thu Jan 8 18:52:11 EST 2004
Mark,
This doesn't work because LINE 3 gets executed right after LINE 2, not
after the dialog is closed (i.e. Revolution doesn't wait for the modal
dialog to be closed before it executes LINE 3).
In stack A you'll need two functions, one that setups and then calls
the modal dialog, and the other (I call it a return handler) that is
called when the modal dialog is closed:
global gFoo, gMyDialogHandler
on functionA
put "Before" into global gFoo
put "MyReturnFunction" into gMyDialogHandler
push card
go to stack B as modal
end functionA
on MyReturnFunction
put gFoo into field "Information"
end MyReturnFunction
In stack B, when the modal dialog is closed, do this:
global gFoo, gMyDialogHandler
put myData into gFoo
destroy stack this stack
pop card
-- you're back at stack A at this point, so call your return handler
send gMyDialogHandler to this stack
Hope this helps.
-- Frank Leahy
http://cornwall.backtalk.com/
On Thursday, January 8, 2004, at 10:53 PM,
use-revolution-request at lists.runrev.com wrote:
> Just to get the obvious out of the way....you *did* define gFoo as a
> global in Stack B...correct?
>
> ======= At 2004-01-07, 12:20:00 you wrote: =======
>
>> I have a handler in stack A of the pseudo form below
>> ...
>> LINE 1 <put "Before" into global gFoo>
>> LINE 2 <go to stack B as modal; user input there goes into gFoo>
>> LINE 3 <put gFoo into fld "Information" of stack A>
>> ...
>>
>> The text that is put into the field on stack A is inevitably "Before".
>> However, if I immediately type
>>
>> put gFoo into fld "Information"
>>
>> the data that was collected in stack B is put into the field in stack
>> A as
>> expected. The global is populated as I would want, except it is as
>> if line
>> 3 above is run before line 2. What is going on? Can I not switch
>> between
>> stacks and collect data? Is there a workaround?
>>
>> Mark
More information about the use-livecode
mailing list