[REBOL] Stopping a function before it is finished.
From: reboler::programmer::net at: 29-Oct-2002 8:50
I have a script which shows the contents of files, and performs some _lengthy_ processing
of their contents.
I have simulated the essentials in a script given below.
Suppose that during processing, I notice that I have entered the wrong password, and
now I want to stop processing the file immediately, instead of waiting til it is done.
(for instance, by clicking on a new file in the text-list)
How would you REBOL gurus go about this?
Seems to me I should add a 'wait somewhere, but where?
The 'process-file function?
Or the button '/action? (this is my preference, since I have many processing functions!)
Elsewhere ???
I've tried a few things but nothing seems to work.
;*** begin script
view layout [
;some setup
do [
files: read %./
process-file: func [
file-contents
][
;some lengthy processing simulated here
file-contents: enbase/base compress form view-area/text 64
loop 500 [
for n 1 length? password/text 1 [
new-char: (xor to-char pick password/text :n to-char pick file-contents :n)
poke file-contents n new-char
]
file-contents: compress form enbase/base file-contents 64
]
]
]
text-list data files [
view-area/text: read to-file value
show view-area
]
button "Process File" [
view-area/text: process-file view-area/text
show view-area
]
return
text "password"
password: field "password"
view-area: area 320x240
];end layout
;*** end script