VERY Basic question

Discussion in 'Rebol' started by elwis, May 9, 2010.

  1. elwis

    elwis New Member

    So, I'm playing around with REBOL which.. by the way doesn't look like anything I ever touched before. That makes it even more interesting :)

    However, her's one thing I don't really get, maybe because it's sunday and Ive been coding all day but please give me a hint ;)

    If I fill in something in f1 and push the button it updates f2. If I change the value of f2 it doesnt overwrite it with the value from f1 again, it updates the value in f1 with the text from f2. And.. I can't see where in my code I read from f2 and set the value to f1?

    Code:
    view layout [
    	f1: field
    	btn "My value" [
    		t: f1/text
    		f2/text: t
    		show f2
    		show f1
    		
    	]
    	f2: field
    ]
  2. Graham

    Graham Developer Staff Member

    The issue is that since you wrote f2/text: t: f1/text, then they all refer to the same string.

    If you want separate strings you need to copy ...

    f2/text: copy f1/text
  3. elwis

    elwis New Member

    Thanks, interesting and important information. REBOL is not at all like Java ;)
  4. Graham

    Graham Developer Staff Member

    Correct. Functional and procedural languages are very different. You might want to read the manual :)
  5. elwis

    elwis New Member

  6. endo

    endo New Member

    This issue is for all series! types like blocks, strings etc.

    Code:
    o: context [t: [a]]
    b: o/t ;b points to o/t but just for series operations!
    append b 'b  ;append, insert, change, remove etc.
    probe o
    make object! [
        t: [a b]
    ]
    b: [x]  ;this doesn't change the value of o/t, b is now another variable.
    probe o
    make object! [
        t: [a b]
    ]
    
    Just for your information.

Share This Page