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

eRebol on Win32

 [1/3] from: john::schuhr::com at: 3-Jun-2001 13:13

In playing with the eRebol (rebol server pages) script by Maarten Koopmans, I had a few problems with it "out of the box" in running it on Apache/Win32. I thought I'd share my patches/hacks with anyone else who might consider playing with it as well. The documentation says to add the following to the httpd.conf file: AddAction erebol /cgi-bin/erebol_sample.r AddHandler erebol rhtml When in actuality, I had to alter it into: Action erebol /cgi-bin/erebol_sample.r AddHandler erebol .rhtml Notice the modified "Action" directive and the added "." to the AddHandler directive. Now, in the erebol_sample.r script which contains the function and the call to the function, Apache/Win32 didn't like the path name for the file it was processing. Apparently, just using 'to-file on Win32 returns C:\blah\blah.r which is an invalid filename in Rebol. So I had to modify the last line in the erebol_sample.r to read: erebol to-file replace system/options/cgi/path-translated "c:\" "/c/" So that it always had a "/c/blah\blah.r" filepath to work with. Additionally, I had to add the following lines before the line above: print "Content-Type: text/html" print "" print "" Otherwise, I got an Internal Server Error 500. Bleah. I've included the whole of the modified script, just for convenience. **SNIP** #!C:/rebol/rebol.exe -cs REBOL [ Title: "rebol Server pages" Date: 18-May-2001/9:18:36+2:00 Version: 1.0.0 File: %erebol.r Author: "Maarten Koopmans" Purpose: "Execute embedded rebol code, see" Email: [m--koopmans2--chello--nl] Category: [cgi markup text] ] print "Content-Type: text/html" print "" print "" erebol: func [ {Preprocesses a text file and evaluates al rebol code between <% and %> tags. Everything that is printed is visible in the output. <%# and %> comments code out (useful for debugging).} content [file! string!] /local text ] [ execs: false page-end: copy {} either file? content [ text: read content ] [ text: copy content ] ; two rules for parsing ; first the comment rule ; removes any comment between <%# and %>, useful for debugging comment-rule: [ copy pre to "<%#" cs: thru "%>" ce: (remove/part cs ((index? ce) - (index? cs)))] ; next, we copy anything that is between <% and %> and try to execute that ; we save the remainder of the page in page-end blok: [ do code ] bind blok 'do exec-rule: [ copy pre to "<%" thru "<%" copy code thru "%>" page-end: (execs: true prin pre error? try blok) ] bind exec-rule 'do ; now remove the comments parse text [ any comment-rule ] ; execute the commands parse text [any exec-rule] ;and... print the end of the page that doesn't contain any code either execs [ print page-end ] [ print text ] ] erebol to-file replace system/options/cgi/path-translated "c:\" "/c/" **END-SNIP**

 [2/3] from: m:koopmans2:chello:nl at: 4-Jun-2001 13:11

John, I'll update the docs. I'm sorry I have been sloppy about it. I tested it only quickly on FreeBSD in Apache mode. The print "" can be replaced by print newline (twice). The content-type isn't set (deliberately) because who says you are serving html (could be xml, ...) --Maarten

 [3/3] from: john:schuhr at: 4-Jun-2001 8:44

No problem Marteen.. :) I just thought I'd play with it on Win32 and see what I could do with it. It works great, for the most part, but I'm still trying to work out scope within an rhtml page. Like the following: **SNIP** <html><body> <!--- Create a variable and print it's contents. Works great. ---> Step 1 <br> <rebscript> a: 1 print ["The number is: " a "<br>"] </rebscript> <!--- You'll notice that 'a does not exist anymore ---> <!--- At least not in this context ---> Step 2 <br> <rebscript> print ["The number was: " a "<br>"] a: 2 print ["The number is now: " a "<br>"] </rebscript> </body></html> **/SNIP** You'll notice that I modified your script to use <rebscript> open and close tags. Just a matter of preference :) I'm a longtime ColdFusion programmer, and it works for me. I've also added a few other constructs, just for convenience, like the following: <html><body> <!--- performs code inside the tag specified number of times ---> <rebloop 5> print "Hello world!<br>" </rebloop> </body></html> I'm also looking at creating custom tags for: <requery 'qry_user> select * from tblUser where UserID = <rebscript> prin cgivars/userid </rebscript> </requery> Where the result set would be stored in 'qry-user. Just some thoughts :) --John