Ah... you're stumbling your way into the object hierarchy. This is a good thing <g> and you're close to one of those "Aha!" moments:
Your "myVariable" variable has a local scope - it can't be seen outside of your combobox object. If you want it visible outside the combobox then there at least a couple of alternatives. Here's the first:
The combobox object is at the front of an object hierarchy. It will get messages first, and messages it doesn't handle are passed through the hierarchy to the card and the stack (this is a simplified view - actually there are other objects along the way that can intercept messages, but let's not complicate things at the moment). So let's put the process one level back, in the card script:
Code: Select all
-- put this in the card script
local sFirstVariable
local sSecondVariable
on StoreFirstVariable pVar
put pVar into sFirstVariable
end StoreFirstVariable
on StoreSecondVariable pVar
put pVar into sSecondVariable
end StoreSecondVariable
on MultiplyThemAndDisplayTheResult
answer sFirstVariable * sSecondVariable
end MultiplyThemAndDisplayTheResult
and put this into the first combobox:
Code: Select all
on MenuPick pChoice
StoreFirstVariable pChoice
end MenuPick
and do the same with the second combobox. Now both comboboxes have access to the routines in the card, and the card handlers do the heavy lifting. You'll probably want a button on your card with
Code: Select all
on mouseUp
MultiplyThemAndDisplayTheResult
end mouseUp
There are many ways to approach this situation, and this is just one. Richard Gaskin (da man) has a great writeup on the object hierarchy on his web site. I don't have the url in front of me at the moment (it really should be engraved on my brain by now), but poke around at
www.fourthworld.com. The idea is that code should be placed in the appropriate place in the hierarchy, and "appropriate" is left up to you to decide - I usually start placing code down the hierarchy if I use a routine more that twice, but putting handlers in the right place enables all sorts of magic to happen.[/code]