Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: choice > options
Pages: [1] Print
Author Topic: choice > options  (Read 251 times)
leke
Jr. Member
**
Offline Offline

Posts: 92


View Profile WWW
choice > options
« on: July 21, 2008, 01:46:42 PM »

I made this for linux, but it always evaluates the first block. How do I make each choice evaluate its own block?
Code:
view layout [ size 700x350
choice "Interet Apps" [alert "Not an option"]
"Firefox" [call "firefox"]
"Trasmission" [call "transmission-gtk"]
"Miro" [call "miro"]
"5" [call ""]
]
Thanks.
Logged

Sunanda
Full Member
***
Offline Offline

Posts: 109


View Profile
Re: choice > options
« Reply #1 on: July 21, 2008, 02:57:01 PM »

You may have mis-interpreted the format of a choice.

It is a set of display strings and a _single_ action block. The action block can check which display option is currently selected. 

Try this to see:
Code:
view layout [ size 700x350
my-choice: choice
    "Interet Apps"
    "Firefox"
    "Trasmission"
    "Miro"
    "5"
[print my-choice/text]
]
Logged
leke
Jr. Member
**
Offline Offline

Posts: 92


View Profile WWW
Re: choice > options
« Reply #2 on: July 22, 2008, 01:50:00 AM »

thanks,
I found this also: http://en.wikibooks.org/wiki/REBOL_Programming/Language_Features/VID#Choice
which helped me code the rest of the app.
Could you maybe explain a little about the refinements /data/1 ?

Code:
rebol[]
view layout [ size 700x350

my-choice: choice "Interet Apps" "Firefox" "Trasmission" "Miro"
[
switch my-choice/data/1
[
"Interet Apps" [alert "Not an option."]
"Firefox" [call "firefox"]
"Trasmission" [call "transmission-gtk"]
"Miro" [call "miro"]
]
]
]
Logged

Sunanda
Full Member
***
Offline Offline

Posts: 109


View Profile
Re: choice > options
« Reply #3 on: July 22, 2008, 08:24:40 AM »

Glad you've got your code working :-)

Not sure I can explain about data/1. But here goes:

VIEW stores text information in various places. They include /text (which, with 'choice, is I think the current displayed/selected option) and /data which may be a block of all possible options.

The usage of /text and  /data has changed between versions of VIEW and it has been inconsistent between different controls. So I cannot give you a definite answer. Use 'probe and experiment to see what works on your version.
Logged
leke
Jr. Member
**
Offline Offline

Posts: 92


View Profile WWW
Re: choice > options
« Reply #4 on: July 22, 2008, 09:07:37 AM »

thanks - that was great!  Grin
Logged

Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: choice > options
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 21, 2008, 12:03:31 AM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2287 Posts in 593 Topics by 3732 Members
Latest Member: Hentai40

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc