[REBOL] Rebol /command Version
Hi to all, its possible to get the rebol /command Version ?. I have the need to execute external progs. bye Giuseppe Vita LWP GmbH SystemkommunikationCarl-Zeiss-Str. 5 Phone +49 7243 5433-0 76275 Ettlingen Fax+49 7243 5433-99 GERMANY mailto:[EMAIL PROTECTED] http://www.lwp.de
[REBOL] Rebol /command Version
me too :-) Jan Regent Hi to all, its possible to get the rebol /command Version ?. I have the need to execute external progs. bye
[REBOL] [REBOL] Default Port Values? Re:
Hi, Tim wrote: I'm setting up an object that contains some ports, which may or may not be open. i.e.: may or may not open "test.txt" may or may not open "dufus.txt" obviously I don't want to attempt to close what I didn't open. If I initialize a word to none as dufus-pointer: none and don't open it. the following code: either equal? dufus-pointer none [][close dufus-pointer] generates an error: expected argument of type: port similarly a function like safe-close: func [p[port!]][if p [close p]] generates an error message. How can I get around this? Thanks Folks! Tim Sorry, I don't understand. For me your code works: dufus-pointer: none == none either equal? dufus-pointer none [][close dufus-pointer] Ladislav
[REBOL] strange Re:(2)
Maybe it would be useful with a script that checks scripts for common beginner mistakes like this and warns the scripter. Maybe someone has written one already? Gisle On Tue, 23 May 2000 [EMAIL PROTECTED] wrote: And again.. (we discuss the sense of this sometimes :) list: [] is something like static in c use list: copy[] in rebol Volker Hi! I have the following code: num: 30 to: load %file until [ list: [] print length? list loop num [ elem: first to if elem [ append list elem ] to: next to ] print length? list print "---" tail? to ] It gives 0 30 --- 30 60 --- 60 90 --- 90 120 --- 120 150 Shouldn't list length be set to zero by list: [] ??? Felix Pütsch -- http://www.ph-cip.uni-koeln.de/~puetsch Of course I'm crazy, but that doesn't mean I'm wrong.
[REBOL] [REBOL] Default Port Values? Re:
Hi Tim, 1. safe-close: similarly a function like safe-close: func [p[port!]][if p [close p]] generates an error message. Since you only permit port! as the argument's datatype, and none is of type none! and not port!, you shouldn't be too surprised! ;-) Try safe-close: func [p[port! none!]][if p [close p]] safe-close: func [p[port! none!]][if p [close p]] safe-close dufus-pointer == false 2. equal? dufus-pointer none ... max's idea, to use port?, should certainly work (and is the cleaner way to do it anyway). It bothers me, however, that your code fails. The code you present should work as expected, as can easily be tested in the REBOL shell: dufus-pointer: none == none equal? dufus-pointer none == true I can think of three reasons why this could happen: 1. the error is not being generated by the code you presented; 2. dufus-pointer is being set (unexepctedly!) to some non-port value somewhere in your program. This possibility should worry you! ;-) 3. One of the two none values is not a none value. It is a word value. For instance: a: none == none b: first [none] == none none? a == true none? b == false type? a == none! type? b == word! At 08:44 PM 5/22/00 -0800, you wrote: I'm sending this again Are we having problems with the mailing list again? == I'm setting up an object that contains some ports, which may or may not be open. i.e.: may or may not open "test.txt" may or may not open "dufus.txt" obviously I don't want to attempt to close what I didn't open. If I initialize a word to none as dufus-pointer: none and don't open it. the following code: either equal? dufus-pointer none [][close dufus-pointer] generates an error: expected argument of type: port similarly a function like safe-close: func [p[port!]][if p [close p]] generates an error message. How can I get around this? Thanks Folks! Tim ;- Elan [: - )]
[REBOL] strange Re:(3)
I like the idea of a script checker, but what other common beginner mistakes are there? [EMAIL PROTECTED] wrote: Maybe it would be useful with a script that checks scripts for common beginner mistakes like this and warns the scripter. Maybe someone has written one already? Gisle On Tue, 23 May 2000 [EMAIL PROTECTED] wrote: And again.. (we discuss the sense of this sometimes :) list: [] is something like static in c use list: copy[] in rebol Volker Hi! I have the following code: num: 30 to: load %file until [ list: [] print length? list loop num [ elem: first to if elem [ append list elem ] to: next to ] print length? list print "---" tail? to ] It gives 0 30 --- 30 60 --- 60 90 --- 90 120 --- 120 150 Shouldn't list length be set to zero by list: [] ??? Felix Pütsch -- http://www.ph-cip.uni-koeln.de/~puetsch Of course I'm crazy, but that doesn't mean I'm wrong.
[REBOL] [REBOL] Default Port Values? Re:(2)
Hi Ladislav: Yes, your code works for me. But I wrote a function as follows: safe-close: func [p[port!]][if p [close p]] lets say dufus: none safe-close dufus generates Script Error: safe-close expected p argument of type: port HOWEVER: if I write safe-close: func [p][if p [] [close p]] dufus: [] safe-close dufus I get no error message. :) Duh!! I know I have lots to learn yet. Thanks Tim Sorry, I don't understand. For me your code works: dufus-pointer: none == none either equal? dufus-pointer none [][close dufus-pointer] Ladislav
[REBOL] [REBOL] Default Port Values? Re:(2)
Hi Max: That is very good advice. I keep forgetting to make use of rebol's run-time type checking. That is a very nice feature! Thanks Tim At 10:10 PM 5/22/00 -0700, you wrote: If port? dufus-pointer [ ]
[REBOL] [REBOL] Default Port Values? Re:(3)
Hi Tim, Here safe-close: func [p[port!]][if p [close p]] you are insisting that the argument to safe-close must be a value of datatype port!, [ p [port!] ]. Therefore you get an error message, whenever you pass a value that is not of type port!. In contrast, here safe-close: func [p][if p [] [close p]] you are not declaring a type restriction on the values passed to safe-close, [ p ]. Accordingly, safe-close does not complain that the value is not of type port!. Confusing? Not really. At 08:22 AM 5/23/00 -0800, you wrote: Hi Ladislav: Yes, your code works for me. But I wrote a function as follows: safe-close: func [p[port!]][if p [close p]] lets say dufus: none safe-close dufus generates Script Error: safe-close expected p argument of type: port HOWEVER: if I write safe-close: func [p][if p [] [close p]] dufus: [] safe-close dufus I get no error message. :) Duh!! I know I have lots to learn yet. Thanks Tim Sorry, I don't understand. For me your code works: dufus-pointer: none == none either equal? dufus-pointer none [][close dufus-pointer] Ladislav ;- Elan [: - )]
[REBOL] Simple CGI Problem
Dear REBOL Friends, What is the HTML code for activating a REBOL CGI script from a web page? Specifically I want to activate a hit counter. I know the answer must be simple, but I am trying to learn REBOL and HTML at the same time, and the answer eludes me. Thanks, Louis
[REBOL] Simple CGI Problem Re:
Hello, What is the HTML code for activating a REBOL CGI script from a web page? Specifically I want to activate a hit counter. I know the answer must be simple, but I am trying to learn REBOL and HTML at the same time, and the answer eludes me. either HTMLHEADTITLEwhatever/TITLE/HEAD BODY whatever SCRIPT="REBOL" ---Rebol code goes here--- /SCRIPT whatever /BODY /HTML or just the Rebol code. Don't forget to give the file the .r extension! Regards Christian
[REBOL] Simple CGI Problem Re:
Hi Louis, There are actually several ways to call CGI scripts that count hits to a web page, but this one is probably the most straight forward for your purposes, that is if your web host supports SSI (Server Side Incudes) as well as REBOL: !--#exec cmd="./cgi-bin/count.r" -- Otherwise you will probably want to use a REBOL script as an image. I have'nt seen a REBOL counter that does this yet, so a few people would likely be glad if you wrote one. --Ryan [EMAIL PROTECTED] wrote: Dear REBOL Friends, What is the HTML code for activating a REBOL CGI script from a web page? Specifically I want to activate a hit counter. I know the answer must be simple, but I am trying to learn REBOL and HTML at the same time, and the answer eludes me. Thanks, Louis
[REBOL] Simple CGI Problem Re:(2)
Louis, Ryan's method is very good. Also, if you have PHP enabled pages, this way works quite well also: ?PHP include ("http://abooks.com/cgi-bin/banner.r"); ? --Ralph Roberts -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 23, 2000 4:21 PM To: [EMAIL PROTECTED] Subject: [REBOL] Simple CGI Problem Re: Hi Louis, There are actually several ways to call CGI scripts that count hits to a web page, but this one is probably the most straight forward for your purposes, that is if your web host supports SSI (Server Side Incudes) as well as REBOL: !--#exec cmd="./cgi-bin/count.r" -- Otherwise you will probably want to use a REBOL script as an image. I have'nt seen a REBOL counter that does this yet, so a few people would likely be glad if you wrote one. --Ryan [EMAIL PROTECTED] wrote: Dear REBOL Friends, What is the HTML code for activating a REBOL CGI script from a web page? Specifically I want to activate a hit counter. I know the answer must be simple, but I am trying to learn REBOL and HTML at the same time, and the answer eludes me. Thanks, Louis
[REBOL] loading objects
I have a script that saves the following as text files in a directory... make object! [ headline: "in the woods" subheadline: "out of the woods" body: ["blue forest" "" "" "red forest" "" "" "green forest" ""] ] How can I load this information and then use it? The following does not work: absolute-path: "absolute/path/articles/" read-directory: reform [ "news-directory: read" rejoin [{%} absolute-path] ] do read-directory news-directory: tail news-directory file-list: copy [] for file-grab 1 10 1 [ news-directory: back news-directory file-name: first news-directory append file-list file-name ] foreach file-name file-list [ read-article: reform ["article-content: load" rejoin [{%} absolute-path file- name] ] do read-article print article-content/headline print article-content/subheadline ] ** Script Error: Invalid path value: headline. ** Where: print article-content/headline print article-content/subheadline
[REBOL] loading objects Re:
Hey there Ryan, Try adding do before load. I dont know why.. read-article: reform ["article-content: do load" rejoin [{%} absolute-path file-name]] --Ryan [EMAIL PROTECTED] wrote: I have a script that saves the following as text files in a directory... make object! [ headline: "in the woods" subheadline: "out of the woods" body: ["blue forest" "" "" "red forest" "" "" "green forest" ""] ] How can I load this information and then use it? The following does not work: absolute-path: "absolute/path/articles/" read-directory: reform [ "news-directory: read" rejoin [{%} absolute-path] ] do read-directory news-directory: tail news-directory file-list: copy [] for file-grab 1 10 1 [ news-directory: back news-directory file-name: first news-directory append file-list file-name ] foreach file-name file-list [ read-article: reform ["article-content: load" rejoin [{%} absolute-path file- name] ] do read-article print article-content/headline print article-content/subheadline ] ** Script Error: Invalid path value: headline. ** Where: print article-content/headline print article-content/subheadline
[REBOL] loading objects Re:(2)
Yes, that works. I would have never thought of that. Hey there Ryan, Try adding do before load. I dont know why.. read-article: reform ["article-content: do load" rejoin [{%} absolute-path file-name]] --Ryan [EMAIL PROTECTED] wrote: I have a script that saves the following as text files in a directory... make object! [ headline: "in the woods" subheadline: "out of the woods" body: ["blue forest" "" "" "red forest" "" "" "green forest" ""] ] How can I load this information and then use it? The following does not work: absolute-path: "absolute/path/articles/" read-directory: reform [ "news-directory: read" rejoin [{%} absolute-path] ] do read-directory news-directory: tail news-directory file-list: copy [] for file-grab 1 10 1 [ news-directory: back news-directory file-name: first news-directory append file-list file-name ] foreach file-name file-list [ read-article: reform ["article-content: load" rejoin [{%} absolute-path file- name] ] do read-article print article-content/headline print article-content/subheadline ] ** Script Error: Invalid path value: headline. ** Where: print article-content/headline print article-content/subheadline
[REBOL] loading objects Re:
Hi RChristiansen, 1. The load function returns a block containing whatever is in the file. When you load an object, you get a block that looks something like this: [ make object! [some-word: some-value some-other-word: some-other-value ...] ] This block consists of two words: make and object!, and an unrelated block of set-words and values. The contents of the block must be converted into an object and extracted from the block. You have two choices: 1. Using do If you do the block, the contents of the block are evaluated, REBOL identifies its contents as an expression that creates an object, and creates and returns the created object. object: do load %object.txt 2. Using reduce If you have a file that contains several objects, you have the option of using reduce. The reduce function also evaluates the expressions contained in the block. In contrast to do it returns a block containing the evaluated expressions. The three elements, word make, word object!, block [ make object! [some-word: some-value some-other-word: some-other-value ...] ] are evaluated and what is returned by reduce is a block containing an object: [ make object! [some-word: some-value some-other-word: some-other-value ...] ] Here: loaded-block: [ make object! [some-word: "some-value" some-other-word: "some-other-value"] ] == [make object! [some-word: "some-value" some-other-word: "some-other-value"]] length? loaded-block == 3 first loaded-block == make second loaded-block == object! third loaded-block == [some-word: "some-value" some-other-word: "some-other-value"] reduce loaded-block == [ make object! [ some-word: "some-value" some-other-word: "some-other-value" ]] length? reduce loaded-block == 1 first reduce loaded-block print mold first reduce loaded-block make object! [ some-word: "some-value" some-other-word: "some-other-value" ] 3. I hope you don't mind a few other comments: To retrieve a directory listing, you can use the simple expression load %file-system-path In your case: absolute-path: %/absolute/path/articles/ foreach file load absolute-path [ if not dir? file [ article: do load join absolute-path file print article/headline print articel/subheadline ] ] The line if not dir? file is only necessary if absolute-path could contain subdirectories. Hope this helps ;- Elan [: - )]
[REBOL] [REBOL]Setting up an error template
The following block construct seems to work to catch errors from the interpreter: ;== if error? set/any 'err try [ "Good Code Block" x: "a" + 1 ] [ "Error Block" err: disarm err print reform bind (get in (get in system/error err/type) err/id) in err 'type ] Two questions arise from this 1)Are there associated error numbers that I can trap and thus change the syntax of the error message itself? 2)Is there a way in which I can explicitly force control to be transferred to "Error Block", with an attendant error message. I have looked at docs for "throw" and don't find a clear answer there. Thanks Tim
[REBOL] [REBOL] Default Port Values? Re:(2)
Hi Elan: Perhaps it is better to ask this question: What would be the preferred way to initialize a port prior to a possible open? would it best to be: my-port: none OR my-port: ;== It bothers me, however, that your code fails. The code you present should work as expected, as can easily be tested in the REBOL shell: dufus-pointer: none == none equal? dufus-pointer none == true I can think of three reasons why this could happen: 1. the error is not being generated by the code you presented; 2. dufus-pointer is being set (unexepctedly!) to some non-port value somewhere in your program. This possibility should worry you! ;-) 3. One of the two none values is not a none value. It is a word value. For Your concern is duly noted: If you're worried, I'm worried. Perhaps type? checking is the best way to go regards tj
[REBOL] [REBOL] [REBOL] Default Port Values? Amended
Hi Elan: ; left out the [] !! Perhaps it is better to ask this question: What would be the preferred way to initialize a port prior to a possible open? would it best to be: my-port: none OR my-port: [] ;== It bothers me, however, that your code fails. The code you present should work as expected, as can easily be tested in the REBOL shell: dufus-pointer: none == none equal? dufus-pointer none == true I can think of three reasons why this could happen: 1. the error is not being generated by the code you presented; 2. dufus-pointer is being set (unexepctedly!) to some non-port value somewhere in your program. This possibility should worry you! ;-) 3. One of the two none values is not a none value. It is a word value. For Your concern is duly noted: If you're worried, I'm worried. Perhaps type? checking is the best way to go regards tj
[REBOL] [REBOL] [REBOL] Default Port Values? Amended Re:
tj wrote: What would be the preferred way to initialize a port prior to a possible open? would it best to be: my-port: none OR my-port: [] This way: my-port: none or: my-port: port! This has the advantage of reminding the writer/maintainer as to what type of value is expected to be in 'my-port. Andrew Martin ICQ: 26227169 http://members.xoom.com/AndrewMartin/ --
[REBOL] Simple CGI Problem Re:(2)
Ryan and Ralph, I still can't get it to work on my home page. My web host does support SSI; I'm not sure about PHP. I am using Drumbeat 2000, and am using the "Roll Your Own HTML" smart element to insert the code into the home page. Here is my counter: http://www.worldmerchantltd.com/cgi-bin/counter.r By clicking on the above link and then refreshing your browser, you can see that it works. Here are lines I have tried: !--#exec cmd="./cgi-bin/count.r" -- exec cmd="./cgi-bin/count.r" exec cmd="www.worldmerchantltd.com/cgi-bin/counter.r" exec cmd="worldmerchantltd.com/cgi-bin/counter.r" exec cmd="http://www.worldmerchantltd.com/cgi-bin/counter.r" a href="http://www.worldmerchantltd.com/cgi-bin/counter.r" ?PHP include ("http://abooks.com/cgi-bin/banner.r"); ? ?PHP include ("http://worldmerchantltd.com/cgi-bin/counter.r"); ? ?PHP include ("http://www.worldmerchantltd.com/cgi-bin/counter.r"); ? Note that even Ralph's banner code is there; that should surely work since it addresses his own server. I am just trying to get anything to work. Please examine the source code of this home page ( http://www.worldmerchantltd.com ), and see how Drumbeat inserted the html. I suspect that the problem lies there. A good book on HTML would probably solve my problem; do you recommend one? Thanks, Louis At 01:21 PM 5/23/00 -0700, you wrote: Hi Louis, There are actually several ways to call CGI scripts that count hits to a web page, but this one is probably the most straight forward for your purposes, that is if your web host supports SSI (Server Side Incudes) as well as REBOL: !--#exec cmd="./cgi-bin/count.r" -- Otherwise you will probably want to use a REBOL script as an image. I have'nt seen a REBOL counter that does this yet, so a few people would likely be glad if you wrote one. --Ryan [EMAIL PROTECTED] wrote: Dear REBOL Friends, What is the HTML code for activating a REBOL CGI script from a web page? Specifically I want to activate a hit counter. I know the answer must be simple, but I am trying to learn REBOL and HTML at the same time, and the answer eludes me. Thanks, Louis