How to pass a message to a substack (or back)?

Klaus Major klaus at major-k.de
Fri Aug 26 13:50:13 EDT 2005


Hi Gajo,

> Hi,
>
> I have the main stack, and when I want to add a new item to a list a
> new dialog/substack is opened. Here the user can enter some
> information, and when he clicks on the OK button I want to send that
> information back to the main stack, so it would appear in the list.

this is a list on some card, a variable or custom property?

> How can I do it?

Try this in your script in your mainstack:

...
ask "Enter new list item:" with "New list item :-)"
## or whatever you want to ask the user...
if it <> empty then
   if fld "list field" of cd x <> empty then
       put CR & it after fld x of cd y
   else
      put it into fld x of cd y
   end if
...

or something like this, if i understood you correctly ;-)

You can also put this into a handler in your mainstack:

on append2mylist what
    if fld "list field" of cd x <> empty then
       put CR & it after fld x of cd y
     ##append 2 field
   else
      put it into fld x of cd y
     ##fill field
   end if
end append2mylist

...and call it from any other (sub)stack:

...
ask ...
## or not ask...
if it <> empty then
   send "append2mylist" && it to stack "mainstack goes here..."
end if
...

> I tried declaring a variable global but it seems I overestimated its
> globality, cause the other script can't see it. I also tried  
> creating a
> message in one stack, and then I call that from another stack, but the
> message can't be found from there.
>
> How can I do this?
>
> Thanks, Csaba

Regards

Klaus Major
klaus at major-k.de
http://www.major-k.de




More information about the use-livecode mailing list