Selecting Menu Item in Option Menu

Peter Brigham MD pmbrig at gmail.com
Wed Jan 28 18:37:24 EST 2009


On Jan 28, 2009, Ken Ray <kray at sonsothunder.com> wrote:

...snip...

> Personally, I'd love to be able to have syntax like:
>
>  set the menuChoice of <buttonObj> to <menuItemString>
>
> that would act like "set the menuHistory", but take the name of the  
> menu
> item as an argument, and NOT trigger menuPick. Then return in "the  
> result" a
> non-empty value if for some reason the menu item you named doesn't  
> exist.
> Like:
>
> set the menuChoice of btn 1 to "Choice 2"
> if the result is not empty then
>  -- "Choice 2" doesn't exist and I can do something about it
> end if
>
> (sigh)
>
> :-)
>
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/

What's wrong with putting this in a suitable library, to extend the  
language:

setprop menuChoice what
    lock messages
    set the wholematches to true -- optional, if you want
    -- to require the syntax to specify the full menuItem name
    put lineOffset(what,the text of the target) into tNum
    if tNum = 0 then
       return "menuItem not found"
    else
       set the menuHistory of the target to tNum
    end if
    unlock messages
end menuChoice

Then you can use your preferred syntax, no?

Peter M. Brigham
pmbrig at gmail.com




More information about the use-livecode mailing list