[REBOL] Unwanted Duplicate Data in Text Fields
From: tserpa::earthlink::net at: 7-Nov-2003 11:38
In the code below, after I click "Load", if I immediately enter text in the
3rd text field, and then click "Forward" the text is not inserted into 'db.
However, if I click "Load", then immediately click "Forward" any number of
times, and then enter text into the 3rd or 4th text fields, the 3rd and 4th
fields of all records will immediately be set to the value entered. What is
happening?
The intended operation is to enter text into a field and have that value
saved in that field for that specific record.
%test.txt is just a csv file of the following format:
Joe,Red
Jim,Blue
John,Green
Jack,Black
REBOL []
view center-face layout [
f1: field 150x24
f2: field 150x24
f3: field 150x24 [probe db]
f4: field 150x24
button "Load" 150x24 [
data-in: read/lines %test.txt
db: copy []
record: copy []
foreach line data-in [
record: parse/all line ","
loop 2 [append record ""]
append/only db record
]
f1/text: db/1/1
f2/text: db/1/2
show [f1 f2]
]
across
button "Back" 71x24 [
db: back db
f1/text: db/1/1
f2/text: db/1/2
f3/text: db/1/3
f4/text: db/1/4
show [f1 f2 f3 f4]
]
button "Forward" 71x24 [
db-lgth: length? head db
db-idx: index? db
if db-idx < db-lgth [db: next db]
f1/text: db/1/1
f2/text: db/1/2
f3/text: db/1/3
f4/text: db/1/4
show [f1 f2 f3 f4]
]
]