Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: is there a better way?

From: ingo:2b1 at: 5-May-2001 22:02

Hi Rishi, Once upon a time Rishi Oswal spoketh thus:
> wondering if there is a better way to do the following > lines of code (rather than using so many if > statements) > > menu-choice: choice 150 "Menu1" "Menu2" "Menu3" [ > if ((first value) = "Menu1") > [menu-panel/pane: menu1 show menu-panel] > if ((first value) = "Menu2") > [menu-panel/pane: menu2 show menu-panel] > if ((first value) = "Menu3") > [menu-panel/pane: menu3 show menu-panel] > ]
You could use switch instead: switch first value [ "Menu1" [menu-panel/pane: menu1 show menu-panel] "Menu2" [menu-panel/pane: menu2 show menu-panel] "Menu3" [menu-panel/pane: menu3 show menu-panel] ]
> menu-choice 150 "Menu1" "Menu2" "Menu3" [ > [menu-panel/pane: to-word first value > show menu-panel] > ]
The problem is, you set the pane _to the word_ menuX, but really want to set it to the value this word is pointing to: menu-choice 150 "Menu1" "Menu2" "Menu3" [ [menu-panel/pane: get to-word first value ; === get the value show menu-panel] ] I'm not sure, but maybe the following works, too: menu-choice 150 "Menu1" "Menu2" "Menu3" [ [menu-panel/pane: to-get-word first value ; =========== get the value show menu-panel] ] I hope that helps, Ingo