Storing menu option data
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Storing menu option data
Hello,
I Implemented a Combobox(menu option) inside my code:
on menuPick pItemName
switch pItemName
case "Yes"
answer "You selected Yes" with "Okay"
break
case "No"
answer "You selected No" with "Okay"
break
case "NA"
answer "You selected NA" with "Okay"
break
end switch
end menuPick
How do I store pItemName so that I can use it in my array like this?:
put text of field "pItemName" into myData["pItemName"]
I know the above is wrong but this is similar to what I need to do.
I just need to store my answer so that I can use it later.
Thanks!
I Implemented a Combobox(menu option) inside my code:
on menuPick pItemName
switch pItemName
case "Yes"
answer "You selected Yes" with "Okay"
break
case "No"
answer "You selected No" with "Okay"
break
case "NA"
answer "You selected NA" with "Okay"
break
end switch
end menuPick
How do I store pItemName so that I can use it in my array like this?:
put text of field "pItemName" into myData["pItemName"]
I know the above is wrong but this is similar to what I need to do.
I just need to store my answer so that I can use it later.
Thanks!
Re: Storing menu option data
Hi.
What makes you think the the line of code is wrong?
Anyway, if you want to store it, set a custom property:
set the yourPropertyName of btn "yourButton" to pItemName.
That can be executed in the option button script. Note that since pItemName is a variable, it must not be quoted.
Craig
What makes you think the the line of code is wrong?
Anyway, if you want to store it, set a custom property:
set the yourPropertyName of btn "yourButton" to pItemName.
That can be executed in the option button script. Note that since pItemName is a variable, it must not be quoted.
Craig
Re: Storing menu option data
Hi, Thanks for the response.
Still having a bit of an issue.
pItemName stores my selection. In this case 'Yes.'
I'm looking to store the selection into a variable so I can use it later.
I'm used to doing this with a text field like so:
put htmltext of field "company_name" into myData["company_name"]
but not sure how to do this with a combobox/menu option.
Still having a bit of an issue.
pItemName stores my selection. In this case 'Yes.'
I'm looking to store the selection into a variable so I can use it later.
I'm used to doing this with a text field like so:
put htmltext of field "company_name" into myData["company_name"]
but not sure how to do this with a combobox/menu option.
Re: Storing menu option data
Hi tasdvl9,
what about something like this, please note my short script, which is pure lazyness
Best
Klaus
what about something like this, please note my short script, which is pure lazyness

Code: Select all
on menuPick pItemName
global myData ##?
answer ("You selected" && pItemName) with "Okay"
put pItemName into myData["user_choice"]
end menuPick
Klaus
Re: Storing menu option data
Hi.
When you say "store for later", I take this to mean really later. A custom property is stored with the stack file, like text in a field. So if you had your original handler:
At any time you need to, in any script or by hand, you can:
answer the selectionPicked of this button
Or am I missing this?
Craig
When you say "store for later", I take this to mean really later. A custom property is stored with the stack file, like text in a field. So if you had your original handler:
Code: Select all
on menuPick pItemName
switch pItemName
case "Yes"
set the selectionPicked of this button to pItemName --THIS IS WHERE THE DATA IS STORED IN A CUSTOM PROPERTY
answer "You selected Yes" with "Okay"
break
case "No"
answer "You selected No" with "Okay"
break
case "NA"
answer "You selected NA" with "Okay"
break
end switch
end menuPick
answer the selectionPicked of this button
Or am I missing this?
Craig
Re: Storing menu option data
Wow Craig!
You just set a light-bulb off in my head!
One doesn't have to pre-define a custom property like a global must be. It does add "of this stack" or whatever. I may just give up on using globals.
Simon
You just set a light-bulb off in my head!
One doesn't have to pre-define a custom property like a global must be. It does add "of this stack" or whatever. I may just give up on using globals.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Storing menu option data
Outstanding, Everyone!
Thanks! That's exactly what I was looking for. I appreciate the responses.
Quick question..
Is there a way to get the current selection of the menu option?
When my card is invoked I'd like to be able to retrieve the current answer(yes/no) in the menu option.
In C++ you can do something like GetCurrentSelection->handleTocontrol
So I was wondering if you can do something similar in Livecode.
Forgive my reference to C++. I just wanted to further illustrate what I am asking
Thanks!
Thanks! That's exactly what I was looking for. I appreciate the responses.
Quick question..
Is there a way to get the current selection of the menu option?
When my card is invoked I'd like to be able to retrieve the current answer(yes/no) in the menu option.
In C++ you can do something like GetCurrentSelection->handleTocontrol
So I was wondering if you can do something similar in Livecode.
Forgive my reference to C++. I just wanted to further illustrate what I am asking

Thanks!
Re: Storing menu option data
Simon.
Properties (and custom properties) are sort of like "ordinary" variables that way, though they must be married to an object. They are "declared" and populated on the fly. So easy...
Craig
Properties (and custom properties) are sort of like "ordinary" variables that way, though they must be married to an object. They are "declared" and populated on the fly. So easy...
Craig
Re: Storing menu option data
Read up on the "menuHistory" in the dictionary.Is there a way to get the current selection of the menu option?
When my card is invoked I'd like to be able to retrieve the current answer(yes/no) in the menu option.
Craig
Re: Storing menu option data
Hi tasdvl9,
...
put the LABEL of btn "your option menu button here..." into tCurrentSelection
...
Best
Klaus
yes:tasdvl9 wrote:Is there a way to get the current selection of the menu option?
...
put the LABEL of btn "your option menu button here..." into tCurrentSelection
...

Best
Klaus
Re: Storing menu option data
Thanks, guys! 
Works like a charm.

Works like a charm.