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

[REBOL] Re: error? try load bad-path

From: carl:cybercraft at: 12-Mar-2004 6:02

On 12-Mar-04, [bry--itnisk--com] wrote:
> I have a situation where I'm converting a > string to a path and loading it, in some > situations this string can be a bad path, I > want to catch that, so I put in this > patherr: error? try[load pass] > either patherr = true[ > > ] [ > passlevel: load pass > passlevel: to-integer passlevel > > ] > unfortunately in the cases where I pass a > bad path I get the following: > ** Script Error: Invalid path value: skjjsjnf > ** Where: do-boot > ** Near: passlevel: to-integer passlevel
The error is with the to-integer and not load, so load seems to be loading your bad path ok. What are the paths to? If to files and pass is a string, then load will quite happily load the string. Changing [load pass] to [load to-file pass] will generate an error if it's not a file. load, (roughly speaking), converts a file or string to REBOL format. Hence the following loads quite happily and generates a block...
>> test: load "aa %bb cc"
== [aa %bb cc ]
>> type? test/1
== word!
>> type? test/2
== file! Hope this helps, but if it's not a file you're trying to load then it probably won't... -- Carl Read