[REBOL] DOing a script from REBOL.org
From: SunandaDH:aol at: 31-Oct-2006 5:30
Hidden in the Library Recent Changes thread, Carl Read asked:
> Shouldn't this just, you know, work...
> do
http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=texture-lab.r
Gregg suggested using the "plain text" version of the script in the Library:
> do
http://www.rebol.org/cgi-bin/cgiwrap/rebol/download-a-script.r?script-name=texture-lab.r
And Anton diagnosed REBOL's inability to parse the script from the webpage as
a documentation and/or coding problem in REBOL -- an embedded script needs to
start with a newline.
http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-message.r?m=rmlWTJC
The Library now emits the HTML with a newline before the script header.
This means that many scripts are DO-able from their Library webpage.
Thanks to Carl and Gregg and Anton for raising and fixing the problem.
****
Unfortunately, _many_ scripts are Do-able, but not the one in question.
texture-lab.r contains greater-than and less-than signs. These are escaped to
character entities in the HTML page, and that creates a syntax error.
Gregg's solution still stands: use the version intended for execution rather
than the one prettied up for display.
Other alternatives include:
-- download the script and run it locally.
-- download the whole Library, and run the one script locally:
http://www.rebol.org/cgi-bin/cgiwrap/rebol/download-librarian.r
Those first two suggestions work even when the library isn't available.
-- Use the Library Data Services interface. Normally (see below for exception
**) this best as it allows you to specify which version of a script you want
to run -- the Library may have multiple versions of a script, and the most
recent one may not be the one you want.
do
http://www.rebol.org/library/public/lds-local.r
res: lds/send-server 'get-archive-version ["texture-lab.r/1"]
do decompress res/data/script
Normally, this would run Version 1 of texture-lab.r
If there were other verisons, you could check them here:
http://www.rebol.org/cgi-bin/cgiwrap/rebol/script-history.r?script-name=textur
e-lab.r
And that would work with most scripts in the Library.
** Sadly, texture-lab.r is an exception: it checks its own REBOL header. That
means it is assuming it is running as a Do %name. So it fails as it can't
find header/version.
You could always save it to a temporary file and do it from there.
****
Who said the X-Internet was easy!?
Moral of the story: listen to Gregg.
Sunanda.