Clearing fields
[1/2] from: didier:jacquemart:libertysurf at: 6-May-2002 21:30
Hi,
I wrote a small program to try text-list.
Goal of the program : pick up the name of a month in the list, then display the number
of days for this month.
I got an unattented problem with a variable : on the first try, the result is ok. On
the second try, the result remains unchanged, not beeing cleared from the first try.
Trying it in console mode, it works fine. I think there's a problem with VID interface.
I tried a 'clear' but it doesn't work. What is the problem ?
Following is my program source
======================
REBOL []
xmois: ["Janvier" "Février" "Mars" "Avril" "Mai" "Juin" "Juillet" "Aout" "Septembre"
"Octobre" "Novembre" "Décembre"]
xjour: [31 28 31 30 31 30 31 31 30 31 30 31]
;wmess: copy []
view layout [
tlm: text-list data xmois
button "Nombre de jours" 150
[
wmess: copy [[ "Le mois de xxx comprend yy jours"]]
;append mess [[ "Le mois de xxx comprend yy jours"]]
replace/all wmess/1/1 "xxx" tlm/picked
ii: index? find xmois tlm/picked;; is there a quicker way to get the index selected ?
replace/all wmess/1/1 "yy" (pick xjour ii)
print tlm/picked; ok
print wmess/1/1; ok on the first time
alert wmess; ok on the first time
]
]
Thanks, Didier.
[2/2] from: brett::codeconscious::com at: 7-May-2002 10:48
Hi Didier,
This will make your program work:
wmess: copy/deep [[ "Le mois de xxx comprend yy jours"]]
Alternatively, instead of using replace, you can could use rejoin.
Also, in this example the nested blocks are not needed. So your code
could change to:
REBOL []
xmois: ["Janvier" "Février" "Mars" "Avril" "Mai" "Juin" "Juillet" "Aout"
Septembre
"Octobre" "Novembre" "Décembre"]
xjour: [31 28 31 30 31 30 31 31 30 31 30 31]
view layout [
tlm: text-list data xmois
button "Nombre de jours" 150
[
ii: index? find xmois tlm/picked
wmess: rejoin [
"Le mois de " tlm/picked
"comprend " pick xjour ii "jours"
]
alert wmess
]
]
Hope it helps,
Brett