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

[REBOL] Re: Newbie with view & vid

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