On 10/9/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wro= te: > > Hi List, > > As I was testing my parse function, I have found an annoying problem > with to-block! is this a bug ? how to workaround it ? > > My function use teh following line > > remove-each w bs [not parse to-block w [url!]] > > And it comes that to-block do not like parens. See > > >> to-block "(right" > ** Syntax Error: Missing ) at end-of-script > ** Near: (line 1) (right > > So there is some kind of evaluation > here. On the other hand, this is ok. > > >> to-block "(right)" > =3D=3D [(right)] > > This is really bothering me, when Rebol is not fun at all :(
Remember to-block needs valid rebol-code, else it is helpless. Catch the error. !> attempt[to-block "(bang"] =3D=3D none !> attempt[to-block "bang"] =3D=3D [bang] !> if u: attempt[to-block "(bang"] [url? first u] =3D=3D none !> if u: attempt[to-block "http://yep"] [url? u/1] =3D=3D true !> attempt[load "http://yep"] =3D=3D http://yep !> url? attempt[load "http://yep"] =3D=3D true Some other versions to do it: setup: does[ s: {Go see http://www.me.org, it is fabulous. And http://aaa.mypicture.com with my photos. ftp://aaa.mypicture.com too} emit: func[val][repend "" val] ] setup ; Simplest in this case: while[ p: find s "http://" ][ emit copy/part s p set[url s] load/next p emit [build-tag [a href (url)] url </a>] ] emit s print emit "" ; Pure parse, but which chars allowed? setup url-chars: charset [#"a" - #"z" #"0" - #"9" "/.:"] ; which chars? parse/all s[ some[ s: to http:// p: copy url any url-chars ( emit copy/part s p emit [build-tag [a href (url)] url </a>] ) ] (emit s) ] print emit "" ; Using load/next in parse is coomplex, but still: setup parse/all s [ some[ s: to http:// p: ( emit copy/part s p set[url p] load/next p emit [build-tag [a href (url)] url </a>] ) :p ] (emit s) ] print emit "" ; With a kind of multiple 'to, different fonts for http/ftp, for demonstrat= ion : setup url-chars: charset [#"a" - #"z" #"0" - #"9" "/.:"] ; which chars? parse/all s[ some[ s: "http://" any url-chars p: ( url: copy/part s p emit [build-tag [a href (url)] <b> url </b> </a>] ) | s: "ftp://" any url-chars p: ( url: copy/part s p emit [build-tag [a href (url)] <i> url </i> </a>] ) | s: skip (emit s/1) ] ] print emit "" > > Ideas and workaround appreciated. > > -- > Ciao > Patrick > > -- > To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject. > > -- -Volker "Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem." David Wheeler -- To unsubscribe from the list, just send an email to lists at rebol.com with unsubscribe as the subject.
