[REBOL] Re: Don't understand "try" and "disarm"
From: greggirwin:mindspring at: 14-Mar-2006 9:12
This is pretty easy, once you know the trick. First, though, I'll ask
if you've looked into using EXISTS? ?
SW> TRANSFER-FILE: does [
SW> either error? FTP-RESULT: try [
SW> ;;;; read %nonexistent.txt ;;;;; this file does NOT exist
SW> ;;;; read %fileexists.txt ;;;;; This file DOES exist
SW> write %tempfile.txt read %fileexists.txt
TRY returns the result of the block evaluation; in this case, the
result of WRITE. Fire up a console and see what WRITE returns. Now,
try assigning that value using a set-word!, like the above code.
What's happening is that WRITE returns an unset! value, which doesn't
work directly with set-word! syntax. You need to use SET/ANY. e.g.:
either error? set/any 'FTP-RESULT try [
write %tempfile.txt read %fileexists.txt