Newbie with view & vid
[1/3] from: alberto::upn::mx at: 19-Feb-2003 15:30
Hi, all
This is my first post to the REBOL list, I'm new with VIEW and VID,
I had little issues while playing with "choice" object: I want to associate
a word with /text property of a choice object
but did not work, however an association works fine with field object.
I did this:
======
pnl: layout [
fld: field [print message] ; this works, value of 'message change with
fld/txt
chs: choice "one" "two" "three" [print number] ; value of 'number
don't change, why?
]
message: fld/text
number: chs/text
view pnl
======
typing something in the field changes 'message's value, but choosing an
item from chioce have no
effect on 'number.
I thing I'm associating 'number with the wrong property (/text).
somebody knows is possible to associate a word with the picked item of a
choice object?
Thanks,
alberto
[2/3] from: sunandadh:aol at: 19-Feb-2003 17:38
Alberto:
> pnl: layout [
> fld: field [print message] ; this works, value of 'message change
with
> fld/txt
> chs: choice "one" "two" "three" [print number] ; value of 'number
<<quoted lines omitted: 3>>
> number: chs/text
> view pnl
Welcome to Rebol and View!!
There are inconsistencies between the various styles and their available
fields. It is confusing at first.
Try
number: chs/data ;; dat holds the text of the selected item
You can also write:
chs: choice "one" "two" "three" [print value]
Value has a local meaning inside the choice action factet: it means the value
of the item selected.
Also of use is:
number: chs/texts ;; a block of the (three) choice texts.
And do this to take a look around the other internal fields.
first chs ;; see all the available fields
chs/text ;; etc -- explore what's in each field.
Happy Rebolin'
Sunanda
[3/3] from: greggirwin:mindspring at: 19-Feb-2003 16:15
Hi Alberto,
AC> This is my first post to the REBOL list, I'm new with VIEW and VID,
Welcome to the REBOLution!
AC> I had little issues while playing with "choice" object: I want to associate
AC> a word with /text property of a choice object
AC> but did not work, however an association works fine with field object.
The issue behind this causes confusion to lots of people just starting
out with REBOL, particularly if they have experience with other
langugages. The catch is that REBOL words reference *values*. Look at
this console transcript:
>> a: "Gregg"
== "Gregg"
>> b: :a
== "Gregg"
>> a: "Alberto"
== "Alberto"
>> b
== "Gregg"
You see, when B is first set, you might think it's referencing A, but
it's not; it's referencing "Gregg". Now, you tell A to reference
something another string ("Alberto") but B has no idea you've done
that because never really knew that the word A even existed.
So, why does it work for field? Because you're *altering* the value
that is being referenced.
>> a: "Gregg"
== "Gregg"
>> b: :a
== "Gregg"
>> append a " Irwin"
== "Gregg Irwin"
>> b
== "Gregg Irwin"
Now, if you don't want to share a reference to a mutable value, you
can use COPY.
>> a: "Gregg"
== "Gregg"
>> b: copy :a
== "Gregg"
>> append a " Irwin"
== "Gregg Irwin"
>> b
== "Gregg"
AC> somebody knows is possible to associate a word with the picked item of a
AC> choice object?
You could either set the value each time it changes, or look it up
dynamically. Since I'm not sure exactly what you're trying to achieve
with the indirection, I'm not sure what else to suggest.
pnl: layout [
fld: field [print message]
chs: choice "one" "two" "three" [number: face/text print number]
ch2: choice "one" "two" "three" [print get-number]
]
message: fld/text
number: chs/text
get-number: does [ch2/text]
view pnl
-- Gregg
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted