Page 1 of 1
PopUp Menu perceived anomaly
Posted: Thu Mar 16, 2023 11:16 am
by CAsba
Hi,
I'm using the following code:
Code: Select all
on menuPick pitemname
switch pitemname
case "The product is a consumable, normally sold in a shop, no invoice raised, for example, a packet of biscuits." #titled fld "fieldboxtitle" of cd "template1"
put "consu" into field "type"
send "mouseup" to btn "afterbiscuits"
exit menupick
break
exit menupick
end switch
but the btn 'afterbiscuits' is not invoked. Instead the code carries on - neither exit statement is invoked.
Any ideas why this is so ?
Re: PopUp Menu perceived anomaly
Posted: Thu Mar 16, 2023 11:42 am
by Klaus
Could you please post the complete "menupick" handler?
Re: PopUp Menu perceived anomaly
Posted: Thu Mar 16, 2023 12:08 pm
by CAsba
Hi Klaus, here it is..
Code: Select all
on menuPick pitemname
switch pitemname
case "The product is a consumable, normally sold in a shop, no invoice raised, for example, a packet of biscuits."
put "consu" into field "type"
send "mouseup" to btn "afterbiscuits"
exit menupick
break
exit menupick
end switch
switch pitemname
case "It is a service, for example, repairing computers. Any parts used would be invoiced seperately."
put "servi" into field "type"
break
end switch
switch pitemname
case "It is a product manufactured by the business, for example, an upholstered headboard."
put "manuf" into field "type"
break
end switch
switch pitemname
case "It is a component of a manufactured product, for example, a roll of fabric."
put "compo" into field "type"
break
end switch
switch pitemname
case "It is a consumer durable, for example, a sofa, or a car, where an invoice would normally be raised."
put "durab" into field "type"
break
end switch
answer "The type chosen may edited after the product entry is completed, if required"titled fld "fieldboxtitle" of cd "template1"
hide button "PopUp Menu1"
hide button "PopUp Menu3"
set the loc of btn "popup menu1" to "614,538"
set the loc of btn "popup menu2" to "614,538"
set the loc of btn "popup menu3" to "614,538"
show button "PopUp Menu2"
answer "Now select a further characteristic of the product."titled fld "fieldboxtitle" of cd "template1"
end menupick pitemname
Re: PopUp Menu perceived anomaly
Posted: Thu Mar 16, 2023 12:28 pm
by Klaus
Thanks, looks like a syntax issue!
You need to use only one SWITCH for all CASEs, the "break" will leave the switch automatically. Try this:
Code: Select all
on menuPick pitemname
switch pitemname
case "The product is a consumable, normally sold in a shop, no invoice raised, for example, a packet of biscuits."
put "consu" into field "type"
send "mouseup" to btn "afterbiscuits"
break
case "It is a service, for example, repairing computers. Any parts used would be invoiced seperately."
put "servi" into field "type"
break
case "It is a product manufactured by the business, for example, an upholstered headboard."
put "manuf" into field "type"
break
case "It is a component of a manufactured product, for example, a roll of fabric."
put "compo" into field "type"
break
case "It is a consumer durable, for example, a sofa, or a car, where an invoice would normally be raised."
put "durab" into field "type"
break
end switch
## Better use parens if you use concatenated object names:
answer "The type chosen may edited after the product entry is completed, if required" titled (fld "fieldboxtitle" of cd "template1")
hide button "PopUp Menu1"
hide button "PopUp Menu3"
set the loc of btn "popup menu1" to "614,538"
set the loc of btn "popup menu2" to "614,538"
set the loc of btn "popup menu3" to "614,538"
show button "PopUp Menu2"
## See above
answer "Now select a further characteristic of the product." titled (fld "fieldboxtitle" of cd "template1")
end menupick pitemname
Re: PopUp Menu perceived anomaly
Posted: Thu Mar 16, 2023 12:47 pm
by CAsba
Thanks, Klaus, I'll try it.
Re: PopUp Menu perceived anomaly
Posted: Thu Mar 16, 2023 1:12 pm
by CAsba
Hi Klaus,
Sorry to report that it is still nopt working. The send mouseup to the button 'afterbiscuits' is not being called.
Re: PopUp Menu perceived anomaly
Posted: Thu Mar 16, 2023 1:42 pm
by Klaus
Do you get any errors or does it just not work?
Is the button on the same card as the popup?
Hint:
If you use a handler more than once, it is always a good idea to "outsource" it to
the card or stack script. Do like this, instead of using a button script like:
Code: Select all
on mouseup
dothis
dothat
andthattoo
end mouseup
and later -> send "mouseup" to button X.
You should put this into the card or stackscript:
Code: Select all
command do_many_things
dothis
dothat
andthattoo
end do_many_things
And then this in the button script:
Code: Select all
on mouseup
do_many_things
end mouseup
This way you can execute this command later as often as neccessary outside of the button without the need to "send mouseup to ..."
To "debug" your handler, put only this into the button:
Code: Select all
on mouseup
beep
## your regular stuff
## and more of that but commented OUT!
end mouseup
And see if THAT works.
If not then there may be something wrong in the message path.
Re: PopUp Menu perceived anomaly
Posted: Thu Mar 16, 2023 2:15 pm
by CAsba
Hi Klaus,
I put in a simpler option ("12") and it called the btn "afterbiscuits"; so, that turned out to be an anomaly between the selection text and the script text, I suppose..
But, the exit instruction was not invoked, the afterbiscuits btn did its thing, but then the popupmenu was reverted to - the code at the bottom was invoked, so I still have a problem getting it to leave (exit) the popup.
Re: PopUp Menu perceived anomaly
Posted: Thu Mar 16, 2023 2:23 pm
by Klaus
Oh, sorry, my fault. Yes, this should do the trick:
Code: Select all
on menuPick pitemname
switch pitemname
case "The product is a consumable, normally sold in a shop, no invoice raised, for example, a packet of biscuits."
put "consu" into field "type"
send "mouseup" to btn "afterbiscuits"
## Misunderstood your first posting:
exit menupick
break
case "It is a
...
If that does not work try this instaed of exit menupick -> exit to top
Re: PopUp Menu perceived anomaly
Posted: Thu Mar 16, 2023 2:43 pm
by CAsba
Thanks, Klaus, everything fine !
Re: PopUp Menu perceived anomaly
Posted: Thu Mar 16, 2023 5:23 pm
by dunbarx
CAsba.
Great news.
You can see that there is a strict syntax in LC that one has to know how to use. The very english-like structure of the language makes users assume that if a person can understand what they are talking about, then the LC parser ought to be able to as well.
This comes with practice. Know, however, that it never quite goes away completely, however experienced one gets.
Craig