Button Drop-menu need help with script
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 8
- Joined: Mon Sep 24, 2012 5:37 pm
Button Drop-menu need help with script
Using LiveCode Community edition version 8.0.1 on Windows 10 laptop
I have a button with a dropdown menu. I have based my code on the code provided by the Menu Builder. The code is accepted without errors. In run mode menu items selected are ignored. Below is a copy of the script:
on menuPick pWhich
switch --pWhich
case "New"
go back --Does not work
answer pWhich--Insert script for New menu item here
break
case "Edit"
answer pWhich--Insert script for Edit menu item here
answer pWhich
break
case "Delete"
answer pWhich--Insert script for Delete menu item here
break
case "Print"
answer pWhich--Insert script for Print menu item here
break
case "Graphs"
answer pWhich--Insert script for Graphs menu item here
break
case "Backup"
answer pWhich--Insert script for Backup menu item here
break
case "Restore"
answer pWhich--Insert script for Restore menu item here
break
case "Import"
answer pWhich--Insert script for Import menu item here
break
case "Export"
answer pWhich--Insert script for Export menu item here
break
case "Backup"
answer pWhich--Insert script for Backup menu item here
break
case "Restore"
answer pWhich--Insert script for Restore menu item here
break
case "Preferences"
answer pWhich--Insert script for Preferences menu item here
break
case "Help"
answer pWhich--Insert script for Help menu item here
break
case "Exdit Program"
quit
answer pWhich--Insert script for Exit menu item here
break
end switch
end menuPick
I would be most grateful for any assistance.
Derek Henderson
I have a button with a dropdown menu. I have based my code on the code provided by the Menu Builder. The code is accepted without errors. In run mode menu items selected are ignored. Below is a copy of the script:
on menuPick pWhich
switch --pWhich
case "New"
go back --Does not work
answer pWhich--Insert script for New menu item here
break
case "Edit"
answer pWhich--Insert script for Edit menu item here
answer pWhich
break
case "Delete"
answer pWhich--Insert script for Delete menu item here
break
case "Print"
answer pWhich--Insert script for Print menu item here
break
case "Graphs"
answer pWhich--Insert script for Graphs menu item here
break
case "Backup"
answer pWhich--Insert script for Backup menu item here
break
case "Restore"
answer pWhich--Insert script for Restore menu item here
break
case "Import"
answer pWhich--Insert script for Import menu item here
break
case "Export"
answer pWhich--Insert script for Export menu item here
break
case "Backup"
answer pWhich--Insert script for Backup menu item here
break
case "Restore"
answer pWhich--Insert script for Restore menu item here
break
case "Preferences"
answer pWhich--Insert script for Preferences menu item here
break
case "Help"
answer pWhich--Insert script for Help menu item here
break
case "Exdit Program"
quit
answer pWhich--Insert script for Exit menu item here
break
end switch
end menuPick
I would be most grateful for any assistance.
Derek Henderson
Re: Button Drop-menu need help with script
Hi Derek,
well, this should do the trick:
If you comment out the parameter -> pWhich, then the engine does not know
what exactly to "switch" and thus NO "case" will fit here!
And if you quit, the next line will of course never be executed:
Best
Klaus
well, this should do the trick:
Code: Select all
on menuPick pWhich
## switch --pWhich
switch pWhich
case "New"
...
what exactly to "switch" and thus NO "case" will fit here!
And if you quit, the next line will of course never be executed:
Code: Select all
...
case "Exdit Program"
quit
answer pWhich--Insert script for Exit menu item here
break
...
Klaus
-
- Posts: 8
- Joined: Mon Sep 24, 2012 5:37 pm
Re: Button Drop-menu need help with script
Hi Klaus
Thanks for such a prompt reply.
I have made the changes. The answer statements appear to be ignored.See Below.
on menuPick pWhich
## switch --pWhich
switch pWhich
case "New"
answer pWhich--Insert script for New menu item here
break
case "Edit"
answer pWhich--Insert script for Edit menu item here
answer pWhich
break
case "Delete"
answer pWhich--Insert script for Delete menu item here
break
case "Print"
answer pWhich--Insert script for Print menu item here
break
case "Graphs"
answer pWhich--Insert script for Graphs menu item here
break
case "Backup"
answer pWhich--Insert script for Backup menu item here
break
case "Restore"
answer pWhich--Insert script for Restore menu item here
break
case "Import"
answer pWhich--Insert script for Import menu item here
break
case "Export"
answer pWhich--Insert script for Export menu item here
break
case "Backup"
answer pWhich--Insert script for Backup menu item here
break
case "Restore"
answer pWhich--Insert script for Restore menu item here
break
case "Preferences"
answer pWhich--Insert script for Preferences menu item here
break
case "Help"
answer pWhich--Insert script for Help menu item here
break
case "Exdit Program"
answer pWhich--Insert script for Exit menu item here
quit
break
end switch
end menuPick
I must be still doing something wrong
Regards
Derek Henderson
Thanks for such a prompt reply.
I have made the changes. The answer statements appear to be ignored.See Below.
on menuPick pWhich
## switch --pWhich
switch pWhich
case "New"
answer pWhich--Insert script for New menu item here
break
case "Edit"
answer pWhich--Insert script for Edit menu item here
answer pWhich
break
case "Delete"
answer pWhich--Insert script for Delete menu item here
break
case "Print"
answer pWhich--Insert script for Print menu item here
break
case "Graphs"
answer pWhich--Insert script for Graphs menu item here
break
case "Backup"
answer pWhich--Insert script for Backup menu item here
break
case "Restore"
answer pWhich--Insert script for Restore menu item here
break
case "Import"
answer pWhich--Insert script for Import menu item here
break
case "Export"
answer pWhich--Insert script for Export menu item here
break
case "Backup"
answer pWhich--Insert script for Backup menu item here
break
case "Restore"
answer pWhich--Insert script for Restore menu item here
break
case "Preferences"
answer pWhich--Insert script for Preferences menu item here
break
case "Help"
answer pWhich--Insert script for Help menu item here
break
case "Exdit Program"
answer pWhich--Insert script for Exit menu item here
quit
break
end switch
end menuPick
I must be still doing something wrong
Regards
Derek Henderson
Re: Button Drop-menu need help with script
Hi Derek,
very strange, just made a test with your script and it works as expsected!?
To be sure, your menuitems (text of button) are in fact:
New
Edit
Delete
Print
Import
Export
etc...
are they?
Best
Klaus
very strange, just made a test with your script and it works as expsected!?
To be sure, your menuitems (text of button) are in fact:
New
Edit
Delete
Import
Export
etc...
are they?
Best
Klaus
Re: Button Drop-menu need help with script
Add a default block which answers pWhich just to see if the switch block is working.
If so, then try changing the switch tests to
case pWhich = "New"
answer "New code goes here"
break
etc etc
If so, then try changing the switch tests to
case pWhich = "New"
answer "New code goes here"
break
etc etc
Re: Button Drop-menu need help with script
if it is the exit switch that is a problem, it is a spelling error there (in the word "Exdit")
should probably be
Code: Select all
case "Exdit Program"
answer pWhich--Insert script for Exit menu item here
quit
break
end switch
end menuPick
Code: Select all
case "Exit Program"
answer pWhich--Insert script for Exit menu item here
quit
break
end switch
end menuPick
-
- Posts: 8
- Joined: Mon Sep 24, 2012 5:37 pm
Re: Button Drop-menu need help with script
Hi Klaus and hpsh
Tried the latest suggestions including the fix of error "exdit", however no luck.
Could it be that I originally copied all the code generated by the Menu Builder and thereafter manipulated the code to what I wanted.
I will clear all code and re-enter line by line.
Presumably it is not the copy from 8.01 to Community 7 causing this.
I will revert with the results.
Regards and many thanks for your help
Derek Henderson
Tried the latest suggestions including the fix of error "exdit", however no luck.
Could it be that I originally copied all the code generated by the Menu Builder and thereafter manipulated the code to what I wanted.
I will clear all code and re-enter line by line.
Presumably it is not the copy from 8.01 to Community 7 causing this.
I will revert with the results.
Regards and many thanks for your help
Derek Henderson
Re: Button Drop-menu need help with script
ok, anyway this is my code under a pulldownmeny button
also, in propertys to the pulldownmeny i have the choises in the text part
also including my code
i use livecode 8.0.1
just one thing, almost everyone here is better then me
if someone disagree with me, i am most likely wrong.
Code: Select all
on menuPick pWhich
## switch --pWhich
switch pWhich
case "New"
answer pWhich--Insert script for New menu item here
break
case "Edit"
answer pWhich--Insert script for Edit menu item here
answer pWhich
break
case "Delete"
answer pWhich--Insert script for Delete menu item here
break
case "Print"
answer pWhich--Insert script for Print menu item here
break
case "Graphs"
answer pWhich--Insert script for Graphs menu item here
break
case "Backup"
answer pWhich--Insert script for Backup menu item here
break
case "Restore"
answer pWhich--Insert script for Restore menu item here
break
case "Import"
answer pWhich--Insert script for Import menu item here
break
case "Export"
answer pWhich--Insert script for Export menu item here
break
case "Backup"
answer pWhich--Insert script for Backup menu item here
break
case "Restore"
answer pWhich--Insert script for Restore menu item here
break
case "Preferences"
answer pWhich--Insert script for Preferences menu item here
break
case "Help"
answer pWhich--Insert script for Help menu item here
break
case "Exit Program"
answer pWhich--Insert script for Exit menu item here
quit
break
end switch
end menuPick
Code: Select all
New
Edit
Delete
Print
Graphs
Backup
Restore
Import
Export
Backup
Restore
Preferences
Help
Exit Program
i use livecode 8.0.1
just one thing, almost everyone here is better then me

- Attachments
-
- pulldown.zip
- (1.01 KiB) Downloaded 235 times
Re: Button Drop-menu need help with script
And of course everything works fine in your stack here on my Mac with LC 8.01! 

Re: Button Drop-menu need help with script
well, should probably said that i also use mac. osx 10.11.5. el capitan.
think only thing i changed was removing "d" from "exdit", and put in the choices in the pulldownmeny.
but pretty easy to to overlook something, remember some pretty amazing errors i did in borland turbo c in then i was young.
if i have space to it, i can try to install linux on my mac, and try the script there, but has to wait to i am home, begin to wonder if its a windows bug.
did try to install linux in a wm, and think i just has to leave that to anyone else, seems to be always some "usefull" function that kill any hope to test it for me.
think only thing i changed was removing "d" from "exdit", and put in the choices in the pulldownmeny.
but pretty easy to to overlook something, remember some pretty amazing errors i did in borland turbo c in then i was young.
if i have space to it, i can try to install linux on my mac, and try the script there, but has to wait to i am home, begin to wonder if its a windows bug.
did try to install linux in a wm, and think i just has to leave that to anyone else, seems to be always some "usefull" function that kill any hope to test it for me.