write does not return a value upon success. This is bad for try blocks
[1/6] from: princepawn::lycos::com at: 7-Sep-2000 9:16
I am writing a script that will try 3 times to write a file and then fail, however, I
cant place a try block around the REBOL write statement because it does not return anything
upon success, thus I get an error that the word is not bound:
>> m: try [ write ftp://chuck:[chuck1--170--16--15--136]/crossing/ndtd/user.r "hi there" ]
connecting to: 170.16.15.136
** User Error: Server error: tcp 530 Login incorrect..
** Where: write ftp://chuck:[chuck1--170--16--15--136]/crossing/ndtd/user.r "hi there"
; -- great: when write fails 'm is bound
>> m: try [ write ftp://chuck:[chuck--1--170--16--15--136]/crossing/ndtd/user.r "hi there" ]
connecting to: 170.16.15.136
** Script Error: m needs a value.
** Where: m: try [write ftp://chuck:[chuck--1--170--16--15--136]/crossing/ndtd/user.r "hi there"]
; --- well this sucks. I cant get a return value upon success
[2/6] from: ryanc:iesco-dms at: 7-Sep-2000 9:57
This method works well...
>> m: error? try [ write %test "test" ]
== false
>> m: error? try [ write test "test" ]
== true
This will elleviate the problem with nothing being returned from write...
>> m: try [ write %test "test" none]
== none
But you will still have to capture the error...
>> m: try [ write test "test" none]
** Script Error: test has no value.
** Where: write test "test" none
I just know how to bottle it up and spit it out later...
>> if error? m: try [ write test "test" none] [ print "error detected!" m ]
error detected!
** Script Error: test has no value.
** Where: write test "test" none
Maybe someone knows how to peel an error! apart?
--Ryan
Life... Dont talk to me about life.
-A robot named Marvin
[princepawn--lycos--com] wrote:
[3/6] from: johnkenyon:ibm at: 7-Sep-2000 10:08
Okay - last one,
m: error? try [ write ftp://chuck:[chuck1--170--16--15--136]/crossing/ndtd/user.r
hi there
]
Does that help?
cheers, john
I am writing a script that will try 3 times to write a file and then fail,
however, I cant place a try block around the REBOL write statement because
it does not return anything upon success, thus I get an error that the word
is not bound:
>> m: try [ write ftp://chuck:[chuck1--170--16--15--136]/crossing/ndtd/user.r "hi
there" ]
connecting to: 170.16.15.136
** User Error: Server error: tcp 530 Login incorrect..
** Where: write ftp://chuck:[chuck1--170--16--15--136]/crossing/ndtd/user.r "hi
there"
; -- great: when write fails 'm is bound
>> m: try [ write ftp://chuck:[chuck--1--170--16--15--136]/crossing/ndtd/user.r
hi there
]
connecting to: 170.16.15.136
** Script Error: m needs a value.
** Where: m: try [write
ftp://chuck:[chuck--1--170--16--15--136]/crossing/ndtd/user.r "hi there"]
; --- well this sucks. I cant get a return value upon success
[4/6] from: bo:rebol at: 7-Sep-2000 10:17
Try using printerror.r from www.rebol.org in the Script Library section.
You can send a disarmed error object to printerror and it will display
the error as REBOL would, but without exiting the application.
-Bo
On 7-Sep-2000/9:57:35-7:00, [ryanc--iesco-dms--com] wrote:
>This method works well...
>>> m: error? try [ write %test "test" ]
<<quoted lines omitted: 32>>
>> Get your FREE Email and Voicemail at Lycos Communications at
>> http://comm.lycos.com
--
Bohdan "Bo" Lechnowsky
REBOL Adventure Guide
REBOL Technologies 707-467-8000 (http://www.rebol.com)
Download the REBOL Messaging Language
The Official Source for REBOL Books (http://www.REBOLpress.com)
[5/6] from: lmecir:geocities at: 7-Sep-2000 19:19
Hi,
try this:
tries: 3
until [
set/any 'm try [write
ftp://chuck:[chuck1--170--16--15--136]/crossing/ndtd/user.r "hi there"]
tries: tries - 1
any [tries = 0 unset? get/any 'm]
]
Regards
Ladislav
> I am writing a script that will try 3 times to write a file and then fail,
however, I cant place a try block around the REBOL write statement because
it does not return anything upon success, thus I get an error that the word
is not bound:
> >> m: try [ write ftp://chuck:[chuck1--170--16--15--136]/crossing/ndtd/user.r
hi there
]
> connecting to: 170.16.15.136
> ** User Error: Server error: tcp 530 Login incorrect..
> ** Where: write ftp://chuck:[chuck1--170--16--15--136]/crossing/ndtd/user.r "hi
there"
> ; -- great: when write fails 'm is bound
> >> m: try [ write ftp://chuck:[chuck--1--170--16--15--136]/crossing/ndtd/user.r
hi there
]
[6/6] from: joel:neely:fedex at: 7-Sep-2000 11:47
You could "try" (groan ;-) something along the lines of
m: not error? try [write ftp:... "hi there"]
which leaves m simply indicating success (or failure) of the
attempted block.
-jn-
[princepawn--lycos--com] wrote:
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted