[REBOL] text file changes Re:
At 03:59 PM 7/10/00 +1000, you wrote: >hi all >just need a little help with something.. >i am trying to change all returns in a text file to tabs file: read %some-filename.txt replace/all file "^/" "^-" >and then change >every occurence of ZZZ to a returnis this possible? replace/all file "ZZZ" "^/" >i am on windoze 98se.the file is about 12mb with about 500,000 records. >i have checked the user guide but couldn't get anything out of it regarding >this sort of thing > >thanks in advance >keith > > > ;- Elan [ : - ) ]
[REBOL] Changing relative paths to absolute ones. Re:(3)
Hi Bruno, take a really close look at the source you are quoting: >>parse page: read http://www.server [ some [thru "SRC=^"" here: >>(insert here "http://www.server")] to end ] and compare it to what you are doing: >parsepage: read http://www.no.com.br/servlets/ specifically note parse page: vs. parsepage: See the missing space between parse and page? The source you are quoting is submitting the result of reading the Webpage to the parse function, after it has set the word page to point at the Webpage that was read. In contrast you are not using the parse function at all, and instead you are setting a word called parsepage to point at the Web page you read. There are other details that you should consider. But this should get you started. At 06:05 PM 7/6/00 -0300, you wrote: >Em Thursday, July 06 2000, 17:39:01, ([EMAIL PROTECTED]) disse: > > >>parse page: read http://www.server [ some [thru "SRC=^"" here: >>(insert here "http://www.server")] to end ] > >Thanks for your answer. I tried that and it didn't seem to work, but I'm not >even sure if i did the right thing. Here is how my script looks like: > >REBOL [ >Title: "Page Sender" >] > >header: make system/standard/email [ >To: [EMAIL PROTECTED] >From: [EMAIL PROTECTED] >Reply-To: [EMAIL PROTECTED] >Subject: "Teste do NO. via REBOL!" >Organization: "Just a Test" >X-mailer: [REBOL] >MIME-Version: 1.0 >Content-Type: "text/html" >] > >parsepage: read http://www.no.com.br/servlets/ >newstorm.notitia.apresentacao.ServletDeSecao [ >some [ >thru "src=^"" here: (insert here "http://www.no.com.br") >] >to end >] > >send/header [EMAIL PROTECTED] parsepage header > >Is it correct? > >-Bruno > > > ;- Elan [ : - ) ]
[REBOL] Find speed Re:(3)
Hi Ladislav, your test function is responsible for the results you get, not the hash! The critical code in the time-blk function is >start: now >loop :count :block >finish: now When you test the hash function, your timing function (time-blk) loops over the block: >[ >random/seed 1 >c: 0 >blk: make hash! [] >repeat i n [ >d: random m >if not find blk d [ >c: c + 1 >insert blk d >] >] >] 0.05 This block includes the CREATION of the hash and INSERTING items into the hash. Certainly creating a hash and inserting items into the hash is not the same thing as searching in a hash and the time required to CREATE the data structure and INSERT items into the data structure should not be part of the value reported for the time required to SEARCH in the data structure. Inserting an element into a hash is by nature of hashing algorithms far more time consuming than inserting an element into a block. Hashes are optimized for locating an element at the penalty of consuming more time for insertion. To correctly identify the time it takes to locate an element in a hash, you must separate the insertion of the element into the hash from the time you calculate to retrieve the element in the hash. If you separate insertion from the search in a hash, you must do the same for the blocks as well. Only then will you be able to compare values that reflect how long it takes to SEARCH in the different series types you are testing! At 10:46 AM 7/6/00 +0200, you wrote: >Hi, > >regarding memoizing. There is a class of functions, that must use >some kind of memoizing to work at all, I think. The number of the >possibilities for parameters does not matter, you can store only >important results (depending on what you consider important - eg. >expensive or recent results...) > >Because I used a non-real-life example for testing, here is >something more adequate for memoizing purposes: > >Block/find time: 14.5 count: 7771 >Block/bfind time: 5.875 count: 7771 >Hash/find time: 28.5 count: 7771 > >The source code: > >REBOL[ >Title: "Seconds" >Author: "Ladislav Mecir" >Email: [EMAIL PROTECTED] >Date: 19/5/1999 >File: %seconds.r >] > >seconds: function [ >{Compute difference between dates in seconds} >a [date!] "first date" >b [date!] "second date" >] [diff] [ >diff: b - a >diff: 24 * diff + b/time/hour - a/time/hour + >b/zone/hour - a/zone/hour >diff: 60 * diff + b/time/minute - a/time/minute >60 * diff + b/time/second - a/time/second >] > > >REBOL[ >Title: "Time-block" >Author: "Ladislav Mecir" >E-mail: [EMAIL PROTECTED] >Date: 19/5/1999 >File: %timblk.r >Purpose: { >Measure time of a block execution with given relative >accuracy. >This function can even time the execution of the empty >block. >Suggested values for accuracy are: 0.05 to 0.30. >Accuracy better than 0.05 may not be reachable, >accuracy worse than 0.30 may not be useful. >} >] > >include %seconds.r > >time-block: function [ >"Time a block." >block [block!] >accuracy [decimal!] >/verbose >] [ >guess count lower upper start finish result >] [ >if verbose [print ["Timing a block:" block]] >guess: 0 >count: 1 >lower: 1 - :accuracy >upper: 1 + :accuracy >while [ >start: now >loop :count :block >finish: now >result: (seconds start finish) / count >if verbose [ >prin "Iterations: " >prin count >prin ". Time/iteration: " >prin result >prin " seconds.^/" >] >any [ >result <= 0 >guess < (result * lower) >guess > (result * upper) >] >][ >guess: result >count: count * 2 >] >result >] > >{ >Example: > >time-block [] 0,05 >} > >Rebol [] > >bfind: func [ >blk [block!] >value >/local d u m >] [ >d: 1 >u: length? blk >while [(m: to integer! (d + u) / 2) > d] [ >either (pick blk m) <= value [d: m] [u: m] >] >either (pick blk u) <= value [u] [d] >] > >include %timblk.r > >n: 8192 ; the test size >m: 10 * n ; random number range >prin "Block/find time: " >prin time-block [ >random/seed 1 >c: 0 >blk: copy [] >repeat i n [ >d: random m >if not find blk d [ >c: c + 1 >append blk d >] >] >] 0.05 >prin " count: " >print c >prin "Block/bfind time: " >prin time-block [ >random/seed 1 >c: 0 >blk: copy [] >repeat i n [ >d: random m >either empty? blk [ >c: c + 1 >insert blk d >] [ >bf: bfind blk d >if not (pick blk bf) = d [ >c: c + 1 >insert skip blk either (pick blk bf) > d [ >bf - 1 >] [ >
[REBOL] An experiment with RTF Re:
Hi Brett, would you consider using AbiWord? It's a beautiful, open source, portable word processor (still in prelease, but it rocks). The advantage is that uses an XML based page description language that can easily be parsed using REBOL's XML parser and then converted into the appropriate HTML. you can download a copy at http://www.abisource.com Advantages: 1. AbiWord has a relatively small footprint (compared to MS Word). It loads much faster. 2. You can download the source and you could conceivably add a button that a) saves the current file, b) starts up REBOL and has REBOL parse the saved file, and c) posts the file to the Web site. 3. AbiWord is similar enough to MS Word that I would think that anyone who can use MS Word will be able to figure out AbiWord quite easily. 4. Big plus: You do not place your solution in the hands of a 3rd party. I.e. you control what your software does. With MS Word, if Microsoft decides to change something about MS Word, and you happen to rely on that feature, and your sister's company wants to use the new improved version of MS Word, they will have to keep two versions of MS Word around, which may cause confusion, take up alot of hard drive space, and conceivably occassionally crash the computer. I think we should adopt AbiWord as standard front end for text and XML oriented interactive solutions that include REBOL as a scripting component. At 07:25 PM 7/6/00 +1000, you wrote: >Hi, > >Again I'm re-impressed with rebol. I spent yesterday and today parsing Rich >Text Format files with rebol and it works a treat. >Although I only got as far as loading RTF into Rebol blocks and words - but >I'm still impressed. > >The situation I have is that I'm going to do up a web-site for my sister's >company. I want to be able to implement a consistent style for the site and >yet have my sister or her staff do the updates. Since they are not familiar >with Web pages (and I don't think they should have to be), I was looking for >some sort of automated process. I've done a lot of research on the web and I >haven't seen a simple effective solution to this problem - the grail of >content + presentation. > >I'd appreciate any comments on other peoples experiences with this sort of >thing. > >I hope others may yet find a use for the code I've generated so far, so I >placed it at rebol.org. And if you can use it let me know - I need the >satisfaction :) > >The script can be found at http://www.rebol.org/general/rtf-tools.r > >Brett Handley > > > ;- Elan [ : - ) ]
[REBOL] Does rebol --do "print 123" for e.g. work for ya? Re:
Hi Petr, works fine for me. I can duplicate your error if I leave away the surrounding "", i.e. if instead of rebol --do "print 123" I enter rebol --do print 123 ;- Elan [ : - ) ]
[REBOL] one more time Re:
Hi Tom, to make things a little more interesting, under Redhat Linux 2.2.15 I am having absolutely no problems. Which Linux distribution are you using? At 12:59 PM 7/6/00 +0100, you wrote: >one more time > >howdy again, > >I'm stumped. Why do I get this with REBOL 2.3.0.4.2: > >error in loading shared libraries: libtermcap.so.2: cannot open shared >object file: No such file or directory > >and not with 2.2.0.4.2? > >I ran "update", and I'm using the libc6 version... >does anyone have a clue? > >Thanks in advance, > >-tom > > > ;- Elan [ : - ) ]
[REBOL] Automation query... Re:
Hi, I just noticed that Windows has a problem with colons in file names. This should work better if you're running under MS Windows (under linux, you can disregard the modification): REBOL [] forever [ wait 60 if error? set/any 'error try [ do %popreader.r ] [ date: replace form now "/" "-" date: replace/all date ":" "." logfile: to file! join "error-" [date ".log"] save logfile mold disarm error ] ] ;- Elan [ : - ) ]
[REBOL] Automation query... Re:
Hi TBrownell, you wrote: >Hi. > >What is the best way to run a script on a timer basis? > >I have a script that that fires off another that >checks a pop account every minute and then runs any >scripts it finds. > >This is a bit thick, but it works... > >N: repeat 100 [wait 60 do %popreader.r] You can use forever, i.e. forever [ wait 60 do %popreader.r ] > >This is lacking as... > >A. If it hits an error it stalls. use try, i.e. forever [ wait 60 if error? set/any 'error try [ do %popreader.r ] [ date: replace form now "/" "-" logfile: to file! join "error-" [date ".log"] save logfile mold disarm error ] ] (this will log each error into its own file called error--.log) and - more importantly - it should continue executing. >B. It picks up values from all the scripts it >generates via email That I don't understand. Where are these values coming from? Remember, REBOL does garbage collection, so I would assume - depending on how popreader.r is written - that old values are garbage collected whenever you rerun popreader.r, because popreader.r will reuse the same words it used previously. When the words are reused the old values become orphaned and are garbage collected. So you shouldn't be accumulating any garbage. But then again, I haven't seen popreader's source, so what do I know? In any event, it should be possible to write popreader.r in such a way that you don't accumulate stuff over several runs. Hope this helps, ;- Elan [ : - ) ]
[REBOL] View: RebolForces Reb updated Re:
Hi Allen, really very nice work. At 02:55 AM 7/1/00 +1000, you wrote: >Hi Rebols, > >I've just finished an update of the Rebolforces Reb. I've added a number of >the interface features people asked for. You can now choose to run, download >and browse the colorised source for each script. ("+" maximises the >minimised windows too) . > >If you haven't visited for a while, click the download icons before running >scripts to force an updated version to be cached on your system. > >The view-FAQ I wrote is also linked from the reb as well as 13 other view >demos. > > >Have a good weekend! (and pity us Aussies as we wake up to a new tax system) > >Cheers, > >Allen K > >Use the REBOL forces link from the Rebol Tech Reb or use the link below > >REBOL [] >do http://www.janita.com.au/rebolforces/reb/index.r > > > > > > ;- Elan [ : - ) ]
[REBOL] REBOL/Core 2.3 Released! Re:(2)
Hi Ralph, re: ftp did you try setting passive to true as Holger suggested? At 08:41 AM 6/28/00 -0400, you wrote: >> >> Announcing the release of REBOL/Core 2.3! >> >> This new version of REBOL/Core includes many >> improvements only available in beta versions >> of our REBOL/View and REBOL/Command products, >> until now. >> > >This is great, thanks, and congrats to all the REBOL team... but ... > >I was going to use 'feedback' to report that FTP is still broken but it >seems that 'feedback' itself now does not work. I get: > >>> feedback >** Script Error: feedback has no value. >** Where: feedback > >and the FTP error that has appeared in all REBOLs since 2.2 is still there: > >>> read ftp://ftp.abooks.com/ >connecting to: ftp.abooks.com >** User Error: Server error: tcp 425 Can't build data connection: Connection >refused.. >** Where: read ftp://ftp.abooks.com/ > >This latter is a bit critical for us here to get working again. > >But... overall... 2.3 seems nicely improved. > >--Ralph Roberts > > > > ;- Elan [ : - ) ]
[REBOL] Problems calling 'external' functions Re:
Hi Peter, I have not encountered a problem with multiple do's. I don't see why there should be a problem. If your functions in test_opcodes.r evaluates anything that ultimately attempts to evaluate words defined in ea.r, then you would be getting an error message, if ea.r had not been do'ne. My guess is your problem has nothing to do with 'do. Send me your files off list and - quite likely - I'll have a solution for you soon. mailto: [EMAIL PROTECTED] At 04:45 PM 6/15/00 +0200, you wrote: >Hello! > >A couple of weeks ago I asked how to split a >project in to several files. The solution was >to 'do' all files to include them in the >main file. > >This has worked fine until now... > >I now have created some files like: > >opcodes.r (includes a 'do %ea.r') >ea.r >test_opcodes.r (includes a 'do %opcodes.r') >test_ea.r (includes a 'do %ea.r') > >In the test_* files I have prepared test cases >to verify the functions in the other files. > >Executing the test_ea.r file is working fine and >will call all functions in ea.r without problems >but when I execute test_opcodes.r it does not >execute the functions in ea.r. There are no error >messages saying that no function by that name >is found. > >Is there some sort of limit to how 'deep' a >function call could be? > >I have tried to include a 'do %ea.r' in the >test_opcodes.r as well but nothing changes. > >Could someone please help me? > >Best regards, >Peter Carlsson > > >Peter CarlssonTel: +46 31 735 45 26 >Saab Ericsson Space ABFax: +46 31 735 40 00 >S-405 15 Göteborg Email: [EMAIL PROTECTED] >SWEDENURL: http://www.space.se > > > > ;- Elan [ : - ) ]
[REBOL] Errata: parsing questions - newbie Re:
Hi Keith, small error. Should be: foreach file load %/c/folder/of/files/ [ clear result parse-file: read file parse parse-file parse-rule print result ] ;- Elan [ : - ) ]
[REBOL] parsing questions - newbie Re:(2)
Hi Keith, you wrote: >hi elan >well i've looked at the parse section and can't quite figure it out... >how do you nominate that you want the parse function to take place on a >text file say "aeros.txt" rather than a string? parse read %aeros.txt rules some-parse-rule >and how do you specify it's location? %aeros.txt ;- file aeros.txt is located in current directory %/c/windows/temp/aeros.txt ;- aeros.txt is located on drive C: in directory ;- \Windows\Temp\ >and how would you strip off just what's after the colon and discard what is >before the colon? It depends on which version of REBOL you are using. I'll go with REBOL/Core here. I am assuming that newline is your delimeter for a record. The CMLISTPTRACKS: entry is wrapped over several lines in my email client. But for this item I also assume that the original data consists of one long line. The following script creates a parse rule, reads the aero.txt file and applies the rule to the file. It generates the following output in the REBOL console: (This output is tripple wrapped: by the REBOL console, by my email client, by your email client. The actual string contains no newlines.) >> do %parse-question.r Script: "Untitled" (none) INFINITE POSSIBILITIES AMEL LARRIEUX 4948792 9399700067507 C9921 21 SMA 19/06/20 00 GET UP,I N I,SWEET MISERY,SEARCHIN' FOR MY SOUL,EVEN IF,INFINITE POSSIBILITES,SHINE,DOWN,WEA THER,MAKE ME WHOLE,GET UP (THREAD HAD FUN MAIN MI,GET UP (MV MIG MIX (RADIO))15.91 Compact Disc Here's the script: REBOL [ file: %parse-question.r ] result: {} words: [ "CPTITLE:" "CPARTIST:" "CMCATNUMBER:" "CMAPN:" "CMARIAPRICECODE:" "CMARIAMEDIACODE:" "CMARIADISTRIBUTORCODE:" "DMRELEASE:" "CMLISTPTRACKS:" "CURMPRICE:" "CMTYPE:" ] parse-sub-rule: [] foreach word words [ insert tail parse-sub-rule :word insert tail parse-sub-rule [copy info to newline (append result join info tab)| ] ] insert tail parse-sub-rule [ skip ] parse-rule: compose/deep [some [(parse-sub-rule)]] parse-file: read %aero.txt parse parse-file parse-rule print result >when you parse files, can it be done on a folder of files? foreach parse file load %/c/folder/of/files/ [ clear result parse parse-file parse-rule print result ] >i have a stack of html files that i need to extract all text in a >particular section and then change the table cells to tabs etc but i have a >few to do and would like to run the script over the whole lot at once if >possible. This sounds like a different task? >i can see no reference to how you parse files locally..there are only >examples of web addresses or specifying a string. See the examples above. > >thanks for your help >keith > >> >hi all >> >i am new to scripting (rebol and python) and was wondering if it was >> >capable of doing to the following and if so..how? >> >the following is an example of what i need to strip and turn into a tab >> >delimited file.. >> >the entries are from a music database that is updated weekly..it is in >> >lotus notes so i export from there and it dumps this file out with the new >> >titles for the coming week (here the 19th June) >> >i only need to get the rows with the double astericks at the start (i put >> >those in for this post, they are not there in the normal file) and then >> >strip the words at the start and then put a tab in between them so i can >> >bring it into excel for the sales team to look at i would need a first >> >row to describe each column also maybe something like >> >Title tab Artist tab Cat no tab APN etc etc >> >the tracklisting is a little more complicated as it has multiple tracks >> >within the row..they are seperated by commas >> >i think that it won't be that hard but i had no success in perl so i >> >thought i might try rebol or python... >> > >> >thanks in advance >> >keith >> > >> >FORM: Popular Recording >> >CMTYPESWITCH: Popular >> >RELOCORIGINAL: 55864A2603AC94ACCA2568F200224388 >> >CMCOUNTRY_ORIGIN: >> >CMGENRE_CODE: >> >**CPTITLE: INFINITE POSSIBILITIES >> >**CPARTIST: AMEL LARRIEUX >> >CPOARTISTS: >> >**CMCATNUMBER: 4948792 >> >**CMAPN: 9399700067507 >> >**CMARIAPRICECODE: C9921 >> >**CMARIAMEDIACODE: 21 >> >**CMARIADISTRIBUTORCODE: SMA >> >CMARIAPACKAGECODE: >> >**DMRELEASE: 19/06/2000 >> >cMDateFormat: 19/06/2000 12:00:00 AM >> >DMDELETE: >> >cMDeleteStatus: No >> >**CMLISTPTRACKS: GET UP,I N I,SWEET MISERY,SEARCHIN' FOR MY SOUL,EVEN >> >IF,INFINITE POSSIBILITES,SHINE,DOWN,WEATHER,MAKE ME WHOLE,GET UP (THREAD >> >HAD FUN MAIN MI,GET UP (MV MIG MIX (RADIO)) >> >CMLISTPARTISTS: ,,, >> >RELOCMEDIA: F73C80183A01A8D7CA2568F2002A5517 >> >**CURMPRICE: 15.91 >> >**CMTYPE: Compact Disc >> >CMRECORDCOMPANY: SONY MUSIC >> >CMPACKAGE: >> >CMARIADISTRIBUTORHOUSECODE: >> >cDistributorHouse: >> >CMLOCALE: Y >> >$UpdatedBy: CN=PPT/OU=AEROS/O=JUKEBOX >> >$Revisions: 02/06/2000 05:42:22 PM,02/06/2000 05:42:22 PM >> > >> > >> > >> >>;- Elan [ : - ) ] > > > ;- Elan [
[REBOL] can rebol strip this type of text file? Re:
Hi Keith, its trivial to do that in REBOL. You have a number of different choices. The most elegant way to do it would be to use parse. Take a look at the documentation under parse. Let me know if you have questions. Elan At 04:18 PM 6/13/00 +1000, you wrote: >hi all >i am new to scripting (rebol and python) and was wondering if it was >capable of doing to the following and if so..how? >the following is an example of what i need to strip and turn into a tab >delimited file.. >the entries are from a music database that is updated weekly..it is in >lotus notes so i export from there and it dumps this file out with the new >titles for the coming week (here the 19th June) >i only need to get the rows with the double astericks at the start (i put >those in for this post, they are not there in the normal file) and then >strip the words at the start and then put a tab in between them so i can >bring it into excel for the sales team to look at i would need a first >row to describe each column also maybe something like >Title tab Artist tab Cat no tab APN etc etc >the tracklisting is a little more complicated as it has multiple tracks >within the row..they are seperated by commas >i think that it won't be that hard but i had no success in perl so i >thought i might try rebol or python... > >thanks in advance >keith > >FORM: Popular Recording >CMTYPESWITCH: Popular >RELOCORIGINAL: 55864A2603AC94ACCA2568F200224388 >CMCOUNTRY_ORIGIN: >CMGENRE_CODE: >**CPTITLE: INFINITE POSSIBILITIES >**CPARTIST: AMEL LARRIEUX >CPOARTISTS: >**CMCATNUMBER: 4948792 >**CMAPN: 9399700067507 >**CMARIAPRICECODE: C9921 >**CMARIAMEDIACODE: 21 >**CMARIADISTRIBUTORCODE: SMA >CMARIAPACKAGECODE: >**DMRELEASE: 19/06/2000 >cMDateFormat: 19/06/2000 12:00:00 AM >DMDELETE: >cMDeleteStatus: No >**CMLISTPTRACKS: GET UP,I N I,SWEET MISERY,SEARCHIN' FOR MY SOUL,EVEN >IF,INFINITE POSSIBILITES,SHINE,DOWN,WEATHER,MAKE ME WHOLE,GET UP (THREAD >HAD FUN MAIN MI,GET UP (MV MIG MIX (RADIO)) >CMLISTPARTISTS: ,,, >RELOCMEDIA: F73C80183A01A8D7CA2568F2002A5517 >**CURMPRICE: 15.91 >**CMTYPE: Compact Disc >CMRECORDCOMPANY: SONY MUSIC >CMPACKAGE: >CMARIADISTRIBUTORHOUSECODE: >cDistributorHouse: >CMLOCALE: Y >$UpdatedBy: CN=PPT/OU=AEROS/O=JUKEBOX >$Revisions: 02/06/2000 05:42:22 PM,02/06/2000 05:42:22 PM > > > ;- Elan [ : - ) ]
[REBOL] Contexts Re:
Hi PHil, I replaced text-fx by block-fx and bind block-fx to fx's local context before I do it: fx: function [x] [] [ print x bind block-fx 'x print do block-fx ] block-fx: [x * x] >> x: 100 == 100 >> >> fx 2 2 4 >> fx 3 3 9 To the same thing with text-fx use: fx: function [x] [] [ print x block-fx: make block! text-fx bind block-fx 'REBOL bind block-fx 'x print do block-fx ] >> text-fx: "x * x" == "x * x" >> fx 3 3 9 >> fx 1 1 1 >> fx 2 2 4 ;- Elan At 06:33 PM 6/4/00 +0100, you wrote: >Hi all, > >can anyone help me with this simple question about contexts > >Consider the following rebol program > >REBOL [ >Title: "Test function definition" >Date: 04-Jun-2000 >File: %fx.r >Purpose: "Test function definition" >] > >; define fx >fx: function [x] [] >[ >print x >print do text-fx >] > >; Main line >text-fx: "x * x" > >x: 100 > >fx 2 >fx 3 > > >even though I have passed the variable x into the function fx, when I "do" >the string text-fx it used the value of x from the main line. > >How do I get the do function to take the value of x passed into the >function. >(I'm sure someone has told me how to this previously but I cant remember the >answer :-(( ) > >Cheers PHil > > > ;- Elan >> [: - )]
[REBOL] simple beginners Q: need to assign variable value to variable Re:
Hi Bryce, I'm not sure I understand your question. The way I interpret what you are saying, the following mechanisms may prove useful. Evaluating the following for loop (Note here I am using to set-word!) >> for i 1 10 1 [ print mold to set-word! join 'var [i] ] results in var1: var2: var3: var4: var5: var6: var7: var8: var9: var10: To assign a value use set (Note here I am using to word!, not to set-word! You could also use set-word! but its not necessary) >> for i 1 10 1 [ set to word! join 'var [i] i print [ to word! join 'var [i] get to word! join 'var [i] ] ] Evaluating this for loop generates the following output: var1 1 var2 2 var3 3 var4 4 var5 5 var6 6 var7 7 var8 8 var9 9 var10 10 The varN words we created are available outside of the for loop: >> var1 == 1 >> var2 == 2 >> var3 == 3 Or to automate the process: >> for i 1 10 1 [ print [mold to word! join 'var [i] " " get to word! join 'var [i] ] ] var1 1 var2 2 var3 3 var4 4 var5 5 var6 6 var7 7 var8 8 var9 9 var10 10 We can unset the varNs as well: >> for i 1 10 1 [ unset to word! join 'var [i] ] Now, var1 no longer exists >> var1 ** Script Error: var1 has no value. ** Where: var1 Another mechanism that may come in handy: Here I set the word test to the set-word! value var1. >> i: 1 test: to set-word! join 'var [i] == var1: >> :test == var1: When I attempt to get the value of var1, I generate an error because var1 was not assigned a value: >> get :test ** Script Error: var1 has no value. ** Where: get :test Now I set the value of var1 to 10. It works like this. REBOL dereferences the word test and retrieves its value, which is the set-word! var1:. A set-word! is like a magnet, it attaches itself to whatever value it finds next. That value is 10: >> test 10 == 10 The word test continues to evaluate to var1, as it did before: >> :test == var1: We can now safely retrieve the value of var1: >> get :test == 10 Or to illustrate it differently: >> unset 'var1 >> var1 ** Script Error: var1 has no value. ** Where: var1 >> i: 1 test: to set-word! join 'var [i] == var1: >> test 10 == 10 >> var1 == 10 A final remark. I would normally just collect my stuff in a block, instead of using set-words: >> for i 1 10 1 [ append [] i ] == [1 2 3 4 5 6 7 8 9 10] or if you want to later retrieve the block: >> result-block: for i 1 10 1 [ append [] i ] == [1 2 3 4 5 6 7 8 9 10] >> result-block == [1 2 3 4 5 6 7 8 9 10] At 12:43 PM 5/31/00 -0700, you wrote: >First let me tell you I took a C++ course(1301) years ago and haven't done >too much programing since. I'm just installed a small LAN and am trying >to learn rebol for maitnance and fun >Now my problem...I need to make the value of var1:test1 into the name of a >new variable that can hold a value like test1:4. Then the programs loops >and var1:test2 and I want test2:some#. I can make the value of var1 >increment I just can't figure out how to make test#:some# from var1:test#. >Thanks for any help, I looked all over the sites documentation but didn't >see what I needed...if its on there just point me in the direction to look >if its easier. Thanks, Bryce > > >-- > >Why is College Club the largest and fastest growing college student site? >Find out for yourself at http://www.collegeclub.com > > > > ;- Elan >> [: - )]
[REBOL] editor for /core here Re:(2)
[REBOL] editor for /core here Re:(2) Hi Volker! you wrote: [snipped quite a few things I cannot respond to right now. Later ...] > >Thanks for testing, whish-list, other feedback :) >i have more fun working on it now :) Since you appear to respond quite reasonably to my observations, here's more ;-) (BTW, I've been using the editor on and off all day. Ran into a few out of range errors, but recovery apparently works quite well.) 1. I wasn't able to figure out how to load a pre-existing file. Apparently internally the function open-t/cache filename works quite well, when you subsequently call ed. So I wrote my own little function. ef: func [filename [file!]] [ open-t/cache filename ed ] (Ok. So I basically copied your .readme function.) and added it to files.r. Unless I overlooked your "open existing file" macro/function, why not include it? 2. How do I tell edi to forget a file that's in the cache? 3. Apparently cached files are not remembered from REBOL session to REBOL session. Can I change this behavior? I.e. can I restart edi in a new REBOL session and edi will remember the files I had opened previously? 4. tt and ^l work well enough. Very useful! 5. Can opening of duplicate copies of the same file be prevented? There are a few things I plan to add, as soon as I have a moment. TIA, ;- Elan [ : - ) ] / Oh, this email was also written in edi.r. What else? ;-)
[REBOL] REBOL/View/Command guidance Re:
Hi Ryan, sounds good. The critical issue for me here would be to check that REBOL/Command can work well with the serial drivers you are using. Since in Linux / U*x systems, serial drivers are implemented as special files (if my memory serves me well, it's been ~ 15 years since I did serial programming on u*x machine), even REBOL/Core should be able to handle it using non-buffered file ports. That shouldn't be a problem, but I'd test it anyway. In MS OSs you would have to access the serial port through a dll. And this may be a little tougher to get right. REBOL's event-driven environment does not scale well to IRQ driven, or polling driven Serial I/O. Haven't played with Serial ports since Win 3.x, so again, my advice may be antiquated. If you run into problems, you may want to try using one of the thoroughly tested serial i/o libraries for MS Win, compile a dll application that does the low-level serial i/o stuff, and use REBOL/Command to interface with the dll. At 12:04 PM 5/30/00 -0700, you wrote: >I need some guidance as to whether REBOL/View/Command has the >capabilities for an upcoming project. > >A friend of mine is going to migrate a Visual BASIC security system >product to another language and maybe even from the Win9x platform. >This is a good time for him to learn REBOL, that is if REBOL/View and >REBOL/Command will be able to handle the problem at hand. > >The system will need to communicate to two other devices via the serial >port. I assume REBOL/Command will do that with the help of some serial >driver programs. > >It needs to run solely with a touch screen interface, which operates >like a mouse. REBOL/View should do this job I suppose. > >There needs to be the ability to have multiple terminals/clients, which >run of a single server. I expect that REBOL/Command could help us >there, since I could do that with REBOL/Core. > >I assume REBOL/View can work as a client to REBOL/Command. REBOL/View >being a visual version of REBOL/Core and REBOL/Command being a binary >executing version of REBOL/Core (amongst other things). > >Am I on the right track here? Will REBOL do this? > >--Ryan > > > ;- Elan >> [: - )]
[REBOL] hidden variables in objects? Re:(16)
Hi Ladislav, it wasn't really meant as a puzzle, just amusing. Yes, you're right: >type? in o 'b >== none! My question regarding this behavior: >> Wouldn't it be better if in o 'b returned unset! instead of >>none? What do you think? >From a pragramatical point of view, the none return value is surely useful. You can easily determine if the word is defined in the object. At the same time, because 'b is not defined in o, I think it would be cleaner, if it behaved like 'a that was set to unset!. In the global context it does that: 1. z was never defined: >> unset 'z >> value? 'z == false 2. y is defined and then unset. >> y: none == none >> value? 'y == true >> unset 'y >> value? 'y == false 3. Summary: a) I unset a non-defined 'z, and tested 'z using value? The result was false. b) I set 'y to a value, and value? 'y returned true. c) I unset 'y d) Because of c) both 'z and 'y responded in the same way to value?. 4. In contrast, in an object, if I follow the same sequence of steps: a) I unset 'z b) I set 'y to a value c) I unset 'y >> o: make object! [unset 'z y: none unset 'y ] then the two words y and z in the object's context respond differently to value?. >> value? in o 'y == false >> value? in o 'z == true We know why 'z responds with true. As you pointed out, it's because 'z was never defined in the context of the object 'o, therefore in o 'z returns none, and none is a defined word. 'y was first defined in object o's context and then unset. It is known in object o's context as an unset value. So when I go through the same step sequence globally (a .. c), 'y and 'z are evaluated in the same way. If I go through the same step sequence in the object 'o, 'y and 'z are treated different from each other. a) I think it would be preferable if 'y and 'z were treated identical in the object's context as well, like they are in the global context. b) I think the preferable behavior would be for REBOL to return unset! for in o 'z as well as for in o 'y instead of returning none for in o 'z and 'y for in o 'y. Opinions? It would make objects more consistent within themselves and more consistent with the way non-defined and unset values are treated globally. > >value? none >== true > >Regards >Ladislav > > >> Hi Jeff, >> >> you wrote: >> >I wonder what Carl's thinking is >> >about why words default to NONE in functions, and UNSET at the >global >> >and object contexts. What's the deeper meaning? >> >> A few more fun samples, followed by a short comment: >> >> 1. Samples >> >> f: func [arg [any-type!] ] [ print value? 'arg ] >> >> f >> false >> >> f 1 >> true >> >> >> f: func [ /refine arg [any-type!] ] [ print value? 'arg ] >> >> f >> true >> >> f/refine >> false >> >> >> o: make object! [ a: none unset 'a ] >> >> probe o >> >> make object! [ >> a: unset >> ] >> >> >> type? o/a >> == unset! >> >> >> >> >> in o 'b >> == none >> >> value? in o 'b >> == true >> >> Of course. none is defined. >> Wouldn't it be better is in o 'b returned unset! instead of >none? >> >> >> in o 'a >> == a >> >> value? in o 'a >> == false >> >> because 'a in o is defined as unset!. >> >> 2. Comment >> Is it really a puzzle? As soon as arguments are used as part of >a function >> declaration, they have entered into a state of existence and >must be >> initialized to some none-value. >> >> >> >> At 11:23 AM 5/29/00 -0600, you wrote: >> > >> >> [EMAIL PROTECTED] wrote: >> >>> The trick here is what does SELF evaluate to when you set >'x to >> >>> it? SELF at that time is an object, containing the words C >and D, >> >>> but those words haven't yet been assigned anything at the >time you >> >>> assign the word X to SELF. >> >> >> >> I would assume they're unset in that stage (even if perhaps >setting >> >> them to NONE could make more sense for an object, like it >is for >> >> function contexts). >> > >> > Which makes me consider what are the real distinctions >between NONE >> >and UNSET? I tend to think that NONE, in REBOL, is closer to a >> >logical state, where as UNSET is more of an existential state. >For a >> >function, local variables defaulting to NONE eases a common >question >> >function writers will ask in their code: >> > >> > if local-variable [do-something-with local-variable] >> > >> > I tend to think that words in the global context or in an >object >> >context are more in an existential state. Once they are >mentioned in a >> >given context the word exists but with no value. They either >are >> >filled in by the person mentioning that word in that context or >not. >> >A word at the global context or in an object context isn't like >a word >> >in a function context which may be changing all the time, being >passed >> >in or not. Those non function context variables seem more >> >existential. At least, that's how it all strikes me. But. of >course, >> >that's just my own formulation, and not necessarily the most in >> >keeping with REBOL's philosophy. I wonder what C
[REBOL] hidden variables in objects? Re:(14)
Hi Jeff, you wrote: >I wonder what Carl's thinking is >about why words default to NONE in functions, and UNSET at the global >and object contexts. What's the deeper meaning? A few more fun samples, followed by a short comment: 1. Samples >> f: func [arg [any-type!] ] [ print value? 'arg ] >> f false >> f 1 true >> f: func [ /refine arg [any-type!] ] [ print value? 'arg ] >> f true >> f/refine false >> o: make object! [ a: none unset 'a ] >> probe o make object! [ a: unset ] >> type? o/a == unset! >> >> in o 'b == none >> value? in o 'b == true Of course. none is defined. Wouldn't it be better is in o 'b returned unset! instead of none? >> in o 'a == a >> value? in o 'a == false because 'a in o is defined as unset!. 2. Comment Is it really a puzzle? As soon as arguments are used as part of a function declaration, they have entered into a state of existence and must be initialized to some none-value. At 11:23 AM 5/29/00 -0600, you wrote: > >> [EMAIL PROTECTED] wrote: >>> The trick here is what does SELF evaluate to when you set 'x to >>> it? SELF at that time is an object, containing the words C and D, >>> but those words haven't yet been assigned anything at the time you >>> assign the word X to SELF. >> >> I would assume they're unset in that stage (even if perhaps setting >> them to NONE could make more sense for an object, like it is for >> function contexts). > > Which makes me consider what are the real distinctions between NONE >and UNSET? I tend to think that NONE, in REBOL, is closer to a >logical state, where as UNSET is more of an existential state. For a >function, local variables defaulting to NONE eases a common question >function writers will ask in their code: > > if local-variable [do-something-with local-variable] > > I tend to think that words in the global context or in an object >context are more in an existential state. Once they are mentioned in a >given context the word exists but with no value. They either are >filled in by the person mentioning that word in that context or not. >A word at the global context or in an object context isn't like a word >in a function context which may be changing all the time, being passed >in or not. Those non function context variables seem more >existential. At least, that's how it all strikes me. But. of course, >that's just my own formulation, and not necessarily the most in >keeping with REBOL's philosophy. I wonder what Carl's thinking is >about why words default to NONE in functions, and UNSET at the global >and object contexts. What's the deeper meaning? There always is a >deeper purpose with most things in REBOL. (-: > > Cheers-- > > -jeff > > > > ;- Elan >> [: - )]
[REBOL] editor for /core here Re:
Hi Volker, I wrote this with your new editor. So, you beat me to it ;-). Well, not really. I had something more light-weight and less capable in mind. I still see a "market" for that. BTW, I first had a weird bug, when I tried to run .readme. I was able to track it down to the fact that I have my own word 'files defined in my user.r. It's a function. Because you ask value? 'files and only set files if it does not have a value to a block, and because in my case 'files was set - to something quite different - the word files was not set to a block. When you later tried to access files/1 if either files/1 ... you inadvertently caused a very weird error. I understand that you had problems putting everything in a context. That's not surprising. Currently the use context mechanism is buggy and breaks when the garbage collector kicks in. Objects, however, are stable. Why not provide ed as an external function and move everything else into an -ed object? The objects you use can become objects embedded in the -ed object. Do you think that might work? Anyway, I'm having fun using it (so far), have to learn a little more about its commands. So far I've mastered .bs, .be, and .db :-) You're right, word wrap is needed! ;- Elan >> [: - )]
[REBOL] refinements Re:
Hi Michael, here's another idea: 1. Use refine-func instead of func to create a function. 2. Use call-with-refine to call a function with refinements. Example: Given the function f: f: func [/a /b /c][if a [print 'a] if b [print 'b] if c [print 'c]] You can create a calling function g: g: refine-func [/a /b /c] [ call-with-refine f refinements ] Such that: >> g == false >> g/a a == false >> g/b b == false >> g/c c == false Here are the two functions refine-func and call-with-refine: refine-func: func [spec body /local refinements] [ refinements: make block! length? spec foreach word spec [ if all [ refinement? word word <> /local ] [ append refinements to word! word ] ] insert body compose/deep [ refinements: make block! 0 foreach word [(refinements)] [ if get :word [ append refinements word ] ] ] either found? find spec /local [ append spec 'refinements ][ append spec [/local refinements] ] return func spec body ] call-with-refine: func [:f ref-block [block!] /local g] [ g: make path! compose [f (ref-block)] g ] Oh, by the way, the function defined as g: refine-func [/a /b /c] [ call-with-refine f refinements ] ends up looking like this: >> source g g: func [/a /b /c /local refinements][ refinements: make block! 0 foreach word [a b c] [ if get :word [append refinements word]] call-with-refine f refinements] >> At 12:50 PM 5/24/00 -0700, you wrote: >A while back a message was posted to the list (can't find it now) about >wanting to loop on the refinements specified to a function, without an 'if >for each one. I've finally come up with a reason to do something similar: I >want to pass all of the given refinements to another function. That is: > >- I call func A, giving some refinements >- func A calls func B with all of the refinements given to func A > >I have been doing the 'if thing on each possible refinent of A and >performing a different (hard-coded) call of B with each different >refinement, but this would get messy if I were to specify more than one >refinement at a time. I have found an "automatic" way of building the >funcname/refinement string, but I haven't found any "slick" way of doing it. >BTW the code below could be improved by recognizing only refinement! from >the first func block. However, I haven't decided whether I even want to use >it. > >f1: function [/a /b /c][local1 local2 local3][ > ; Calls function F2 with the refinements given to this function > ; MUST define [local1 local2 local3] (exactly) as locals to this >function > local3: :f1 > do bind refine 'local1 > do join "f2" local1 >] > >f2: func [/a /b /c][if a [print "a"] if b [print "b"] if c [print "c"]] > >; Then, somewhere in the code specify the block: >refine: [ > local1: make string! length? first :local3 > ; Assume that no other parameters were specified > repeat local2 length? first :local3 [ > if true = get bind to-word pick first :local3 local2 'local1 > [append local1 join "/" pick first :local3 local2] > ] >] > >; Example use: >>> f1/b >b >== none >>> f1/b/c >b >c >- Michael Jelinek > > > ;- Elan >> [: - )]
[REBOL] [REBOL]hidden variables in objects? Re:
Hi Tim, hiding words in REBOL is independent of objects and facilitated by the 'use context. The 'use context can be used in objects. The 'use native is used to create a context in which words are hidden: use [ a b c ] [ a: 1 b: 2 c: 3 ] object: make object! [ a: none b: none use [a b] [ a: "this is the hidden a" b: "this is the hidden b" ] ] If we probe the object we find that the words in the use context are not exposed: >> probe object make object! [ a: none b: none ] At 09:20 AM 5/24/00 -0800, you wrote: >I am presently reviewing a presentation on rebol >made by a third party. It is good to see that rebol >is getting some exposure. > >I need to verify something stated in this presentation: >Can there be "hidden variables" in a rebol object. > >I.E. would these by like private variables/methods >in C++; > >I'd appreciate the informed word on this. > >Thanks >Tim > > > ;- Elan >> [: - )]
[REBOL] [REBOL] [REBOL] Default Port Values? Amended Re:
Hi Tim, A) Initiliazing Words? why do you want to initialize the word port to some value before opening it? Let us assume you did NOT initialize it. Then there are three possible states for the word port. It does not exist yet, because the port has not been opened. You can check for this condition using value? >> value? 'port == false once the word port has been assigned to some value? 'port returns true. This value could be an open port! or something else. Second condition is port has been opened. Third condition is port has been closed. Note that when a port has been closed, it still qualifies as a value of type port!. Trying to read from or write to a closed port will generate an error. (Maybe that is the source of some of your errors? Can have you been trying to read from or write to a closed port, because the port was not none?) 3 -> 2 You may want to reduce complexity by dealing with two port states: exists or open. Then, whenever you close a port, use unset to get rid of the word. Instead of using the close function, you use the following shut function that does it for you: shut: func ['port] [ if port? get port [ close get port unset port ] ] >> value? 'port == false >> port: open %file >> value? 'port == true >> shut port >> value? 'port == false Of course it's more port-like (portly?) to ask the port if its open, instead of asking it if it exists. Also, if it exists, it better reference a port! value. Let's do that: open?: func ['port] [ return all [ value? port port? get port ] ] >> open? port == false >> port: open %file >> open? port == true >> shut port >> open? port == false Using the three functions open?, open, and shut consistently, instead of using close will narrow words referencing ports to two states. If open? port returns true, then the word port is pointing at an open port that was opened using open. If open? port is false, then there is no word port and - if port previously referenced an open port - then that port has been closed. For instance you would say: if open? port [safe-close port] and by having used open? you would be guaranteed that that the port you are passing to safe-close is an open port, not some other type of value, not a closed port, and it exists. 3 -> 5? When you initialize port to some non-port value, you are introducing a fourth and a fifth state for the word port, in addition to the three default states. Besides being 1. existent/non-existent 2. open 3. closed the word port can now also be 4. none 5. a type that is not port!. (namely none!) 1. A function may fail because it expects a port! type value, BUT it is passed the word port when it references the value none, i.e. a none! type value. 2. A function may fail because the having checked for none, it determines that the value of port is NOT none, and it now attempts to access the port. BUT the port - even though it is not none - is closed, not open, and accessing it generates an error message. My personal preference is to reduce complexity. Two states suits me better than five. If I thought that declaring values before using them is important, I would certainly prefer none over an empty block. A value set to none can easily be identified using if or either, because none evaluates to a logical false value. An empty block evaluates to a logical true value. It complicates matters. With respect to your example code, be sure to use a uniform function interface. It does not help you, if you test for the types of arguments occassionally and not consistently. In the following example you note that once you do and once you don't get an error message. Apparently you overlooked that in one function you are checking for the type of the argument being passed and in the other version of the function you do not: argument is type checked here: | | With type checking:safe-close: func [p[port!]][if p [close p]] Without type checking: safe-close: func [p][if p <> [] [close p]] | | No type checking here You comment saying: lets say dufus: none safe-close dufus generates Script Error: safe-close expected p argument of type: port The error message is reporting that your safe-close function is checking for the type of the passed argument. You require that the argument be of type port! safe-close: func [p [port!]] ... but you are passing a value of type none! Therefore you get the error message. You would be getting the same error message, if you used [] instead of none with this version of the safe-close function, because you would be passing a value of type block!, while this version of safe-close expects a value of type port!. block! <> port! >>> HOWEVER: if I
[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] 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] [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] installing Rebol as CGI application under PWS/Win32 Re:
Hi Christian, PWS is a little weird. I don't recall that anyone was able to successfully install REBOL as a CGI client under PWS (may have missed it), whereas I do recall periodically seeing messages that complain about PWS. My recommendation: use Apache. You can download your free copy of Apache from http://www.apache.org. If you have problems getting Apache to run, let me know. I have an old email that describes Apache configuration under MS Windows. At 04:36 PM 5/21/00 +0200, you wrote: >Hello, > >I am having a problem installing Rebol under PWS. In the registry, I added a >key ".r" under >HKLM/System/CurrentControlSet/Services/W3SVC/Parameters/Scriptmap with the >value "c:\rebol\rebol.exe -cs %s %s" >Now when I place a .r file into my cgi-bin directory and try to call it, I >always get the message that the script returned incomplete headers. I also >tried to output "Content-type: text/html" manually, but this didn't change >the result. Any pointers? > >Regards >Christian > > > > > ;- Elan >> [: - )]
[REBOL] probe object Re:
Hi, you wrote: >I have a set of functions which turn the contents of an e-mail message >object into a different object (called "article.") > > article: make object! [ > headline: subject-pieces/1 > subheadline: subject-pieces/2 > body: content-pieces > ] > >I'm trying to figure out how to probe the object and then write the >result of the probe out to a file for inclusion at a later date. Why don't you use save? >> save article will write the object to a file. Later you can read or load it back. In either case you will have to either do the result of reading the file, to convert the string (read) or block (load) to an object: retrieved-article: do read %article.txt retrieved-article: do load %article.txt Another option is to use >> write filename mold object Same result as saving the object. ;- Elan >> [: - )]
[REBOL] Mailing Address Parse Re:
Hi myers, is this a parsing *problem*? IMHO the problem consists of several aspects: a) defining all possible formats for address variants; b) providing alternative parsing rules for the different formats (the example formats suggest that this would be quite trivial); c) each of the different format parse rules collects address data and uses it to fill out a standard address object; d) the generated address objects are compared, duplicate objects are identified and processed (removed?). At 06:49 AM 5/19/00 -0400, you wrote: > Have any of the parsing experts spent any time with the parsing of >mailing addresses e.g. recognizing that234-500 Main Street >Centertown, Maryland USA 12345 is the same as: 500 Main St. Apartment >234 Centertown, Maryland 12345 US and500 Main St Apt 234 Centertown, >MD USA 12345 andUnit 234 500 Main Centertown MD USA 12345 by >parsing to add standard address format that might be something like >unit type, unit number, street number, street name, city, state/province, >country, zip/postal code There are apparently lots of variants with >different unit types acceptable and multilingual versions of most >everything. ;- Elan >> [: - )]
[REBOL] Suppressing == false Re:(5)
Hi Tim, you wrote: >Hello Allies: >I gotta say it: extra verbiage is not simplicity. It would >cause a client of mine alarm, and that ain't simple >Wouldn't take a lot of code to give an option to suppress... >but what the hey - >I modified Michael's idea of ending the script with a true >and ended it with prin "" Why not use a roll-your-own if replacement? _if: :if if: func [condition block [block!] /quiet /local result] [ result: _if condition block either quiet [ exit ][ return result ] ] >> if false ["Will return false."] == false >> if/quiet false ["Will NOT return anything."] >> Note that you cannot redefine if UNLESS you preserve its original behavior as the new, reassigned if's default behavior, because there are some mezzanine functions that expect if to return some value. These functions may fail if your reassigned if does not act as they expect. That's why my reassigned if preserves the behavior of REBOL's original if as its own default behavior when it is called without the /quiet refinement. The mezzanine functions will be served the result they expect. >That shut the sucker up! >Thanks As Always :>) Tim > >At 08:22 AM 5/18/00 -0700, you wrote: >>You all DO understand WHY "== false" is being displayed in the interpreter >>(for an 'if statement), right? Gabrielle said it best, who deserves to be >>quoted on the rebol.com site: "...This is the thing about REBOL --- >>everything is simple by design; so if something looks unintuitive, it's just >>because simplicity is not always intuitive. :)" >> >>'if returns a value, just like most other REBOL words/functions/statements. >>'if first evaluates the given condition (producing a value of 'true or >>'false); when the condition is 'true, 'if "then" evaluates the block (also >>producing a value). The value of 'if is therefore taken from the value of >>either the condition or the value of the block. To change this would add >>complexity. >> >>BTW I end all of my REBOL modules with the word 'true, just so that I don't >>get some arbitrary value displayed when loading it. Seeing "== true" after >>loading a module is somehow pleasing. >> >>- Michael Jelinek >> >>-Original Message- >>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] >>Sent: Wednesday, May 17, 2000 8:40 PM >>To: [EMAIL PROTECTED] >>Subject: [REBOL] Suppressing == false Re:(2) >> >> >>Tim wrote: >>> I get "== false" in the output. >>> How do I get rid of that? >> >>The best way currently, is to swap the 'if for a 'either. >> >>I, too, would like rebol to get rid of the 'false returned by a 'if not >>taken. >> >>Andrew Martin >>ICQ: 26227169 >>http://members.xoom.com/AndrewMartin/ >>-><- >> >> > > > ;- Elan >> [: - )]
[REBOL] CGI Error Re:(3)
Hi Louis, a little off-topic, but it is more efficient to collect your output in a string and print the complete string in one go, using a single call to print. Like so: output: make string! 1000 insert output {Content-Type: text/html^/^/ Results:} cgi: make system/standard/email decode-cgi system/options/cgi/query-string either all [ email? try [cgi/to: load cgi/to] email? try [cgi/from: load cgi/from] ][ append output " Sending Email to cgi/to " send/header cgi/to cgi/content cgi ][ append output "Invalid email to or from address" ] print [output ""] At 07:32 PM 5/17/00 -0500, you wrote: >Here's the script: > >#!rebol -cs > >REBOL [ > Title: "Sends Email via CGI Form" > Date: 20-July-1999 > File: %cgiemailer.r > Purpose: { > Uses a Web form to send an email message. > } >] > >print "Content-Type: text/html^/^/" ;-- Required Page Header > >print "Results:" > >cgi: make system/standard/email decode-cgi system/options/cgi/query-string > >either all [ > email? try [cgi/to: load cgi/to] > email? try [cgi/from: load cgi/from] >][ > print [ "Sending Email to" cgi/to ] > send/header cgi/to cgi/content cgi >][ > print "Invalid email to or from address" >] > >print "" > >And here is the HTML: > > > > > > > untitled > > > > >http://worldmerchantltd.com/www/cgi-bin/cgiemailer.r" >METHOD="GET"> >Send an Email Message: > > > > > To: > > > > > > From: > > > > > > Subject: > > > > > > Message: > > > > > > > > > > > > > >At 04:07 PM 5/17/00 -0700, you wrote: >>Louis wrote: >> > CGI Error >> > The specified CGI application misbehaved by not returning a complete >> set of >> > HTTP headers. The headers it did return are: >> >>Is your script printing a Content-type header as the first thing it >>does, followed by a blank line? >> >>print "Content-type: text/html^/^/" >> >>Kev >> >> >>Kevin McKinnon, Network Engineer [EMAIL PROTECTED] >>Sunshine Communications http://www.sunshinecable.com >> >>PGP Public Key: http://www.dockmaster.net/pgp.html PGP 6.0 www.pgp.com > > > ;- Elan >> [: - )]
[REBOL] CGI Error Re:
Hi Louis, you wrote: >I'm having trouble getting set up. What is causing the following error >message? I it caused by me or my ISP? > >Many thanks in advance. >Louis > >CGI Error >The specified CGI application misbehaved by not returning a complete set of >HTTP headers. The headers it did return are: If this is the complete error message, then the Content-type: text/html is not being reported. Provided that your script does print the string Content-type: text/html before it outputs anything else, at least that string should appear in the reported headers. If the first thing being printed by your script is the Content-type ... thing, and the error you report is the complete text of the error reported by your ISP, then at least something is wrong with their error reporting mechanism. 1. Perhaps their error reporting mechanism has a bug and is suppressing the Content-type header? 2. Or their bug is that they are missing the Content-type header you are printing, and therefore they report that they did not receive any headers? 3. Perhaps they should not be displaying an error at all? 4. Perhaps something is wrong with your configuration on their machine and therefore the Content-type header you are printing is not reported to them? Do you happen to know their configuration? What OS are they using? Webserver? ;- Elan >> [: - )]
[REBOL] [REBOL]Finding characters in strings/Comparing Re:
Hi Tim, you wrote: [...] >I would love to see some input and discussion as to what >is the most efficient of the three functions. [...] If you compare char-pos1 to char-pos2 then the only difference is that char-pos2 adds a call to found? to char-pos1. It's probably safe to speculate that char-pos1 should be more efficient. if you accept that, then the field is narrowed down to char-pos1 vs. char-pos0. You can speculate about these two, but without knowing the implementation details of all, any and either, the degree of confidence in the result of this speculation is a little lower. As a matter of principle, either accomplishes what the combined any and all accomplish. At face value I tend to think that char-pos1 should be more efficient, since it consists of one (native) function call, where the combination all/any requires two function calls. I doubt that any and all's implementations can be that much more efficient than either's implementation, that parsing and calling any and all would still be more efficient than a single parse/call to either. If you compare this speculation to some (inaccurate) measurements, I appear to be on the right track: >> start: now/time loop 100 [char-pos0 s c] print now/time - start 0:00:46 >> start: now/time loop 100 [char-pos1 s c] print now/time - start 0:00:42 >> start: now/time loop 100 [char-pos2 s c] print now/time - start 0:00:54 >I wouldn't consider readability to be an issue, because >this would not be a function that would need any maintenance. > >Here goes: >char-pos0: func [str [string!] ch [char!] /ndx] >[ > any[all [ndx: find/case str ch index? ndx] 0] >] >char-pos1: func [str[string!] ch[char!] /local result] >[ > either result: find/case str ch [index? result] [0] >] >char-pos2: func [str[string!] ch[char!] /local result] >[ > either found? result: find/case str ch [index? result][0] >] > > > ;- Elan >> [: - )]
[REBOL] Question on Wait Re:
Help wait agrees with your observation. It reports >> help wait ARGUMENTS: value -- (Type: number time port block) No mention of date. At 10:46 AM 5/9/00 -0800, you wrote: >Hello, > >The following is taken from the Rebol Dictionary, describing WAIT. > > >If the value is a TIME, delay for that period. >If the value is a DATE/TIME, wait until that DATE/TIME. >If the value is an INTEGER or DECIMAL, wait that number of seconds. > > >Testing with TIME and INTEGER works fine. > > >>> forever [print now/time wait 60 print now/time break ] >10:18:33 >10:19:33 >>> forever [print now/time wait 00:01:30 print now/time break ] >10:20:12 >10:21:43 > >However when i try to specify a DATE/TIME, i get the following > > >>> forever [print now/time wait 9-May-2000/10:30:00 print now/time break ] >10:24:08 >** Script Error: wait expected value argument of type: number time port >block. > >The error seems to suggest that WAIT only expects a TIME and not a DATE? >Am i missing something? > >Thanks. > >Mike. > > > > > ;- Elan >> [: - )]
[REBOL] two-digit return of now switches Re:(3)
Hi RChristiansen, you wrote: >This doesn't work... > >month: to-string now/month >if (length? month < 2) [insert month "0"] > >** Script Error: Expected one of: string! - not: integer!. >** Where: if (length? month < 2) [insert month "0"] Try: >> if (length? month) < 2 [insert month "0"] == "5" >How come? Since you ask: 1. < is polymorph: String comparison: >> "1" < "2" == true When the left argument to < is of type string, < expects the right argument to be of type string as well. 2. Precedence: The < is evaluated first, then the length? operator. Example: >> "123" < "1234" == true >> length? "123" < "1234" ** Script Error: length? expected series argument of type: series port tuple. ** Where: length? "123" < "1234" What's the complaint? First "123" < "1234" is evaluated and returns true. Then length? is applied to true. We are applying length? here to a boolean value. Accordingly, this does not work: >> length? "123" < 10 ** Script Error: Expected one of: string! - not: integer!. ** Where: length? "123" < 10 Precedence, < is applied before length? Polymorphism, < detects that its left argument is a string, and therefore expects the right argument to be a string as well. But this does work, because we force length? to be applied first and < detects an integer left and expects an integer as its right argument: >> (length? "123") < 10 == true ;- Elan >> [: - )]
[REBOL] tuple math Re:
Hi Bob, since make tuple! [1] generates 1.0.0, I think that a good way of handling it would be to change the highest order. >> make tuple! "1" == 1.0.0 >> make tuple! [1] == 1.0.0 Elan At 03:38 AM 5/8/00 +, you wrote: > REBOL 2.2.0.4.2 >... > >>> a: 192.9.200.211 >== 192.9.200.211 >>> a + 1 >== 193.10.201.212 > > >what justification is there to changing >-all- the integer fields? I expected at most to >change either the highest order or the lowest order >integer field by this operation - not all of them. > > >>> a: 192.9.255.1 >== 192.9.255.1 >>> a + 1 >== 193.10.255.2 >>> a + 0.0.1.0 >== 192.9.255.1 > >humm, neither of these does what I expected. >What I was looking for was some form of carry propagation. > > >Now there are 2 contexts that I consider using tuples for: >IP addrs and version numbers. I would welcome the list to show >some alternate uses for them. [big math like bigint seems out -- too bad] > >As internet addresses, I can reasonably stay away >from adding + 1 and instead use 0.0.0.1 to get the next higher IP >addr to try. The lack of carry is probably not going to be discovered >by other programmers using them for IP because 255 becomes a >broadcast address in most systems so logic is likely >in place [I hope others remember to look...] before this value >is taken on. > >no wrap or carry? >My gut tells me it is wrong to have to check >my results after every addition. > >so here is what I am looking for: >- an example of a use for the current behavior which warrants >adding math checks to all other uses. > > > > >;# mailto: [EMAIL PROTECTED] > > > ;- Elan >> [: - )]
[REBOL] Endless looping processes. Re:(3)
Hi, hitting the Escape key (conveniently labeled Esc on my 10 function key version of the AT IBM keyboard), will stop a running REBOL script. (Note that if the script is waiting for a response from some remote computer, i.e. when you use ftp for instance, it may take a time until REBOL evaluates the keyboard input and the excape key is detected.) Example: Here's an endless loop: >> forever [] which terminates when I hit the escape key: >> forever [] >> At 10:52 AM 5/7/00 -0700, you wrote: >REBOL/view 3 won't stop by pressing "enter" or any control combination I >tried. I had to use "control-alt-delete" in Win98 SE, which offers the >option of stopping REBOL. I seem to remember an early version of REBOL/core >having some key combination to stop runaway loops, but I don't remember what >it was. > >Russell [EMAIL PROTECTED] >- Original Message - >From: <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]> >Sent: Sunday, May 07, 2000 10:26 AM >Subject: [REBOL] Endless looping processes. Re: > > >> >> >> [EMAIL PROTECTED] wrote: >> >> > Dear rebol-list, >> > >> > I recently started using Rebol on my WebServer, and it works very >> > nice, I'm nearly done with a script that checks if domains are taken or >> > not at different whois servers. >> > >> > But anyway.. to the point. >> > >> > Yesterday I was writing some new things, and due to that I'm not >> > entirely into the Rebol language yet I make some typos and stuff. >> > >> > I wanted to find the last "." of a string, I cannot remember exactly >> > the code but i took it from the "Core users guide". >> >> find/last string "." >> >> > Yes, the point.. This function made a endless loop and printed lots of >> > lines with "." on, >> >> what function please? Could you post it's code, please? >> >> > this did not stop, and I pressed "Stop" in >> > Netscape. >> >> well, known thing - pressing Stop in Netscape very often doesn't mean >> Netscape will stop :-))) >> >> > Only later i found that for every endless loop I left a >> > Rebol.exe running on the server (NT) taking about 30% CPU time, and >> > the server was crawling. >> > >> > Windows NT will not let me kill these processes, and they did not seem >> > to stop. >> > >> > Is it possible to kill a rebol process? >> >> That's not question related to rebol, right? If you can't kill NT process, >> then how to stop infinite loop? >> >> > Or can I stop a script that is running from the console or something ? >> >> What console? Rebol one? Just press enter. If you are talking about NT >> console, then some NT folks will give you surely an answer ... >> >> > Thanks for the time, hoping for answer. >> >> You are welcome ... >> >> -pekr- >> >> > Regards, Fredrik Bergstrom >> > >> > -- >> > PowerWebs AB >> > Wåxnäsgatan 10 >> > S-653 40 Karlstad >> > Sweden >> > Tel: +46-(0)54-103377 >> > Fax: +46-(0)54-103376 >> > ICQ# 7654213 >> > > > ;- Elan >> [: - )]
[REBOL] how can i... Re:
Hi -= usaps jeronimo =-, there are two ways your CGI script can receive form input. Through the input function or through system/options/cgi/query-string. Which is used depends on whether the form submits its data using GET or POST. Only when GET is used the form's data becomes available in system/options/cgi/query-string. If PUT is used you must use input. Which request method was used can be determined by retrieving the value of system/options/cgi/request-method. There is a function available on www.rebol.org user contributed scripts that automates that automates the process. At 05:37 PM 4/17/00 +0200, you wrote: > >hi! everybody... i'm really new in this stuff. > >i'm trying to make rebol work with html forms, an the thing is: > >** Script Error: decode-cgi expected args argument of type: any-string. ** >Where: cgi: make object! >decode-cgi system/options/cgi/query-string > >i cannot go futher, from this error... > >if i ask the value for: >system/options/cgi/query-string > >is equal to none (but i don't know what value i need) > > >can somebody help me! > >thank in advance. > >-- > >-= usaps jeronimo =- > > > > > > ;- Elan >> [: - )]
[REBOL] webbanner.r help Re:(3)
Hi Ryan, you wrote: >OK, so in the following function... > >make-banner: func [/ad adnumber /local url img alt] [ >set [url img alt] skip banner-db either ad [ >adnumber - 1 * 6 >][ >random (length? banner-db) / 6 >] >rejoin [{target"_blank">}] >] > >...how does adnumber get its value and what is the purpose of the >adnumber word? > Function specification: when you specify a refinement in a function - /ad - then you can associate an argument with that refinement - adnumber. The make-banner function can be called either without a refinement and without an argument, or with the refinement /ad, in which case you must supply an argument for adnumber. The argument adnumber is initialized to the value with which you call make-banner, when you call make-banner with the /ad refinement: make-banner ;- no refinement, no argument make-banner/ad 6 ;- with refinement, with argument The role of adnumber. The function subtracts 1 from the adnumber and mutliplies the result with 3 (not 6 as in your example!). The value 3 is the length of each record in the block. The adnumber which is passed to make-banner is index of the first field of the record. Since the function uses skip to locate the three fields it wants to use - url, img alt - you must subtract 1 from the index. If the function is called with the index 1, the first record in the block (consisting of three fields) has to be displayed. The skip function will skip (adnumber = ) 1 * 3 (= record length) = 3 fields. That would position you at the second record. So you subtract 1 (adnumber =) 1 - 1 * 3 (=record length) 1-1 * 3 = 0 * 3 = 0. You skip 0 fields and set [url img alt] will set the three local variables to the first three fields in the block. The url word will be set to the url of the site, the img will be set to the path of the image that is to be displayed, and will set to the string which is displayed while the image is being loaded, or continues to be displayed if loading the image fails. When you call make-banner/ad 2, you want to displaye the second record. 2 - 1 * 3 = 1 * 3 = 3 The skip function will skip 3 fields and s et will load the three local variables to the three fields beginning at the fourth field, which is the url of the second Web site, followed the image file's path, followed by the string that is displayed by the Web browser as the alt string. BTW, all arguments that precede any optional refinements are mandatory arguments, arguments that follow refinements are associated with their respective refinement, until another refinement is detected, or until the /local word is detected which introduces words that are local to the function. f: func [mandatory-arg-1 mandatory-arg-2 /refinement refinement-arg /local local-word] [ do-something-real-smart-here ] This function may be called with two arguments f arg-1 arg-2 or with two arguments, the refinement, and a third argument associated with the refinement: f/refinement mandator-arg-1 mandatatory-arg-2 refinement-arg Hope this helps, ;- Elan >> [: - )]
[REBOL] webbanner.r help Re:
Hi Ryan, you wrote: >Original (with three urls in the block) > >adnumber - 1 * 3 >random (length? banner-db) / 3 >make-banner/ad 3] > >My changes (with six urls in the block) > >adnumber - 1 * 6 >random (length? banner-db) / 6 >make-banner/ad 6] > The 3 in adnumber - 1 * 3, that 3 does not stand for number of entries in the database. It stands for the length of a database entry, i.e. each entry in the database consists of three items: > http://www.schonder.com %/graphics/bannerads/schonder.gif > "Papier-Schonder KG office supply and bookstore" 1. the url: http://www.schonder.com 2. the banner file: %/graphics/bannerads/schonder.gif 3. the accomapnying text: "Papier-Schonder KG office supply and bookstore" You added 3 more companies, fine, you therefotr changed 3 to 6 in your call to make-banner/ad 6, that's fine, but you now have 18 entries in the database, six records of length 3 each, and not 36 entries. But when you call make-banner with the ad refinement, get adnumber - 1 * 6 is 6 - 1 * 6 = 30. No wonder you get none. ;- Elan >> [: - )]
[REBOL] Dumb Question Re:
At 06:33 PM 4/14/00 -0400, you wrote: >I installed Rebol on a Slackware system in its own directory under >/usr/local/src. I made a link to it from /usr/local/bin. >At the command line, I typed 'export REBEL_HOME=/usr/local/src/rebol' > Perhaps replacing export REBEL_HOME=/usr/local/src/rebol by export REBOL_HOME=/usr/local/src/rebol will help (note the capital O instead of the second capital E)? ;- Elan >> [: - )]
[REBOL] Vanilla sample-space Re:
I did download your earlier version (it needed a little more configuration than I expected). Why not package it in the REBOL rip compressed archive format? At 09:53 PM 4/11/00 +0200, you wrote: >Hi folks, > >since Vanilla is a lil' bit awkward to deploy at the moment (eventually, >it should be download-doubleclick-deploy kind of thing, but for now it >certainly isn't), I've set up a 'playground' at > >http://iw2.infowerk.co.at/cgi-bin/vanilla.r?selector=display&snip=playground > >I'm sure that there are still bright people on this world (and maybe >even on this list) who haven't been exposed to the wiki principle yet. >Everyone edits everything. It's human. There may be vandals, but usually >we know how to behave. > >Over the next few days I'll enhance the extension script capability of >Vanilla, so that it will become possible to write full-fledged web >applications with it. DynaSnip-caching is waiting, too. And WML >rendering. And a 'history' aka revision control facility. Lots of >things, some even exciting. Get in touch. > >Enjoy! > >Chris Langreiter > >_ >c h r i s langreiter - - - unterlangkampfen 3 2 7 >f o r m is function -- autriche 6322 langkampfen >0 0 4 3 / (0) 5 3 3 2 / 8 7 6 0 7 c a l l - n o w >w w w . l a n g r e i t e r . c o m > >There are three kinds of lies: >lies, damn lies, and statistics. >--Benjamin Disraeli > > > > ;- Elan >> [: - )]
[REBOL] fun with 'switch Re:
Hi Michael, 1. The Problem 2. The Solution 1. The Problem: >>> retval: curr-func >>> switch retval [none [print "val-none"] "abort" [print "val-abort"]] >== none > >Notice that the == none is the value returned from 'switch, not the >execution of the none block. To further illustrate: The reason it didn't work is that the none in a block, [none], is a value of type word! the none "as we know and love it" is a value of type none!: >> type? first [none] == word! >> type? none == none! The none in brackets is not an evaluated none. Evaluation makes the word none a value-of-type-none! none. >> type? do [none] == none! >> type? do first [none] == none! The same is true for other values/words such as false, true, on, off. 2. The Solution: You can do or reduce (you get the value, or a block containing the value:) >> type? first reduce [none] == none! >> type? do [none] == none! To apply it to your problem. Simply reduce the block you pass to switch: >> retval: none == none >> switch retval reduce [none [print "val-none"] "abort" [print "val-abort"]] val-none Hope this helps, ;- Elan >> [: - )]
[REBOL] [REBOL] Redefining functions with objects Re:
Hi Tim, >Will >tims-object/print >redefine rebol's own print? > Within tims-object print replaces the global print, which you can continue to access using system/words/print >> tims-object: make object! [ print: func [][ system/words/print "this is the global print." ] ] >> tims-object/print this is the global print. Outside of the object's context print is not affected by your re-definition of print in the object. ;- Elan >> [: - )]
[REBOL] first second third ... last Re:
Indeed, that would be more graceful. At 07:11 PM 4/11/00 +1200, you wrote: >Elan wrote (in another thread): >> Note that pick is safer, it will return none if parse returns none or if >parse returns an empty block, whereas first will fail with an error >exception in both cases. > >'second, 'third and so on do the same as well as 'last. I'm of the opinion >that these functions should return 'none instead. So instead of: > >>> first [] >** Script Error: Out of range or past end. >** Where: first [] > >they should return: > >>> first [] >== none > >YMMV. > >Andrew Martin >"Move along now, nothing to see here." >ICQ: 26227169 >http://members.xoom.com/AndrewMartin/ >-><- > > > ;- Elan >> [: - )]
[REBOL] [REBOL]string to series function Re:(4)
At 09:55 PM 4/10/00 -0700, you wrote: > >Fair enough. >I have little time to give a complete course on parse so I went for >the shortest version. Yikes! Of course. I was worried that tim may eventually want to exclude spaces from his parse rule, and then he'd be frustrated, because he wouldn't know how to control space parsing. (Actually, I'd already written my response, and before I sent it off I checked my email to avoid duplicate answers, and lo and behold, there was your message. But I'd chosen a slightly different approach, and I thought it was still worth mentioning it ...) So he gets more than he asked for ;-). >I expected to see a few other responses to this >thread as well and sure enough the old-time REBOL-masters of the >outside world give a more full answer than us insiders have time for. Time? I have time? ... Me? > >Take it easy guys, >Sterling > You to Sterling. ;- Elan >> [: - )]
[REBOL] [REBOL]string to series function Re:(3)
Hi tim, just-one: pick parse/all "one#two%three four" "#% " 1 or just-one: first parse/all "one#two%three four" "#% " or, if want to continue collecting the complete block in my-series: just-one: pick my-series: parse/all "one#two%three four" "#% " 1 and just-one: first my-series: parse/all "one#two%three four" "#% " Note that pick is safer, it will return none if parse returns none or if parse returns an empty block, whereas first will fail with an error exception in both cases. At 09:07 PM 4/10/00 -0800, you wrote: >Sterling showed me how the following code >gives me a block parse "one#two%three four" "#%" >>== ["one" "two" "three" "four"] > >that's great! Now if I write: >my-series: parse "one#two%three four" "#%" >just-one: my-series/1 >just-one is returned as "one" > >now how do I get "one" into just-one with 1 line >of code instead of two? > >thanks again >tim > > > > ;- Elan >> [: - )]
[REBOL] Using Rebol with HTML templates, reading dynamic data -- is it possible? Re:
Hi Martin, At 11:56 PM 4/10/00 +0200, you wrote: >1. A Rebol script can be used to fetch data from a textfile and put the >data >into a HTML template, thus creating an unique web page? In this way one may >render lots of documents of the same kind, but with unique data, such as a >list of products where each product is linked to a script-generated >information page? That is correct. This can be done offline, i.e. creating static webpages. > >2. A Rebol script can be used in the way above, but on the server side, >reading data from a text file for input to the HTML template. In this way, >Rebol may serve the same function as Visual Basic or Javascript within an >Active Server Page? Absolutely. > >3. Which one of the two above methods is preferred -- rendering unique web >pages with a script or having the script read data "on the fly" thus >providing dynamic web pages? It depends on what you are trying to do, what resources are available on your machine and how many hits you expect to process. As a rule, static Web pages are of course less resource hungry and more stable. I would only use dynamic Web pages if the data changes often enough to justify the additional overhead on the server side. Or if the ratio of expected number of hits vs. the resources available on the machine is ridiculously low. > >I would be really glad to get some ideas on this, and maybe even some code >that I can play around with to learn from. Thanks! > Look at Andrew's HTML Dialect in the archive at www.rebol.org. Hope this helps, ;- Elan >> [: - )]
[REBOL] [REBOL]string to series function Re:(2)
Hi Sterling, one little detail: your approach works well enough with this particular example because space is one of the desired delimiters. Conceivably Tim may want a more universal solution that enables him to determine whether or not he wants to include spaces in his parse rule. In that case IMHO it would be more appropriate to use parse's all refinement and - for the sake of this particular example - include space explicitly as a delimiter in the rule: With space: >> parse/all "one#two%three four" "%# " == ["one" "two" "three" "four"] Without space >> parse/all "one#two%three four" "%#" == ["one" "two" "three four"] Note that the second version returns "three four" as one string because space is not included in the rule. At 09:06 PM 4/10/00 -0700, you wrote: > >You really ought to just try these things. ;) >You'll be surprised at what you find. > >>> parse "one#two%three four" "#%" >== ["one" "two" "three" "four"] >>> > >Sterling > >> I would like to have a function to do >> the following >> 1)take two strings as arguments >> a)arg one is source >> b) arg two is delimiters >> 2)return a series >> >> it would work like this: >> >> my-series: string-to-series "one#two%three four" "#% " >> my-series is returned as ["one" "two" "three" "four"] >> >> BTW: I have a c function that does this. With >> subsequent function calls, it is about 40 lines of >> code. I'm pretty lost when it comes to parse, but >> I bet the rebol function would be shorter. >> thanks >> tim > > > ;- Elan >> [: - )]
[REBOL] Return types Re:(5)
Hi Gisle, note that Gabriele discovered some early hints of work being done on return types in REBOL/View. Possibly there will be some return type handling in future versions of REBOL. At 07:13 PM 4/10/00 +0100, you wrote: > > >On Wed, 5 Apr 2000 [EMAIL PROTECTED] wrote: > >> Hi Gisle, >> >> you wrote: >> >> >Elan's idea of being able to optionally specify return types of a >> >function would be nice >> >> Thank you. I think this email contains a rather complete return type >> enforcer function (further below). > >Thank you ! This will be useful! I didn't think of looking at it from that >perspective. It'll do the job pretty well :) > >Gisle > > > > ;- Elan >> [: - )]
[REBOL] official guide, again Re:
Coming soon. Not available yet. At 07:51 PM 4/9/00 -0500, you wrote: >I see bn.com lists REBOL: The Official Guide as "available" and "ships 1-2 >weeks" Weird. Must be a bug. >while amazon.com says "this title is not yet available." They know what they are talking about. >Meanwhile, >the chapters previously posted in the McGraw-Hill Bet@ Books section are >non-existant. Hmmm, I wonder why. > >Is the book available yet, or not? No, but soon. > >Thanks. > > > ;- Elan >> [: - )]
[REBOL] [REBOL] Reading REBOL header Re:
Hi, try: >> print mold system/script/header The objects fields will all be set to none, unless you do a script first. At 04:37 PM 4/8/00 -0800, you wrote: >According to rebol documentation, the >rebol header is an object. > >If so, how does the rest of the script file >access the header? > >Given the following code: > >REBOL >[ >Title: "Scan Web Sites" >Date: 12-Nov-1997 >Author: ["Ema User" "Wasa Writer"] >] >print REBOL/Title >; the line above generates the error message: >** Script Error: Invalid path value: Title. >** Where: print REBOL/Title > >what would be the correct syntax. >Thanks >Tim > > > ;- Elan >> [: - )]
[REBOL] parse / space Re:(3)
Hi Volker you wrote: At 12:41 PM 4/6/00 +0200, you wrote: >>> parse "LIB1 " ["LIB1"] >== false >>> parse "LIB1 " ["LIB1" to end] >== true >>> parse "LI B1 " ["LIB1" to end] >== false > >result says, could parse full string, or there is a rest, IMO. that is correct and undisputed. According to the documentation parse ignores spaces unless used with the /all refinement. In the example (1) >> parse " LIB1" ["LIB1"] == true I demonstrate that parse w/o /all refinement indeed *ignores* spaces, at least leading spaces. The example (2) >> parse "LIB1 " ["LIB1" (print "found it")] found it == true demonstrates that parse w/o /all also ignores *trailing* spaces. If we leave away the expression (print "found it") and simply do (3) >> parse "LIB1 " ["LIB1"] == false the trailing space is *not* ignored. Why all of a sudden is the trailing space not ignored? Should it be ignored? My position is: In example (3) the trailing space should be ignored, because the pattern matching part of the rule in (3) is no different from the pattern matching part of the rule in (2). Since we are doing the same pattern matching against the same input stream we should be getting the same results. Should (2) return the same results as (3), or should (3) behave like (2)? Since we are using parse without the /all refinement, and parse ignores spaces without the /all refinement, the trailing space should be ignored in (3) as it is being ignored in (2) and the string should be considered completely parsed. My guess is that (3) does not act like (2) because the termination code for parse is incomplete in situation (3). How do (2) and (3) differ? In (2) the rule block is *not* exhausted with the "LIB1" pattern. In (3) it is. When parse encounters the trailing space, it still has something remaining in the rule block, namely (print "found it"). This means that empty? rule-block at this point will return false. Since there's still something remaining in the rule block, parse continues to evaluate the rule-block. In doing so, it returns to a part of the parse code that is ignore-spaces-aware. In (3) the rule block is exhausted with the "LIB1" pattern. empty? rule-block returns true and parse returns false because it has not reached the end of the input stream, but it has already exhausted its rules. That is an incorrect termination, since we are using parse without the /all refinement, and parse should determine whether or not all remaining characters in the input stream are spaces, before it decides whether to return true or false. If only spaces remain, - and in our example that is the case - parse should report true, just as it did in (2). ;- Elan >> [: - )]
[REBOL] parse / space Re:
Hi bciceron, The short version is: I believe it's a bug. The long version: space at the begining of string: >> parse " LIB1" ["LIB1"] == true space smack in the middle of token: >> parse "LI B1" ["LIB1"] == false Now, that somehow makes sense. If I am parsing for the token LIB1 I do not want the two tokens "LI" and "B1" separated by anything - including a space - to qualify. Otherwise I should make white spaces separating "LI" and "B1" part of my rule. >> parse "LIB1 " ["LIB1"] == false Apparently "LIB1 " with a trailing space is treated like "LI B1" with a space separating two parts of the token. That space is not being ignored. I think that's a parse bug and should be reported as such. The trailing space should be ignored. That's because: SPACE NOT IGNORED: >> parse "LIB1 " ["LIB1"] == false SPACE IS IGNORED: >> parse "LIB1 " ["LIB1"(print "found it")] found it == true Note that I did not change the rule that determines which tokens are recognized! I only added an instruction to print "found it" when the token has been recognized. Since the token to be recognized has not changed, and the string being parsed has not changed, the two previous cases should evaluate to the same thing. Here's another example: >> parse "LIB1 " [some ["LIB1"]] == true Here I permit multiple occurences of "LIB1" in the input stream. Again the trailing space is ignored. My guess is that the parser does something like this: 1. Is the current character in the input stream identical to the current character in the token? 2. Answer to 1: No. Am I ignoring spaces and current character in input stream is character? If Yes: increment input stream index. Reset token index to beginning. Return to 1. If No: Return false 3. Answer to 1: Yes. Then Increment input stream index, increment token index 4. Is the token index exhausted? Yes. Check input stream index: 5. Is there anymore stuff left in the input stream? Yes. 6. Are there anymore rules left? No. 7. Report false. Instead, 7 should be 7. Am I ingoring spaces? Yes. Then 8. Do I encounter only spaces until string index is exhausted? 9. If 8. evaluates to YES: return true If 8. evaluates to NO: return false Until this is repaired you may want to go with the some version of lib-type, i.e. >> lib-type: [some ["LIB1" | "LIB2"] ] == [some ["LIB1" | "LIB2"]] >> parse "LIB1 " lib-type == true Hope this helps. At 12:41 PM 4/5/00 -0500, you wrote: > >parse is very powerfull but still kills me with spacer: > >>> parse "asergd" lib-name >== true >>> parse "LIB1" lib-type >== true > >so the 2 elements matches the 2 single rules. >but pout together they don't : > >>> parse "asergd LIB1" [lib-name lib-type] >== false >>> probe parse "asergd LIB1" [lib-name lib-type] >false >== false >>> parse/all "asergd LIB1" [lib-name lib-type] >== false > >but the white space means trouble: > >>> parse/all "asergd LIB1" [lib-name " " lib-type] >== true > >why one matches with extra white space and not the other ? >>> parse "LIB1 " lib-type >== false >>> parse "asergd " lib-name >== true >>> parse " asergd " lib-name >== true > >lib-name: [name] >name: [ some symbol ] >lib-type: [ "LIB1" | "LIB2" ] >symbol: charset [#"0" - #"9" #"A" - #"Z" #"a" - >#"z" #"." #"-" #"_" #"$" #"+" ] > > > > > ;- Elan >> [: - )]
[REBOL] Return types Re:(3)
Hi Gisle, you wrote: >Elan's idea of being able to optionally specify return types of a >function would be nice Thank you. I think this email contains a rather complete return type enforcer function (further below). >provided that all natives that can >return more than one type used it. This is not how I meant it. An optional return type specifier would be used by the programmer who implements his own functions and wishes to prescribe legal return types for his function. Here's an example for what I mean: This works: >> x f email@ connecting to: ... This generates an error identifying the function f as the culprit: >> x f ftp:// ** Script Error: Expected one of: return type: [email!] - not: url!. ** Where: f ftp:// Let me explain (and demonstrate below): The return type specifier is not intended to announce which types will be returned. Rather, it is meant to exclude certain, unlisted, types from being returned and - instead of returning them - it will alert you to the fact your function is returning an unexpected type that you have outlawed in your return type specification block. What's that good for? In a world in which functions have polymorphic return values, you may be returning values from one function that are subsequently handled by a chain of other functions *without* complaints - those functions have polymorphic parameters - until some point in time in which a function does not support that datatype. It is probably time consuming to detect where in your code that value originates, since in our scenario the immediate suspect, the function that evaluated the failed expression, is not to blame. Let me illustrate with a simple example. Given the functions f, and x: f: func [value] [ return join value ["site.com"] ] x: func [value] [ send value "Hi" ] The following example works: >> x f email@ connecting to: ... The following example >> x f ftp:// in REBOL/Core generates this error: ** Script Error: send expected address argument of type: email block. ** Where: send value "Hi Since the error message quotes the send function as the source for the complaint we would begin to search for the problem in function x. Consider that in a real-word situation there may be any number of functions that mediate between f and x, x .. w .. v .. u .. s .. t .. .. g .. f and functions w .. g may have no problem dealing with url! types instead of email! types. Here we would have to review function w thru g until we arrive in f and determine that f is the source of improper datatype because join is return type polymorphic. Compare the previous error message to the following one: >> x f ftp:// ** Script Error: Expected one of: return type: [email!] - not: url!. ** Where: f ftp:// This error message tells you where the error originated - in f not in x -, tells you it is a return type error, and what improper return type the function attempted to return instead of using one of the legal choices defined in the block. Here is how the improved error message came about: >> f: rt-func [[catch] value /local return-type [email!]] [ return join value ["site.com"] ] >> x: func [value] [ send value "Hi" ] >> x f ftp:// ** Script Error: Expected one of: return type: [email!] - not: url!. ** Where: f ftp:// This is the version of rt-func I used: rt-func: func [spec [block!] body [block!]] [ insert body compose/deep [ return: func [result /local return-type] [ return-type: reduce [(spec/return-type)] either found? find return-type type? result [ system/words/return result ][ throw make error! reduce ['script 'expect-set join "return type: " [mold return-type] mold type? result ] ] ] ] remove/part find spec 'return-type 2 append spec [return] return func spec body ] Hope this helps. ;- Elan >> [: - )]
[REBOL] Return types Re:(5)
Hi Brian, I sure enjoy your thoughts on the subject. I can certainly do without typed functions, but as long as they're optional ... Why not separate function constructors which support return type enforcement from functions that don't? Let's say we wish to enforce types or automatically convert types. This example auto-converts. Example usage: >> f: rt-func [a /local return-type [string!] ] [return a] Note that the return-type is entered in the /local part of the function's specification block (cheap trick, simplifies my implementation of rt-func somewhat). >> f 1 == "1" >> f [EMAIL PROTECTED] == "[EMAIL PROTECTED]" >> f http://www.rebol.com == "http://www.rebol.com" >> f 123.128.000 == "123.128.0" >> f [a b d] == "abd" >> f: rt-func [a /local return-type [block!] ] [return a] >> f 1 == [1] >> f [EMAIL PROTECTED] == [[EMAIL PROTECTED]] >> f http://www.rebol.com == [http://www.rebol.com] >> f [a b d] == [a b d] Later we go into production and want to optimize for speed (no auto-conversion). We set rt-func to func: >> rt-func: :func and now our functions behave normal: >> f: rt-func [a /local return-type [string!] ] [return a] >> f 1 == 1 >> f [EMAIL PROTECTED] == [EMAIL PROTECTED] >> f http://www.rebol.com == http://www.rebol.com >> f 123.128.000 == 123.128.0 The function rt-func could look something like this DISCLAIMERS Warning this is not production quality code. Just a rough draft, to get an idea. Does not support results of type object!: >> f make object! [a: none] == "?object?" "Things that can't be converted are not handled intelligently!" (TM) Probably there are other exceptions. A more careful approach would be to first check whether the function prototype contains the return-type word ... rt-func: func [spec [block!] body [block!] ] [ insert body compose/deep [ return: func [result /local return-type] [ return-type: (spec/return-type) system/words/return to return-type result ] ] remove/part find spec 'return-type 2 append spec [return] return func spec body ] At 04:56 PM 4/4/00 -0500, you wrote: >Hi Elan, > >You wrote: >> I don't see any harm in having a type specifier as part of >> the function declaration, which enforces a return type ... >> as long as it's *optional* ;-). > >How would this be enforced in an interpreted language that >creates its functions at runtime? > >Testing for return type at function creation time would need >a type-inference engine to determine the type. Type inference >is too slow to do at runtime. Type inference could not possibly be complete, since any function can be called via REBOL console. How do you infer the type of user input? > >Testing for return type at function execution time would add >an type-checking exception after the end of the function block. The only possible solution. >The function code wouldn't be able to handle such an exception, >so it would have to ensure that the error couldn't occur using >internal error-checking code, which would mean that the built-in >return type-checking code would just be overhead. Sure would. > >> Something like: >> >> func [ a [any-type!] b [integer!] /local ... /return [any-type!]] [ >> ] >> >> Perhaps with auto-conversion? > >I noticed that you put the return type you listed was in a block. >Blocks are used for the other types so that multiple types could >be specified. If multiple types are specified, which type do you >auto-convert to? First one by default. >What about conversions that aren't so automatic? > Too bad. >Functions in REBOL are often polymorphic, returning types that >depend on the types or values of their arguments. Which is the reason I don't quite see why return type checking is so important. >Any conversion >or type checking in such an environment is better done manually. >It's usually faster too, because you can remove tests where they >aren't needed. See above. > >A type inference engine would be a great development-time tool >to check your code before release, though. It would be a good >thing to have for documentation too. Perhaps, when I have a little more time. > >Wanna write one? ;-) >Brian > > > ;- Elan >> [: - )]
[REBOL] Return types Re:(3)
Hi Ingo, If I'm not mistaken, both your answers touch on documentation issues, not on function implementation. I don't see any harm in having a type specifier as part of the function declaration, which enforces a return type ... as long as it's *optional* ;-). Something like: func [ a [any-type!] b [integer!] /local ... /return [any-type!]] [ ] Perhaps with auto-conversion? At 09:49 PM 4/4/00 +0200, you wrote: >Those were the words of [EMAIL PROTECTED]: >> Hi Gisle, >> >> why should return types be defined for functions? > >Just some random thoughts on this: > >1) it would be easier to guess what a function does, or how > to use it: > >compare this > >>> help compress >Compresses a string series and returns it. >Arguments: >data -- Data to compress (any-string) > >to this > >>> help compress >Compresses a string series and returns it. >Arguments: >data -- Data to compress (any-string) >Returns: >binary! -- Maybe with some more explanation here > >which carries more information for you? How do you >use it correctly? > > >2) If you change the function some time later it is >more likely that you don't introduce changes which >would break existing code. > > >regards, > >Ingo > >-- _ ._ >ingo@)|_ /| _| _ www./_|_) |o(_|(/_ We ARE all FREE> ingo@| |(_|o(_)| (_| >http://www.2b1.de/Rebol/ ._| ._| > > > ;- Elan >> [: - )]
[REBOL] Return types Re:
Hi Gisle, why should return types be defined for functions? At 05:14 PM 4/4/00 +0100, you wrote: > >One thing that bothers me is that I can't specify a return type for >functions in REBOL. Many people consider this to be a bad idea so I'm >wondering what the idea behind this is. > >There are obviously advantages and disadvantages with this, but do the >advantages really outweigh the disadvantages? > >Gisle > > > ;- Elan >> [: - )]
[REBOL] Dialecting Re:
Hi, you wrote: >How is dialecting different from defining a new word in >Forth? Dialecting goes beyond just extending REBOL's vocabular. It permits you to also define your own syntactic structures (i.e. language grammar). >How does this make REBOL better than any language >which allows you to define new words? Some differences between REBOL and languages that allow you to define new words: 1. There are now holy cows, i.e. keywords. REBOL allows you to define new words as well as any word from REBOL's existing vocabulary to be anything you want. 2. Using REBOL's dialecting support, you can also define new syntactic structures. 3. Using contexts you can precisely control under what circumstances your new word definitions/syntactic structures become affective, without impacting REBOL's default vocabulary and behavior. 4. Based on contexts you can freely mix REBOL's default behavior and any number of dialects. Example: See the CID dialect that is shipping REBOL/View beta Hope this helps, ;- Elan >> [: - )]
[REBOL] Newbie question #2 - Pattern making and using? Re:(11)
Hi Gabriele, thanks for posting this to the mailing list. In general I would appreciate it if questions that are probably of general interest be posted to the mailing list, since we can all learn from the questions as well as the answers. At 12:00 PM 4/2/00 +0200, you wrote: >Hello jb! > >On 01-Apr-00, you wrote: > >[Forwarding to the list] > > j> Gabrielle, > >Just one "l"... :-) > > j> For the past two months when I have the time to review the > j> rebol posts, I've appreciated reading your succint, thoughful > j> and clear examples. Thankyou. Your method outlined below is a > j> fine example of this. You are both an excellent teacher and > j> certainly you must be a world class programmer ! :-> > >Thank you. You're surely exaggerating --- I'm just a student! :) > > j> Perhaps you will be so kind as to provide urls for the best > j> examples of pattern matching techniques for REBOL? For > >I think you can find a lot of examples on rebol.org. I've written >a site-saver too (downloads an HTML document plus all of the links >etc.); it still needs some work, so I didn't publish it yet, as >you can get a couple of other script doing the same job on >rebol.org, but if you're interested... > > j> example, let's assume a useful utility will crawl through a > j> web site and gather only the links on the site saving them to > j> a file, how does a good rebol programmer think about and then > j> execute the following: > > j> find all instances of the following pattern > j> http://yy.yyy/ ( ie any and all urls in a web page.) > j> and return and then store only the http://y.yyy portion to > j> a file appending a newline to each ? > >If you assume that the initial "http://" is always present, as >well as the "/" after the domain name, the task is really easy: > > file-port: open/lines %destination-file.txt > parse text-containing-links [ > any [ > to "http://" copy url ["http://" to "/"] > (insert tail file-port url) > ] > ] > close file-port > >If you just want to assume that the URLs begin with "http://": > > url-rule: ["http://" some domain-chars] > domain-chars: complement charset [#"^(00)" - #" " #"/"] > parse text-containing-links [ > any [ > to "http://" copy url url-rule > (insert tail file-port url) > ] > ] > > j> Now with perl the matching expression is relatively short and > j> the assignment of the value is rather straight forward as well > j> as the printing to a append the file. > > j> Feel free to forward this letter to the list with your > j> response. I'd love to see how others will answer it. > > j> TIA, > j> JB > > j> PS > j> *I'm replying off list because my temporary isp doesn't > j> forward my mail when I use my subscribed email account. > >Regards, >Gabriele. >-- >o) .-^-. (--o >| Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila | >| GIESSE on IRC \ \-\_/-/ / http://www.amyresource.it/AGI/ | >o) `-v-' (--o > > > > ;- Elan >> [: - )]
[REBOL] [REBOL]Problem with function argument Re:(3)
Hi t, A file! type is a filename with a leading % character. Example: %myfile.r %/c/mydir/. A file! may be any type of file, including a directory. A port! datatype is a low-level i/o abstraction that REBOL uses to serialize different types of i/o channels, such as files (here we are not talking about the filename, but access to the file's contents), and socket i/o. The access to ports is typically controlled by protocols that define how information is read and written to a port, and also commonly implement some convenient navigation functions for the port's datastream, such as first, next, insert, pick, etc. These functions work in a sensible way on a port! datatype. They enable you to treat ports as though they were series values (i.e. blocks, paths, hashes ...) to a degree, hence the term serialize is used to describe this type of access to i/o channels. There are some limitations, since not all ports lend themselves to being treated as a series effectively with respect to all series! functions. I haven't been following this thread, so I don't know why you are using ports. Generally speaking, it is often more convenient to use higher level functions when dealing with files, then accessing them as ports. read, write, read/lines, write/append write/lines, write/append/lines, save, load, come to mind. All of these functions take a filename (type file!), and do not require that you manage the file on the port level, for instance with respect to positioning, etc. Hope this helps. ;- Elan >> [: - )]
[REBOL] Newbie question #2 - Pattern making and using? Re:
Hi T Brownell you wrote: >x: none >cat: "feline" >cat: "kitty" >fact: "I have a kitty" >if found? find fact cat [x: "found it"] >if found? x [print x] >unset 'x A few remarks: >x: none this line is not necessary. But it's not a bad idea. >cat: "feline" >cat: "kitty" Now cat evaluates to "kitty" only! cat no longer evaluates to "feline"! If you try this code against fact: "I have a feline" find will fail! Given: >cat: "feline" >cat: "kitty" >fact: "I have a kitty" you could say: if found? find fact cat [print x: "found it"] >How can i make the 2 values of cat: into a pattern >that can be used in this script? Also, the rest of >this script stinks... THERE MUST BE A BETTER WAY!!! fact: "I have a kitty" rule:[ [thru "kitty" (x: "found kitty")] | [thru "feline" (x: "found feline") ] to end ] >> if parse fact rule [print x] found kitty fact: "I have a feline" >> if parse fact rule [print x] found feline To identify both in any order: fact-1: "The feline I have is a kitty." fact-2: "I have a kitty which is a feline" one possible approach is: rule:[ marker: [thru "kitty" (x-kitty: "found kitty")] :marker [thru "feline" (x-feline: "found feline") ] to end ] unset 'x-feline unset 'x-kitty if parse fact-1 rule [ if value? 'x-feline [print x-feline] if value? 'x-kitty [print x-kitty] ] unset 'x-feline unset 'x-kitty if parse fact-2 rule [ if value? 'x-feline [print x-feline] if value? 'x-kitty [print x-kitty] ] >> unset 'x-feline >> unset 'x-kitty >> >> if parse fact-1 rule [ [ if value? 'x-feline [print x-feline] [ if value? 'x-kitty [print x-kitty] [] found feline found kitty >> >> unset 'x-feline >> unset 'x-kitty >> >> if parse fact-2 rule [ [ if value? 'x-feline [print x-feline] [ if value? 'x-kitty [print x-kitty] [] found feline found kitty Hope this helps. ;- Elan >> [: - )]
[REBOL] [REBOL] Error Message Re:(6)
Hi Volker, you wrote: >My problem is: i dont know the arg of 'do. its a parameter. >type? destroys the result. i can not store it before, because >this can cause an error. i can not [try [a: do b] because the error >can be caused by code in 'b . maybe something like >[try [ a: try [b]], but this gets complicated. Not very elegant, but this works: >> unset 'a >> result: [] == [] >> insert result do [print "hi"] hi == [] >> if not unset? first result [a: first result] clear head result == [] >> value? 'a == false >> insert result do [1 + 1] == [] >> if not unset? first result [a: first result] clear head result == [] >> value? 'a == true >> a == 2 Hope this helps, ;- Elan >> [: - )]
[REBOL] [REBOL] Error Message Re:(4)
Hi Volker, you wrote: >use and /local have another bug: you can't look in after an error! I'm not sure how you were trying to "look in": >> f: func [/local a] [a: 1 1 / 0] will cause a divide by zero error: >> f ** Math Error: Attempt to divide by zero. ** Where: 1 / 0 Now let's look at the value of a: >> first second :f == a: >> get first second :f == 1 "Looked in" and saw that a evaluates to 1. You must mean something quite different? >a question: [a: do [print "1"]] does not work, how can i handle this too? >i wanted to return the result of [do b] this way, with some lines after it >[.. e: do b if a-option [..] "return" e ] ? print returns nothing, and nothing is a value of type unset!: >> type? print "hello" hello == unset! >> type? do [print "hello"] hello == unset! >> print mold do [print "hello"] hello ** Script Error: mold is missing its value argument. ** Where: print mold do [print "hello"] When type? returns the datatype unset! it is reporting that there was no value: >> type? == unset! There is no value to assign to 'a in your example. Otherwise it works as you expect (?): >> f: func [] [a: do [1 + 1] return a] >> f == 2 >"code" >local: func[a "vars" b "script" /local c d ][ >c: copy[] foreach i a[ append c to set-word! i] append c none You could simplify your foreach loop: foreach i a [ append c compose [(to set-word! i) none] ] >d: make object! c bind b in d 'selfdo b d] > >"test" do [ >a: "-a" b: "-b" >probe the-locals: local[a b][ a: 10 b: 20] >probe a probe b probe the-locals >] > > >Volker > > > ;- Elan >> [: - )]
[REBOL] [REBOL] Error Message Re:(2)
Hi another_bob, I believe I've seen this error message when I've used hidden contexts. Were experimenting or using a use block, something like this? use [a b] [a: 1 b: 2 [a b]] I believe it's an error that is not supposed to happen and indicates that REBOL's garbage collection has been corrupted. At 05:41 PM 3/23/00 +1200, you wrote: >another_bob wrote: >> What is the meaning of this error message? >> How can I avoid it? >> >> Invalid data type during recycle >> ** Press enter to quit. > >It could be a bug. Send a copy of the script to the list. Or run the >feedback script. > >Andrew Martin >ICQ: 26227169 >http://members.xoom.com/AndrewMartin/ >-><- > > > ;- Elan >> [: - )]
[REBOL] String formatting Re:
There should be a rather complete solution called format.r located in the user contribution archive at http://www.rebol.org At 10:17 AM 3/14/00 +0100, you wrote: > The following is rather trivial... anyway: >what is the most convenient way of formatting strings in Rebol, let say for >producing suitable output, à la printf/sprintf in C? Thanks, Mauro >Bregolin > Attachment Converted: "c:\eudora\attach\bregolin.vcf" ;- Elan >> [: - )]
[REBOL] finding stuff, and looping Re:
Hi -t, you wrote: >finding stuff, and looping foreach filename load %ddbms/ [ if not dir? filename [ file: read join %ddbms/ [filename] ;- do-stuff-with-contents-of-file filename, ;- or just print the name of the file read: print ["read filename" filename] ] ] ;- Elan >> [: - )]
[REBOL] How do I save and restore an array of objects Re:(4)
Hi Bob, A) do works when you only want to load a single object. It's like saying: do [make object! [word: 'something]] which - of course - returns a single object, namely the last object (and here only object) found in the block (returned by load), and not a block containing all objects that were in the file. B) you wrote: >is there a situation where reduce should not be used? There are two I can think of right now. 1. When the object contains a literal word, as in: >> o: make object! [word: 'something] here 'something is lit-word! probe o reveals that the lit-word! becomes a word! when we create the object: >> probe o make object! [ word: something ] We store it and then load it. We now have the following block: >> o: load %bob-store.dat == [ make object! [ word: something ]] Note that this block contains three elements: the word make, the word object!, and the block containing the set-word! word and the word something. So when we reduce this block, we have the same situation as: >> o: make object! [word: something] which generates an error as it would with reduce, because the word something is not defined in this context: >> o: make object! [word: something] ** Script Error: something has no value. ** Where: word: something This whole scenario is due to the fact that the original lit-word! something (i.e. 'something) was reduced to a word when the original object - the one that we saved - was created. Accordingly, when we saved the object the word something, originally a lit-word! is saved as a word! and is no longer usable to create the object. I don't see how this situation could be avoided, since you can't as a matter of principle change all words that are assigned to a set-word! into lit-words when you load the stuff, because it is possible that some of these words are indeed intended as words. This is only a problem if it is possible that your object will include values that started out as lit-words, before the object was created. Two work-arounds: a) Never use literal words in objects you want to save, instead always assign literal word in blocks: >> o: make object! [word: [something] ] >> save %bob-store.dat o >> o: reduce load %bob-store.dat == [ make object! [ word: [something] ]] >> type? first o == object! b) Or If you are certain that - when you load objects from a file - you will not be using words that should be dereferenced during the act of object creation, i.e. something can never be intended as anything but 'something, then you could edit each respective block used in the object creation before you reduce the stuff, like in this case: >> o: make object! [word: 'something] >> save %bob-store.dat o >> loaded-o: load %bob-store.dat == [ make object! [ word: something ]] >> change back tail third loaded-o ['something] == [ ] >> print mold loaded-o [ make object! [ word: 'something ]] >> o: reduce loaded-o == [ make object! [ word: something ]] > type? first o == object! >> probe first o make object! [ word: something ] 2. When you have objects that contain references to objects: >> p: make object! [q: o] >> save %bob-store.dat p >> r: first reduce load %bob-store.dat >> probe r make object! [ q: [ make object! [ word: something ]] ] >> probe p make object! [ q: [ make object! [ word: something ]] ] Looks as though everything is ok. NOT! Here's the problem: p, which is the object the word q as a reference to o, does not have its own copy of o. If you modify o, you automatically modify p's embedded object: Let's grab the object contained in the block o (remember we loaded it from the file): >> o: first o >> probe o make object! [ word: something ] Ok, now let's change what word is pointing at: >> o/word: 'something-else == something-else and p was changed as well: >> probe p make object! [ q: [ make object! [ word: something-else ]] ] in contrast there is no equivalent of p in the loaded scenario r, such that this equivalent points at the object referenced by q in r. In other words, as soon as you save the objects o and p, the relationship between o and p, namely that p/q is only reference to the object o, and not a second object, this relationship is lost. Can't think of anything else right now. Hope this helps. ;- Elan >> [: - )]
[REBOL] Associative Arrays in Rebol? Re:
I think select and paths should come close to what you're asking: for instance: >> select [ a "this is a" b "this is b" ] 'a == "this is a" >> select [ a "this is a" b "this is b" ] 'b == "this is b" >> block: [ a "this is a" b "this is b" ] == [a "this is a" b "this is b"] >> block/a == "this is a" >> block/b == "this is b" At 09:06 PM 3/9/00 -0500, you wrote: >Is there any way to simulate Associative Arrays in Rebol? > >The type where the index could be a list of random words >like in the language Awk? > > > ;- Elan >> [: - )]
[REBOL] Command Line Args Re:(2)
Hi Bo, >system/script/args is only for arguments passed with DO/ARGS. >system/options/args is for arguments passed from the command >line. Interesting enough, under Win95 system/script/args did contain the command line args! Actually, they both worked! They both contained the same arguments. ;- Elan >> [: - )]
[REBOL] Command Line Args Re:(2)
Hi Bo, >system/script/args is only for arguments passed with DO/ARGS. >system/options/args is for arguments passed from the command >line. Interesting enough, under Win95 system/script/args did contain the command line args! Actually, they both worked! ;- Elan >> [: - )]
[REBOL] Command Line Args Re:
I tested it on my machine (running Win95) and it worked as advertised, i.e. the arguments were available under system/script/args as a string. What did you expect would happen? Perhaps the problem is with trim.r? At 09:04 PM 3/9/00 -0500, you wrote: >Can some one please send me a example of how to deal with >command lind arguments please? > >I want to do some thing like this from the command line: > >rebol -swq trim.r file.in file.out > >Manual says I should see "file.in and file.out" at >system/script/args but I don't. > >What am I doing wrong? > > > ;- Elan >> [: - )]
[REBOL] How do I save and restore an array of objects Re:(2)
Hi Bob, if I'm not mistaken, it is here where you are loading the file containing objects: > if exists? %articles/stor [ stories: load %articles/stor ] try the following instead: if exists? %articles/stor [ stories: reduce load %articles/stor ] At 06:57 PM 3/9/00 +, you wrote: >The example below reads a web page of alternating headlines and >associated stories. If the same headline appears on a later scan >the story is ignored. It saves elements parsed from the webpage >as an array (block) of structs (object!s). >It cannot seem to restore them cleanly when rerun later. >why? How do I get around it for now? > >I have simplified the example below. > >REBOL [title: "sample story fetcher" ] > >stories: make block! 25 >story-tmpl: make object! [ > head: none > body: none > topics: none > dest: none > fileto: none > ] > >page-parser-rules: [ > any [ > thru "headline:" > copy headl to "story:" > thru "story:" > copy story-body [ to "headline:" | to | to end ] > (store-story) > ] ] > >headl: make string! 30 >topic: make string! 30 >story-body: make string! 300 > >store-story: func [ /local sry ] [ >; drop dupes... >foreach st stories [ >if st/head = headl [ return false ] > ] > >; fill in struct >sry: make story-tmpl [] >sry/head: copy headl >append stories sry >] > >go: func [ /local c ] [ >if exists? %articles/stor [ stories: load %articles/stor ] >c: read http://localhost/storygenerator.cgi > >parse c page-parser-rules ; calls store-story when "headl" filled >save %articles/stor stories >] > >go >q > > >;# mailto: [EMAIL PROTECTED] > > > ;- Elan >> [: - )]
[REBOL] Some niggley things Re:(3)
At 06:15 PM 3/9/00 +, you wrote: > >Hello, Elan: > >On 09-Mar-00, [EMAIL PROTECTED] wrote: > >> One possibility would be: > >> >> files: [%a %b %c %d %e %f %g %h %i %j] >> >> foreach [f-1 f-2 f-3 f-4 f-5] files [ >> print mold to string! >> reduce [f-1 "+" f-2 "+" f-3 "+" f-4 "+" f-5] ] > >> which results in: > >> "a+b+c+d+e" >> "f+g+h+i+j" > >> Hope this helps, > >What I ended up using was: > > FOREACH [f-1 f-2 f-3 f-4 f-5] files [ > portfolio: MOLD TO STRING! > REDUCE [f-1 "+" f-2 "+" f-3 "+" f-4 "+" f-5] > >When I do it this way, I get a string. That's what I told it to do. > >This causes an error, Which error? A REBOL error? >and the page is returned which page returned where? >minus the first and last (f-1 & >f-5) entries. If it causes an error, how is anything returned? Oh, it's not a REBOL error? >When the quote marks are removed after copying the completed URL >into the brower, it works fine, so the quote marks are the problem. > > tmp: READ JOIN QAN-URL [ "?tick=" portfolio decimals ] note that I used the "print mold " expression only for demonstration purposes: so that you can see exactly what is being returned, namely a string "..." containing the file values %x and plus signs. If you want to use the stuff somehow (I don't know what the URL you are returning has to look like, you will need to join the stuff with the url, and the final result should be one value, including all information, of type url!. As in read join http://www.some-site.com/ [""]. See, I don't know whether you plan to read the files and report the contents of those files to the URL you are addressing, or whether you want to send a list of file names to the url, in which case you possibly do not want to include the leading percent sign, if the server side program does not know that % is REBOL's way of saying literal file! type. > >Hmm, this is the *same line* used elswhere in the program, which worked last >night. Am I missing something? I guess it is. > >In what form can I get the above "string" without quotes, so that I can build >the URL properly? >> join http://www.some-site.com/ ["a+b+c+d+e"] == http://www.some-site.com/a+b+c+d+e >> type? join http://www.some-site.com/ ["a+b+c+d+e"] == url! Hope this helps, ;- Elan >> [: - )]
[REBOL] Lowing SECURITY LEVEL within a script Re:
Hi Carlos, If you are running the script under a copy of REBOL that you control, you can use rebol -s (or rebol.exe -s) to disable security at startup. If REBOL is running on someone else's remote computer, and you have not control over that REBOL instance, you are NOT SUPPOSED to be able to disable security programmatically, without that person OKing it. At 04:56 PM 3/9/00 -0300, you wrote: >Hi REBOLS, > >Is there any way of lowing security level of REBOL within a script without >having to click that warning every time? In other words how can I avoid that >warning dialog everytime? > >Carlos > > > > ;- Elan >> [: - )]
[REBOL] Some niggley things Re:(5)
Hi Donald, you wrote: >What I really wanted to know was how to use a set-word!. The reason is that, >if the program has an error and stops, the console is still set for a changed >directory path. This is very annoying, since, to re-run the program, I have to >change-dir again and again: > > list-path: %/drive/folder/folder/ > list: READ path > >with "list" containing the dir-list block. I didn't get this working yet. I must be missing something! This wouldn't work for you, right? >> set 'path %/d/temp/ == %/d/temp/ >> list: read path == [%save_NewFrames/ %funky/ %tcl-v7/ %snapshots/ %lynx_w32_2_8_2rel_1.zip %yikes131.zip... BTW, here you see how my temp file has changed since the last test ;-) If you're using words that referece the directory names: >> drive: 'd == d >> folder-1: 'temp == temp >> folder-2: 'funky == funky >> set 'path to file! reduce ["/" drive folder-1 folder-2] == %/d/temp/funky >> append :path #"/" == %/d/temp/funky/ >> read path == [%schema.DAT %LATEST.LOG %DECISION_TAB.LOG] Hope this REALLY helps, ;- Elan >> [: - )]
[REBOL] Some niggley things Re:(3)
Hi Donald, >> Under windows I can read the directory saying: >> files: read /drive/folder/folder/ > >I tried using it directly, but... > >** Script Error: READ expected source argument of type: file url object block. >** Where: files: READ /Data2 /Stocks /Data You need a % character (In the prototype I skipped it because - in the back of mind - I thought it was understood, sorry): read %/drive/folder/folder/ Example: >> read /d/temp/ ** Script Error: read expected source argument of type: file url object block. ** Where: read /d /temp / Compare to: >> read %/d/temp/ == [%save_NewFrames/ %funky/ %tcl-v7/ %snapshots/ %lynx_w32_2_8_2rel_1.zip... Hope this helps, ;- Elan >> [: - )]
[REBOL] Some niggley things Re:
Hi Donald, perhaps I'm misunderstanding something. But ... >#1 >files: READ %. gets the current directory, but how do we do it with a >set-word? Example: > > directory: %/partition/drawer/drawer > files: READ %directory(how to deal with "."?) > >doesn't work because (among a few things) it tries to read the current >directory. I don't want to use CHANGE-DIR because then REBOL persists to look >at that drawer, which is *very* annoying when trying to re-run the program. It appears to me that you are trying to read the directory located at %/partition/drawer/drawer ? Under windows I can read the directory saying: files: read /drive/folder/folder/ such as in >> directory: %/d/temp/ == %/d/temp/ >> files: read directory == [%save_NewFrames/ %funky/ %tcl-v7/ %snapshots/ %lynx_w32_2_8_2 ... > >#2 >"files" (above) will, eventually, be a block of about 300 file names. I need >to know how to take five file names at a time and make a string that is: >"name+name+name+name+name", to add to a URL. One possibility would be: >> files: [%a %b %c %d %e %f %g %h %i %j] >> foreach [f-1 f-2 f-3 f-4 f-5] files [ print mold to string! reduce [f-1 "+" f-2 "+" f-3 "+" f-4 "+" f-5] ] which results in: "a+b+c+d+e" "f+g+h+i+j" Hope this helps, ;- Elan >> [: - )]
[REBOL] solved: dynamic words 2 Re:
Trying to figure out what you are trying to accomplish I ran your code and get an error message: >> count: 50 == 50 >> out: make string! 1000 == "" >> >> for build 1 count 1 [ [builder: reform ["messagebuilder:" rejoin ["message" build]] [do builder [append out messagebuilder [] ** Script Error: message1 has no value. ** Where: messagebuilder: message1 You don't? How come? At 04:18 PM 3/8/00 -0600, you wrote: >got it! > >appending the value of a dynamically created word name to a word... > >count: 50 >out: make string! 1000 > >for build 1 count 1 [ > builder: reform ["messagebuilder:" rejoin ["message" build]] > do builder > append out messagebuilder >] > > >"reform" was the missing link. thanks for directing me to use "do." > >-ryan > > > ;- Elan >> [: - )]
[REBOL] return statement Re:
Hi Phil, 1. As a matter of principle REBOL lets you modify the value of each and every word. There are no keywords. This is good. 2. To protect all words that are part of the REBOL vocabulary use the built-in function protect-system. 3. To protect selected words (here return) use the function protect, as in >> protect 'return >> return: none ** Script Error: Word return is protected, cannot modify. ** Where: return: none You can have it your way without limiting REBOL's flexibility. At 10:22 PM 3/7/00 +, you wrote: >Consider the following code : > >REBOL [] >; Check function >check1: function [] [] >[ >x: "A" >if x <> none [return "Error"] >print "This should not print" >return none >] >print check1 > > >does not print the text (correctly). > >However adding the line >return: "Error" > >gives >REBOL [] >; Check function >check1: function [] [] >[ >return: none >x: "A" >if x <> none [return "Error"] >print "This should not print" >return none >] >print check1 > >does print the text >(I accidentally added this line to a sub-function, instead of return none, >and it took me ages to track this down) > >Shouldn't progress stop us setting variables like return: ??? > >Cheers Phil > > > ;- Elan >> [: - )]
[REBOL] new proxy server and related problems ... Re:
Hi Petr, have you tried to set the http proxy settings? I.e. >> system/schemes/http/proxy/host: proxy.sec.trz.cz >> system/schemes/http/proxy/port-id: 3128 >> system/schemes/http/proxy/type: 'socks. >> system/schemes/http/proxy/user: none >> system/schemes/http/proxy/pass: none At 10:54 AM 3/3/00 +0100, you wrote: >Hi, > >our company has new proxy server installed and I can't get trhu it with >REBOL > >My Netscape settings are: > >http: proxy.sec.trz.cz port: 3128 > >No socks hosts setting is applied. > >how should I set my http scheme to let it work? > >The only one way of how to get thru is: > >port: open/lines tcp://proxy.sec.trz.cz:3128 >con: insert port "GET http://www.rebol.com/ HTTP/1.0^M^J^M^J" > >wait con >while [data: pick con 1][print data] > >close con > >This small test works, but read http://www.rebol.com hangs, and I can't >find it combination of setting to make it work. > >Any help, please? > >Thanks, > >-pekr- > > > ;- Elan >> [: - )]
[REBOL] out of range or past end Re:
Hi RChristiansen, 1. first words will fail when words is empty: >> first [] ** Script Error: Out of range or past end. ** Where: first [] To avoid the error use pick words 1 instead: >> pick [] 1 == none 2. >in: read %messages.txt >lines: make block! 1 >parse in [any [thru newline copy text to newline (append lines text)]] why don't you use read/lines instead? lines: read/lines %messages.txt read/lines returns a block containing each line as a string! You don't need the additional parsing and you get the same result. 3. > fields: form first lines Since lines is a block containing strings, first lines will evaluate to a string and you don't need the additional string conversion provided by form. 4. > firstword: form first words Since words was constructed by appending strings to the block words, first words will evaluate to a string and you do not need the additional form. 5. > words: [] > clear words You could instead write: words: make block! 0 or words: copy [] 6. >append out {} This is the first element you are adding to the block out. Since append is a convenience which in turn calls insert tail, and therefore more compute intensive (hardly a worthwhile consideration in your code, just old habit on my part), and out is empty at this point anyway, you could just as well just use insert. You apparently skip the first line that ends with an end of line character (the "thru newline" part of your rule before you "copy text to newline". I'm therefore using next read/lines %messages.txt to skip the first line in messages.txt. A simpler version of your code would look like this: out: make string! 10 insert out {} words: make block! 0 foreach fields next read/lines %messages.txt [ clear words foreach word parse fields ":" [append words word] firstword: pick words 1 ] At 05:43 PM 3/2/00 -0600, you wrote: >When I run the following script, I get the following error: > >** Script Error: Out of range or past end. >** Where: firstword: form first words > >The script runs fine for several loops then quits on this error. What may be >happening? > > >REBOL [] > >in: read %messages.txt >lines: make block! 1 >parse in [any [thru newline copy text to newline (append lines text)]] > >out: make string! 10 >append out {} > >forall lines [ > fields: form first lines > > words: [] > clear words > foreach word parse fields ":" [append words word] > > firstword: form first words >] > > > ;- Elan >> [: - )]
[REBOL] [REBOL]How to remove email headers Re:
Hi tim: message-with-headers: none message-without-headers: none forall inbox [ message-with-headers: import-email first inbox message-without-headers: message-with-headers/content ] or: forall inbox [ message-without-headers: get in import-email first inbox 'content ] Note that message-without-headers will point at a different message body at each iteration and will not preserve the last message. If you want to save the message you will have to insert the messages one by one into a block. messages: [] forall inbox [ append messages get in import-email first inbox 'content ] Also note that when a message is a reply to a previous message, the message body may quote a message it is responding to and include that previous message's headers in its own body. In this case you will end up with the complete body of the message you received, including possibly quoted headers of previous messages it responds to, provided they are included in its body. ;- Elan >> [: - )]
[REBOL] REBOL on a MAC Re:(2)
Hi Carlos, correct instructions, wrong example. Instead of: >Under MS Windows that would be: > >rebol.exe -c use rebol.exe -s ;- Elan >> [: - )]
[REBOL] REBOL on a MAC Re:
Hi Carlos, secure none does not cause a message box when security has previously been set to none. For instance if your user.r file includes the secure none expression, then if you run a script later which also sets secure to none, the messagebox will not be displayed. The messagebox will always be displayed (ie on MS Windows) when evaluate secure none and the previous security level was higher. You can check what your previous security settings were when you run the script under MS Windows by evaluating >> print [secure none] For instance, under MS Windows: 1. Manually force the security level to quit, to ensure that you are starting out with a higher security level: >> secure quit 2. Now evaluate the expression >> print mold secure none and REBOL displays the messagebox and subsequently displays: [net quit file quit] because that was the previous setting. For security reasons REBOL always requires operator response when the security level is being lowered by a script. Use the -s command line switch, to set security to none when REBOL starts up. Under MS Windows that would be: rebol.exe -c At 04:59 PM 2/29/00 -0300, you wrote: >Hi Rebols, > >my script has a SECURE NONE at the one of the first lines in order to avoid >that annoing question about write permission. > >In Windows it works out fine but on MAC OS I still have a question where >Rebol wants me to be sure security is going to be down. WHY? > >Any help is welcome > >Carlos > > > ;- Elan >> [: - )]
[REBOL] Catching Web Site Access Errors Re:
Hi Melvin, >> if error? error: try [ read http://www.does-not-exist.com ] [ error: disarm :error probe error ] connecting to: www.does-not-exist.com make object! [ code: 507 type: access id: no-connect arg1: "www.does-not-exist.com" arg2: none arg3: none near: [read http://www.does-not-exist.com] where: none ] At 01:56 PM 2/29/00 -0500, you wrote: > I am connecting to a remote site using: page: read >http://www.noSuchSite.com How do I catch the scenario where the site >doesn't exist, with no error checking I get the following: Access Error: >Cannot connect to www.noSuchSite.com Melvin Mudgett-Price >Director of Development >http://www.acmex.com/bio/mmp (Bio) >(216) 391-7400 X207 - Acme Express, Inc. >Web-enabled software / e-commerce / Web Marketing >http://www.acmeX.com >(216) 391-0707 (FAX) >(216) 276-5487 (Cell) ;- Elan >> [: - )]
[REBOL] decrypting downloaded rebol files Re:
Hi Martin, write/binary filename.extension decompress read/binary downloaded-filename.extension At 01:12 PM 2/29/00 -0400, you wrote: >Hello. > >I just downloadedhttp://www.rebol.com/examples/examplesall.r from the web site. >Apparently this is compressed as I see junk when I look at it in a text editor. >There is no instruction on how to extract it at that point on the web page. I have been unable to find out how to extract it although I looked at, and printed the users guide plus other doc's. > >A hint and reference please > >Regards...Martin >-- >--- > >If speed kills, then Windows users may live forever. > > > > ;- Elan >> [: - )]
[REBOL] Parsing examples? Re:
Hi Brad, you wrote: [snip] >I want to write an XML'ish parser. Which is to say that I need to match >beginning and ends of tags, but I don't know the tag names. i.e. >bookXML in a nutshell The tags are made up for a >specific data set, but i don't know what they are in advance. I know they >begin like this, and end like this Check out >> source xml-language You may find it helpful, especially the function xml-language/parse-xml, which is used by the global word parse-xml. >> source parse-xml ;- Elan >> [: - )]
[REBOL] Testing REBOL/View Beta List Re:
Hi guys, Sorry about this noise, I wasn't aware that apparently the problem has been resolved! ;- Elan >> [: - )]
[REBOL] Testing REBOL/View Beta List
Hi Carl, I'm responding to your message by hitting the reply button. If all goes well, my response should be distributed to REBOL/View Beta members only and should not show up on the main REBOL list. I modified the subject line to ensure that this message is not categorized by email client filters based on subject line. I don't see how this message will end up on the Beta list. When I hit the reply button the to: field was automatically set to [EMAIL PROTECTED] ;- Elan >> [: - )]
[REBOL]
Hi Keith, you wrote: >> ...or wait a bit for the public release of REBOL/View. > >Well, you can do a graphical interface with REBOL/View, but I was careful to >be explicit and specify that it was if you want an HTML interface that you >have to run a REBOL CGI script :) Right. Or you could use one of the REBOL Webservers (see library) and include the necessary REBOL functions in the Web server script without using CGI at all (provided you will be using this local server for this purpose exclusively!) ;- Elan >> [: - )]
[REBOL]
Hi Chris, send a request for beta participation to [EMAIL PROTECTED] You might get lucky ;-) At 05:46 PM 2/25/00 +1000, you wrote: > > >[EMAIL PROTECTED] wrote: > >> Better yet, wait til REBOL/View becomes available (or join the beta testing >> now), and you can do it all with a nice GUI interface using nothing but >> REBOL/View (no web browser, no web server, no HTML, no JavaScript, and >> probably in no more than ten or twenty lines of code ...) > >I recall hearing about the approaching beta testing of /view several >months ago before I dropped off the list (final semester of my degree, >and playing with rebol was too distracting :). > >Is the beta still open (to anyone)? If so, how may I join? > >Thanks, >Chris > > > ;- Elan >> [: - )]
[REBOL] html4 generator script Re:
Hi Scott, I briefly glanced at your html4.r script. (Briefly means that I may have few more ideas when I take a close look). Some observations: You use print throughout in your functions. That will significantly slow down your output to the webserver. Instead, have each function return a string that contains the stuff you would have usually printed out. I.e in this example: Begin: func ["The tag."][ print [] ] use: begin: func [] [ return "" ] In this example: _head: make object! [ http-equiv: none author: none keywords: none description: none title: none style: none out: func [][ print [newline] if (not none? http-equiv) [print build-tag [meta http-equiv (http-equiv)]] if (not none? author) [print build-tag [meta name "AUTHOR" content (author)]] if (not none? keywords) [print build-tag [meta name "KEYWORDS" content (keywords)]] if (not none? description) [print build-tag [meta name "DESCRIPTION" content (description)]] if (not none? style) [ print build-tag [style type "text/css"] print [style newline ]] if (not none? title) [print [{}title{}newline{}]] ] end: func [] [print []] ] ; end of _head object TRY INSTEAD: _head: make object! [ tags: make object! [ http-equiv: none author: none keywords: none description: none title: none style: none ] out: func [/local result meta-block][ result: make string! 1000 foreach tag next first tags [ if get in tags tag [ append result either meta-block: select [ http-equiv [http-equiv] author [name "AUTHOR"] keywords [name "KEYWORDS"] description [name "DESCRIPTION"] ] tag [ build-tag compose/deep [meta (meta-block) content (get in tags tag)] ][ switch tag [ style [ rejoin [ build-tag [tags/style type "text/css"] tags/style newline "" ] ] title [ rejoin ["" tags/title " "] ] ] ] append result newline ] ] return head insert result ] ] To have a complete (albeit trivial) web page let me add the following strings: content-type: "Content-Type: text/ ^/^/" end-html: body: " Think First Consulting } Perhaps it would be a better idea to use html-head instead of _head? It's more user friendly and even a novice will immediately understand what you are talking about. ;- Elan >> [: - )]
[REBOL] WAP (protocol) and REBOL Re:(2)
Any pointers to URL's with specifications, tutorials ... ;- Elan >> [: - )]
[REBOL]
Hi, better use a local Apache server. I described the configuration in a previous email (from yesterday). You can download Apache for Win95 at http://www.apache.org (I think it was .org. Otherwise try .com or .net). Then you can put your form handling REBOL script in the Apache cgi-bin and continue to use JavaScript + HTML for input. Better yet, wait til REBOL/View becomes available (or join the beta testing now), and you can do it all with a nice GUI interface using nothing but REBOL/View (no web browser, no web server, no HTML, no JavaScript, and probably in no more than ten or twenty lines of code ...) ;- Elan >> [: - )]
[REBOL]
Hi Keith, you wrote: >For now, if you want to use REBOL to get form input from >an HTML page, you'll have to do it with REBOL running as a CGI script. :) Well, how else would collect data from a form? Even using JavaScript, you will have to eventually report the data to the server and you will need some server side application to collect the data. So, server side you must have some program that will accept the data and do something sensible with it. ;- Elan >> [: - )]
[REBOL] if condition vs. while condition Re:
Hi Piroz, >In this context, what is the definition of a >"condition" A condition is an expression that evaluates either to a logical false (including none, off) or something else. Like in C, everything that is not a logical false is considered true, i.e. >> if 1 [print {will be evaluated because 1 is not logical false}] will be evaluated because 1 is not logical false >> if [] [print {will be evaluated because an empty block, [], is not logical false}] will be evaluated because an empty block, [], is not logical false >and why does >REBOL treat the two conditions differently? The condition expression for if needs to be evaluated exactly once. First, we evaluate the condition expression and then - depending on what this expression evaluates to - we either do or do not evaluate if's body. What happens in that body cannot affect the result of having evaluated the condition expression. There is therefore no reason to pass the condition expression on to if for evaluation. The condition expression will be evaluated in the context in which if is called, and the resulting value will be passed to if. In contrast, while's condition has to be evaluated repeatedly, once on entering while and repeatedly after while's body has been evaluated. Therefore, "while" itself must evaluate its condition expression. It cannot simply receive the result of a single evaluation of the condition epxression. To protect while's condition expression from being evaluated in the context in which while is being called (i.e. the global context of the REBOL shell, or the context of a function in which while is being called), the condition expression is embedded in a block. The condition expression block can contain as many expressions as required. The condition expression itself - not the result of having evaluated it - is passed to while in a block and and while will evaluate the condition expression as often as it needs to. We expect that some expression evaluated in while's body will eventually affect the condition expression and that expression will return false. The condition expression must therefore be able to reflect modifications that occurred as a result of evaluating while's body. >Why not >use a block for an >"if" statement as we do for loops? There are two factors that determine that we must pass the condition expression unmodified - i.e. embedded in a block - to while: the condition expression must be evaluated repeatedly, and during its repeated evaluation changes that occured within while's body must be able to affect values that are processed in the condition expression. Neither of these factors apply to if. There is no reason to complicate if's implementation by forcing it to evaluate its condition expression, when that expression can be safely evaluated before the result of that evaluation is passed to if. ;- Elan >> [: - )]
[REBOL] CGI interpreter on win95 apache Re:
Hi kenss, At 11:40 AM 2/24/00 +0800, you wrote: > > How can I make rebol a cgi interpreter on win95 apache ? > > I can easily make perl work. Just copy the perl script to cgi-bin and > make sure a #!C:/PERL/BIN/PERL at the top. I don't even need to touch > the apache .conf files. You may "not even need to touch ...". That may mean that Apache was already configured to support perl. Or MS Windows is configured to support Perl and perhaps therefore Apache does not need to be configured. I'm using Apache on a Win95 system and it works just fine. Here are my settings. The only file that needs to be modified is httpd.conf 1. ServerName must be configured to something sensible. If you are using Apache locally then simply removing the comment character, #, will be sufficient. Otherwise you must use the domain name of your si2. te or its IP Number: #ServerName new.host.name 2. You must add ExecCGI to the Options line: Options Indexes FollowSymLinks ExecCGI 3. Are you using the default CGI directory cgi-bin for your scripts? C:\Program Files\Apache Group\Apache\cgi-bin 4. Check the first line of your CGI script. If rebol is in the directory c:\rebol, your first line in the script should read: #!C:/REBOL/REBOL.EXE --cgi --script 5. Verify that your script begins its output by printing: print "Content-Type: text/html^/^/" followed by a proper html page. A simple example: print "Content-Type: text/html^/^/" print { Testing This is a test. } ;- Elan >> [: - )]
[REBOL] System... and the other objects! Re:
Hi Matos, >How can I know wich objects, variables and other things exist under an >object?! use and look at Bo's system browser (browse-system.r) which should be on rebol.org. If you can't find it let me know off-list and I'll mail it to you. In short, as Jan pointed out, you can access a block containing all the words defined in an object using first object-name: >> object: make object! [word-1: "this is word-1" word-2: "this is word-2"] >> print mold first object [self word-1 word-2] Note that the first word in every object is self, which evaluates to the object itself. When you inspect the object word by word you will want to skip the first word, since you are interested in the words defined in the object and not the complete object. You can use a loop like this: foreach word next first object [ print [ mold word mold get in object word ] ] to print each word and its value. In our example this will result in: >> foreach word next first object [ [ print [ [ mold word [ mold get in object word [ ] [] word-1 "this is word-1" word-2 "this is word-2" ;- Elan >> [: - )]