Hello,
Need help please. Lets say, i have two option menus in a card, with three options (A, B, C) and (X,Y, Z) on each one. How can I run a conditional function or do something, by checking that each menu option has some selection. like Option A in first menu and Option Z in second menu carry a specific funtion - like go to next card.
Until now, I have done this:
I have saved selection option in global variables.
On optionmenu
On menupick
put the label of me into choice1
end switch
end menupick
On card
on opencard
global choice1, choice2
if choice1 = "A" and choice2 = "Z" then
go to next card
on closecard
But it is not working. What am I doing wrong here?? Help appreciated.
Option Menu Selection
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Option Menu Selection
Hi.
I did not test your stuff, but you have to declare globals in every script they are used, and ABOVE any handler that uses them.
I would have set a custom property instead of a global, so that the above issue goes away, but that is just me.
Craig Newman
I did not test your stuff, but you have to declare globals in every script they are used, and ABOVE any handler that uses them.
I would have set a custom property instead of a global, so that the above issue goes away, but that is just me.
Craig Newman
Re: Option Menu Selection
Hi saviour,
what Craig said about globals!
Do like this:
Best
Klaus
what Craig said about globals!

Do like this:
Code: Select all
## Option menu:
global choice1
On menupick
put the label of me into choice1
## you do not have an SWITCH structure here, so no need for END SWITCH!
## end switch
end menupick
Code: Select all
## card script:
global choice1, choice2
on opencard
if choice1 = "A" and choice2 = "Z" then
go to next card
END IF
## !!!
on closecard
Klaus
Re: Option Menu Selection
Thanks for your response.
I did as you told. I think I am doing something wrong here and could not get it into working. Please check-
Following are the code in the option menus: (Similar code in another option menu as well)
on menuPick pItemName
switch pItemName
global choice1
case "A"
put the label of me into choice1
break
case "B"
put the label of me into choice1
break
case "C"
put the label of me into choice1
break
end switch
end menuPick
In the card
on opencard
global choice1, choice2
if choice1 = "A" and choice2 = "Z" then
go to next card
end if
end opencard
Thanks
I did as you told. I think I am doing something wrong here and could not get it into working. Please check-
Following are the code in the option menus: (Similar code in another option menu as well)
on menuPick pItemName
switch pItemName
global choice1
case "A"
put the label of me into choice1
break
case "B"
put the label of me into choice1
break
case "C"
put the label of me into choice1
break
end switch
end menuPick
In the card
on opencard
global choice1, choice2
if choice1 = "A" and choice2 = "Z" then
go to next card
end if
end opencard
Thanks
Re: Option Menu Selection
Hmmm.
You sort of have this right, but there are issues on two levels. Let's see if we can make the whole thing simpler and more robust.
Why load a global? In other words, if you already have the labels set in both option menus, then why not just test those values directly:
No globals, no custom properties.
Now then, if you have an openCard handler that tests the state of those menus, and that handler does indeed proceed, then you will navigate immediately to the next card. Well and good. But you can never get back to the card with the option menus. Do you see? You cannot change them, because you cannot access them.
So what to do? This depends on what your intentions are. Do you want to be able to change those labels from another place? That would do fine, and then you could access the card with the option menus if the labels did not pass muster, or go on to the next card if they did. But I have no idea if that suits your purpose. All I know is that there is likely a big problem with the way you have it set up now.
So write back and tell us.
Craig
You sort of have this right, but there are issues on two levels. Let's see if we can make the whole thing simpler and more robust.
Why load a global? In other words, if you already have the labels set in both option menus, then why not just test those values directly:
Code: Select all
If the label of btn "option1" = "A" and the label of btn "option2" = "Z" then...
Now then, if you have an openCard handler that tests the state of those menus, and that handler does indeed proceed, then you will navigate immediately to the next card. Well and good. But you can never get back to the card with the option menus. Do you see? You cannot change them, because you cannot access them.
So what to do? This depends on what your intentions are. Do you want to be able to change those labels from another place? That would do fine, and then you could access the card with the option menus if the labels did not pass muster, or go on to the next card if they did. But I have no idea if that suits your purpose. All I know is that there is likely a big problem with the way you have it set up now.
So write back and tell us.
Craig