[REBOL] Re: Don't understand "try" and "disarm"
From: swhite:ci:bloomington:mn:us at: 14-Mar-2006 9:58
Well, I am slowly beginning to understand my own question. The
previously-submitted test script left out the obvious fourth option of
trying to read a file that does NOT exist and then writing it. That
operation "works" also, as in reporting the error of the file not
existing. (The revised script is at the end of the message.)
Of the four options, the script crashes when it tries to read a file
that DOES exist and write it to another file. It crashes only when it
According to the REBOL dictionary, "try" returns either an error or THE
RESULT OF THE BLOCK. So, if I comment-out things so the script tries to
read a file that does not exist, FTP-RESULT is an error. If I
comment-out things so the script just reads a file that does exist,
FTP-RESULT is a a string. A string is the result of reading a text
The script crashes when it tries to write a file. What is the "result"
of a block that writes a file? That, perhaps, is what I don't
My actual mission is to write a script that transfers a file from one
computer to another by FTP, and not crash if the file is not there, or
if the transfer fails in some way. Maybe I am trying to do this the
Thank you for any advice.
;;;; revised test script
TRANSFER-FILE: does [
either error? FTP-RESULT: try [
;;;; read %nonexistent.txt ;;;;; this file does NOT exist
;;;; read %fileexists.txt ;;;;; This file DOES exist
;;;; write %tempfile.txt read %nonexistent.txt
write %tempfile.txt read %fileexists.txt ;;;; this crashed
;;;;;; -- There was some error
FTP-ERROR-OBJECT: disarm FTP-RESULT
FTP-ERROR-MESSAGE: rejoin [
"The file was not transferred."
" The REBOL interpreter returned the following message: "
;;;;;; -- There was no error
alert "The file was read successfully"
view layout [
title "Test the script"
button "GO" [TRANSFER-FILE]
;;;; end of test script
City of Bloomington
1800 W Old Shakopee Rd
Bloomington MN 55431-3096