Rebol - How can I append text from a text field to a text list?

93 Views Asked by At

I've been exploring the amazing Rebol programming tool. I've run into a problem of trying to append text from a text field into the data of a text-list. My code below adds text to the text-list but changes all previous text to the current one multiplied by how many data entries were already in the text list.

How can I correct this?

REBOL [
    Title: "test4"
    Version: 1.3.3
    Author: "me"
    Purpose: {create a list of countries}
]

populate: does[
    country: countryField/text
    append txtList/data country
    show lay
]

lay: layout [
    across
    text "Enter name of country" black bold
    countryField: field
    return
    across
    txtList: text-list 
    panel [
        button "Add" [populate]
        button "Delete" [remove back tail txtList/data show lay]
        button "Clear" [clear txtList/data show lay]
    ]
]

view lay
1

There are 1 best solutions below

2
endo64 On BEST ANSWER

You just need to copy the text:

country: copy countryField/text

For short, without copying a series (a string in this case) you just append the same one multiple times, it is all the same string. When you change it you just change one string but you see it as multiple changes.

Here you can read the detailed explanation:

https://github.com/red/red/wiki/%5BDOC%5D-Why-you-have-to-copy-series-values