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

[REBOL] 'dispatch ?? (was redirecting from http to ftp)

From: ryan:christiansen:intellisol at: 29-Jun-2001 11:46

I looked over all of the port-related functions in the dictionary and tried several of them to see if I could get REBOL to return an error on that URL, but it does not. I did find the function 'dispatch, however. My understanding is 'dispatch waits for activity from a port. Perhaps I could use 'dispatch and somehow just let ports which run amok continue until the script finishes? Can someone give me an example of using dispatch? Is there a way to place each 'open argument in "queue" and use dispatch to wait for a result? Again, here is the code I am using to read URL redirection: port: open full-url ; where full-url is created by previous code redirect-url: make url! probe port/url -Ryan [ryan--christiansen--inte] To: [rebol-list--rebol--com] Sent by: cc: [rebol-bounce--rebol--com] Subject: [REBOL] Re: R: Re: redirecting from http to ftp 06/29/2001 11:04 AM Please respond to rebol-list Hmm... I tried this function, but it doesn't seem to behave any differently than using 'open. -Ryan
> OK. So how can I fix it? I want the script to at least error out instead
> keep trying over and over again. Using an if error? try statement doesn't > help.
I'm new with rebol, but to learn i have written this script. ------------------------------------------------------------------------------ REBOL[ Title: "Redirecting HTTP to FTP" Author: "Romano Paolo Tenca" Version: 1.0.0 Date: 29/06/01 Purpose: { Try a http url if fail for error 800 (redirect to a ftp site) return a custom object (redir) with info for the ftp Perhaps worked better if it was an object with a public routine embedded but it is my first Rebol routine } History: [ "It doesn't check ftp error" 29/06/01 ] ] HttpRedir?: function [url [url!]] [rule err porterr redir-str] [ rule:[to "http://" to "ftp://" copy redir-str to " could" "could" "not" be retrieved. "Circular" "forwarding" "detected" to end] redir: make object! [ net: "http" ;type of connection success: true ;false for failure urlpath: url ;url (http or ftp) urlob: decode-url url ;standard object! purl err: ;standard object! error type: none ;type of fftp url ("file" | "dir") ] if error? porterr: try [info? url][ err: disarm porterr redir/success: false redir/err: err if err/code = 800 [ redir-str: copy "" parse err/arg1 rule if redir-str <> "" [ redir/success: true redir/net: "ftp" redir/urlpath: to-url redir-str redir/urlob: decode-url redir-str either dir? redir/urlpath [ ;is a dir redir/type: "dir" ][ ;is a file redir/type: "file" ] ] ] ] return redir ] r: HttpRedir? either r/success = true [ print ["You can open" r/net r/urlpath "(ftp type" r/type ")"] ][ print ["Error on open http" r/err/code ] ]