I have finished up a day of head-beating and discovered something strange. I have gotten my program to work, so all is well there, but I would like to understand what is going on here. It seems that if I have a program that gets data from a window and appends it to a block in the program, that block gets altered the next time I type stuff in the window even if I don't explicitly append it to the block. A sample program follows that shows this happening. I am wondering if anyone can explain it. Thank you.
R E B O L [
Title: 'Append test'
]
;; -- We want to get data from a window and append it to this block.
SOME-OTHER-BLOCK: []
;; -- This function appends the field from the screen to the block.
APPEND-BUTTON: does [
append SOME-OTHER-BLOCK trim get-face MAIN-FIELD1
alert 'OK'
]
;; -- The DEBUG button shows the value of SOME-OTHER-BLOCK
;; -- so you can check it before using the APPEND button.
DEBUG-BUTTON: does [
print ['Value of SOME-OTHER BLOCK is: ' SOME-OTHER-BLOCK]
]
;; -- Main window.
MAIN-WINDOW: layout [
across
label 'Field 1:'
MAIN-FIELD1: field 100
return
button 'APPEND' [APPEND-BUTTON]
button 'DEBUG' [DEBUG-BUTTON]
return
text 400 '1. Enter something in the field and press APPEND'
return
text 400 '2. Press DEBUG to see that it has been appended'
return
text 400 '3. Enter something different and DO NOT press APPEND'
return
text 400 '4. Press DEBUG and see that SOME-OTHER-BLOCK has changed'
return
text 400 '5. Press APPEND and DEBUG again to see that append works.'
]
view center-face MAIN-WINDOW