There is a mechanism in place to do this kind of thing. LC has an always-present variable called "the dialogData" which is specifically for passing information to a modal dialog, though you can use it to store any kind of data temporarily for any reason. It is volatile and likely to change at any time, much like the variable "it" or "the result", so you should populate it right before you open a modal stack and use the values immediately.
To use it, set the dialogData to the values the modal stack will need right before you issue the "sheet" command. In the substack that will become the modal dialog, use a preOpenCard handler to grab the values and set up the display. How you pass the values is up to you; sometimes just a comma-delimited string of values is enough. Or you might use an array, or name/value pairs, or anything else.
For example, in the main handler that will display the modal:
Code: Select all
put myWindow into item 1 of tValues -- window title
put myValue into item 2 of tValues -- option button selection
set the dialogData to tValues
sheet (the short name of this stack)
And in a preOpenCard handler of the sheet stack:
Code: Select all
on preOpenCard
get the dialogData
set the title of this stack to item 1 of it
lock messages
set the menuhistory of btn "optionButton" of me to item 2 of it -- typical way to handle menu setup
unlock messages
end preOpenCard
The reason to lock messages before setting menuHistory is because a menuPick message is sent automatically when the history changes, which you probably don't want to happen during initialization.