Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Don't understand "try" and "disarm"

From: swhite::ci::bloomington::mn::us at: 14-Mar-2006 10:46

Thank you. It did not register in my old-fashioned brain that one could do an existence check across the network. I tossed out all the "try" stuff and just checked to see if the source file and the target directory existed before I allowed any file transfer. This "set-word" concept is a bit confusing, but I am going to wait with my criticism of the REBOL documentation until I have re-read it, plus the two books I have purchased. Then I'll complain.
>>> greggirwin-mindspring.com 3/14/2006 10:12 AM >>>
Hi Steven, 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 SW> ] 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 ] HTH! -- Gregg