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

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

From: swhite:ci:bloomington:mn:us at: 14-Mar-2006 7:44

I am writing a very simple script to transfer a file when a button is clicked on a screen. It works fine. The procedure to send the file is basically this (the SOURCE-FILE is an ftp url, the DESTINATION-FILE is a local file name): TRANSFER-FILE: does [ write/binary DESTINATION-FILE read/binary SOURCE-FILE alert "File has been transferred" ] Now I want to add an error check in case the file does not exist, the directory structure is changed, or something like that, so the script doesn't just stop. I am trying to approach it a step at a time so I know what I am doing. I read the dictionary entries for try and disarm and thought I could do the following as my first step toward thorough error detection: TRANSFER-FILE: does [ FTP-RESULT: try [ write/binary DESTINATION-FILE read/binary SOURCE-FILE ] alert "File has been transferred" ] ...and then, after the write-read operation, I would check if FTP-RESULT was an error value, and if so, disarm it and check its various parts. But when I run the script as above (with the "try"), I get the error: FTP-RESULT needs a value Could someone explain, in simple terms, this try-disarm business, or tell me the appropriate way to do what I am trying to do, which is to catch an error in my file transfer process so the script doesn't just crash? Thank you. Steven White City of Bloomington 1800 W Old Shakopee Rd Bloomington MN 55431-3096 USA 952-563-4882 (voice) 952-563-4672 (fax) steven.white-ci.bloomington.mn.us