With a drop down (ie combo box or option menu) button you can find out the currently selected item in the menu by testing the menuHistory property, which returns the line number of the last selected item in the menu. In the script of the calculate button you could:
Code: Select all
-- say the menu choices are "Private" and "Corporate" and "Other" (in that order)
-- and the latest selected choice is "Private"
-- we get the line number
put the menuHistory of button "Purchase Type" into tPTline
-- tPTline should now contain 1
-- we can then get that line of text for our purposes
-- the text of button "Purchase Type" is the list of all the menu choices
-- now that we know which line of the text it is we want, we can
put line tPTline of the text of button "Purchase Type" into tG4
Of course, when you make your choice on the original combo box or option menu button, it will trigger its own "menuPick" message so you could use that to put the current selected choice into a field "Purchase Type" which you may find simpler. Or you could set a custom property which is just as simple (perhaps not so obvious, but still). Instead of the above, in the script of the menu button
Code: Select all
on menuPick pItemName
-- put the current choice into a visible field
put pItemName into field "Purchase Type"
-- or set a custom property
set the currentChoice of me to pItemName
end menuPick
Then in the script of the calculate button you can ignore the method of getting the right value for tG4 using menuHistory, and either stick with reading the value from the field, or
Code: Select all
put the currentChoice of button "Purchase Type" into tG4
There are lots of ways to do almost anything in LiveCode. Sometimes this can be confusing, but it is a great flexibility when you have more experience. Try checking all the tutorials you can to get more used to the basics, it will greatly help in the future.
PS, in all of this the variable names tG4 etc are only chosen because of the original reference to the cell on the Excel sheet you were interested in, just to make it clearer what we were dealing with. There's nothing to stop you using more specific variable names (eg tPurchaseType) if you wished.