[REBOL] Split-path correction Re:
From: [EMAIL PROTECTED] Hi, after having some problems with split-path, here is my version: (Andrew, it may be nice to have it in your %patch.r) Not yet, Andrew ! split-path: func [ { Splits a file or URL. Returns a block containing path and target. Not always. It has other bugs than the original. It breaks the splitting of URLs (I called your version split-path2) : split-path http://fgdfgdfg.Fgdfg/fgdfgdfg/dfgdfg == [http://fgdfgdfg.Fgdfg/fgdfgdfg/ %dfgdfg] split-path2 http://fgdfgdfg.Fgdfg/fgdfgdfg/dfgdfg == [http://fgdfgdfg.Fgdfg/fgdfgdfg/ dfgdfg] Overcomes some limitations of the Core split-path like strange results for: split-path %file.r split-path %dir/ split-path to file! "" The last expression can also be written like that : split-path %"" Moreover, the identity: file = (append copy first r: split-path file second r) is always preserved. Remember that you can have a look to the source of the original split-path to improve it : source split-path Olivier.
[REBOL] Split-path correction Re:(2)
Andrew Martin wrote: [EMAIL PROTECTED] wrote: split-path %file.r split-path %dir/ These ones, I feel, aren't a problem. The existing implementation of split-path is correct, I believe. There is a problem. Look at the type of the second element of the result : split-path %fdgd/file.r == [%fdgd/ %file.r] split-path %file.r == [%./ "file.r"] In one case it is a string!, in the other it is a file!. There is also others problems with the original split-path: split-path http://www.rebol.com == [http:// %www.rebol.com] split-path http://www.rebol.com/ == [http:// %www.rebol.com/] I would prefer to get == [http://www.rebol.com/ none] in both cases, as in the following: split-path %/ == [%/ none] To summarize, split-path is so inconsistent that I will never use the current version for real work. clean-path is as buggy (even more) : clean-path http://www/dfhfgh/../fghfgh == http://www/dfhfgh/../fghfgh (doesn't remove . and .. in URLs) clean-path %"" ** Script Error: Out of range or past end. ** Where: first target-copy What would be cool, in fact would be a reference test suite for every function of REBOL. Every Perl module provide such tests to assure consistence between platforms. It seems that Rebol (the company) doesn't use such methods to assure code quality. But it's not too late to take another way than Microsoft's. Olivier.
[REBOL] [BUG] unset!
Look at that : type? %f == file! type? == unset! So unset! seems to be a datatype. Lets verify if unset! is a datatype : type? file! == datatype! type? unset! ** Script Error: unset! has no value. ** Where: type? unset! But : type? type? %f == datatype! type? type? == datatype! So, is unset! a datatype! or not ? This also has an impact when using "mold" and "do" : do mold type? %f == file! do mold type? ** Script Error: unset! has no value. ** Where: unset! Olivier.
[REBOL] [BUG] help function lie!
Look at this : type? 'afgfgh == word! help 'afgfgh afgfgh is word This is ok. type? file! == datatype! help file! file! is word of value: file This not ok! Olivier.
[REBOL] newsgroups Re:
Hi, If your are using news:// protocol/dialect (described in the how-to http://www.rebol.com/howto.html#news.html) rather the built in nntp:// protocol (described in the manual http://www.rebol.com/users/netnntp.html) You need to do the %nntp.r file.. do %nntp.r Cheers, Allen K - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, February 27, 2000 11:15 PM Subject: [REBOL] newsgroups WITH THE FOLLOWING SCRIPT... REBOL [] secure none print "security level set to none" nntp-host: news://news.uswest.net np: open nntp-host print "news host opened" write/append %BeAdvocacyMessages.txt insert np [headers-bodies from "comp.sys.be.advocacy"] print "messages retrieved" I GET THE FOLLOWING ERROR... ** Access Error: Invalid port spec: news://news.uswest.net. ** Where: np: open nntp-host print "news host opened" WHAT AM I DOING WRONG? THANKS.
[REBOL] %mensaje.txt
%mensaje.txt
[REBOL] redirecting input and output
Hello, and sorry for previous message Does anyone know how to use the redirecting input feature of Rebol? I have been trying it but it doesn´t seem to work. I have tried on Windows things like: rebol -w in out where the file "in" is: print "hello!!" Redirecting only output works as I expect: rebol -w script.r out
[REBOL] where does that space come from? Re:
tf wrote: when running this very simple thing, after I'm prompted with "what day?" REBOL hangs. the rest of the prompts come up "correctly" after I hit enter. Why is that? I tried it, after commenting out this line: change-dir %/home/ 'cause I've got no directory with that name, and got: Script: "Title Here" (27-Dec-1999) What Day? Monday How many hours? 3 What did you do? Took attendance records for local school. What Jobsite? Colenso HS with this in %mytime.txt: Day: Monday Hours:3 Task(s): Took attendance records for local school. Jobsite: Colenso HS It seems OK to me, except for the leading space before these lines: "Day:" and: "Hours:" But that's due to the space in this: [{^/ Day: } day {^/ Hours: after each newline character. What's the problem? :-\ Andrew Martin ICQ: 26227169 http://members.xoom.com/AndrewMartin/ -- - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, 23 February 2000 12:14 AM Subject: [REBOL] where does that space come from? where does that space come from? Hey guys, when running this very simple thing, after I'm prompted with "what day?" REBOL hangs. the rest of the prompts come up "correctly" after I hit enter. Why is that? #!/path/to/rebol -sc REBOL [ Title: "Title Here" Date: 27-Dec-1999 File: %file.r ] change-dir %/home/ day: ask "What Day? " hours: ask "How many hours? " describe: ask "What did you do? " jobsite: ask "What Jobsite? " output: rejoin [{^/ Day: } day {^/ Hours:} hours {^/Task(s): } describe {^/Jobsite: } jobsite {^/}] write/append %mytime.txt output
[REBOL] [BUG] unset! Re:
Olivier wrote: So, is unset! a datatype! or not ? Eric discovered this sometime ago. It's a bug that REBOL crew haven't got around to fixing yet. In my most recent %Patch.r file, this is fixed with this code: if not value? 'unset! [ unset!: (type?) ] if not value? 'action! [ action!: type? :action? ] Andrew Martin ICQ: 26227169 http://members.xoom.com/AndrewMartin/ -- - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, 28 February 2000 2:14 AM Subject: [REBOL] [BUG] unset! Look at that : type? %f == file! type? == unset! So unset! seems to be a datatype. Lets verify if unset! is a datatype : type? file! == datatype! type? unset! ** Script Error: unset! has no value. ** Where: type? unset! But : type? type? %f == datatype! type? type? == datatype! So, is unset! a datatype! or not ? This also has an impact when using "mold" and "do" : do mold type? %f == file! do mold type? ** Script Error: unset! has no value. ** Where: unset! Olivier.
[REBOL] Split-path correction Re:(3)
Olivier wrote: There is a problem. Look at the type of the second element of the result : split-path %fdgd/file.r == [%fdgd/ %file.r] split-path %file.r == [%./ "file.r"] In one case it is a string!, in the other it is a file!. I haven't come across that one! I agree totally that that's a problem. There is also others problems with the original split-path: split-path http://www.rebol.com == [http:// %www.rebol.com] split-path http://www.rebol.com/ == [http:// %www.rebol.com/] I would prefer to get == [http://www.rebol.com/ none] in both cases, as in the following: split-path %/ == [%/ none] I would prefer the result of: split-path http://www.rebol.com and split-path http://www.rebol.com/ to both be: [http://www.rebol.com/ %.] In other words, the target is the current directory of the path: http://www.rebol.com I would prefer the result of: split-path %/ to be: [%/ %.] The target is the current directory of the root. To summarize, split-path is so inconsistent that I will never use the current version for real work. clean-path is as buggy (even more) : clean-path http://www/dfhfgh/../fghfgh == http://www/dfhfgh/../fghfgh (doesn't remove . and .. in URLs) clean-path %"" ** Script Error: Out of range or past end. ** Where: first target-copy What would be cool, in fact would be a reference test suite for every function of REBOL. Every Perl module provide such tests to assure consistence between platforms. Totally agree. This is a job that list members could implement most of the test code for, perhaps? It seems that Rebol (the company) doesn't use such methods to assure code quality. But it's not too late to take another way than Microsoft's. Agreed. Andrew Martin ICQ: 26227169 http://members.xoom.com/AndrewMartin/ --
[REBOL] where does that space come from? Re:
On Sun, Feb 27, 2000 at 06:00:03PM -0800, [EMAIL PROTECTED] wrote: It seems OK to me, except for the leading space before these lines: "Day:" and: "Hours:" But that's due to the space in this: [{^/ Day: } day {^/ Hours: after each newline character. What's the problem? :-\ Well, if I fire up the REBOL console and run it, it goes as expected. Only I don't want to fire up the console. I added the bang-path to the script and made it executable... Then when I run it, I get the first question, and then a blank line on which the cursor sits forever. I used #!/usr/local/bin/rebol -cs It's not a problem, really. I was just curious because it seems like strange behavior... -- -Tom
[REBOL] [BUG] unset! (and help function lie!)
Hi Olivier, you wrote: So unset! seems to be a datatype. Lets verify if unset! is a datatype : type? file! == datatype! type? unset! ** Script Error: unset! has no value. ** Where: type? unset! One of REBOL's most confusing issues is that representations of some values look exactly like the words they are assigned to. These values cannot be directly parsed by REBOL - first they are parsed to words, and then the word is evaluated. When you did: type? file! == datatype! REBOL first parsed the string you typed, "file!", to the word file!, and then when that word is used as the argument of TYPE? it is evaluated. The word FILE! is preset to the datatype! file!, which is the value that the function TYPE? sees. Try this: a: [type? file!] == [type? file!] type? first a == word! type? second a == word! While they're still in an unevaluated block, type? and file! are still just words. But when you do (that is, evaluate) that block, the correct answer comes out: do a == datatype! Here's another way to look at this: a: ['type? file!] == ['type? file!] type? first a == lit-word! a: reduce a == [type? file!] type? first a == word! type? second a == datatype! First I made a block with one lit-word! and one word! . Then when I reduced the block, the lit-word! was evaluated to a word! , and the word file! was evaluated to its preset value, the datatype! file! . If we do that block: do a == datatype! we still get the same answer, because when you evaluate a datatype! you just get the same datatype! . Now the problem with unset! is that there is no word set to the value unset! . This is easily fixed: unset: (type?) == unset! type? unset! == datatype! I put the paren around type? because if you do this in a script TYPE? will take the value of whatever is next, but the paren prevents TYPE? from seeing anything else. You also wrote: type? file! == datatype! help file! file! is word of value: file This not ok! It seems inconsistent, but this is the result of a REBOL trick. HELP has a special way of specifying its argument: help: func [ "Prints information about words and values." 'word [any-type!] /local value args item refmode types ][ snip ] The argument is specified as a lit-word! (by using the ' ). This specifies that if the argument is actually a word, that word is to be unevaluated. That is, HELP wants to see the word itself, not what the word is set to. This way you can use HELP to test if a word is set to a value: help grog No information on grog (word has no value) Otherwise, trying to evaluate the word grog would result in an error before HELP even had a chance to see it. So, if you want to get help on the value that the word is set to, try this: help (file!) file! is datatype help file! file! is word of value: file Putting the word file! in a paren prevents HELP from seeing it as a word. So the paren is evaluated, the datatype! file! comes out, and HELP tells you that the datatype! file! is a datatype. One other little issue here is that there are two ways of representing a value, forming and molding. Molding is better in that it gives you a string that REBOL can use to get back the original value, but forming is supposed to be easier on the eye. HELP forms the values, which is why you lose the ! 's. See you, Eric
[REBOL] New Floating-Point Functions
Hi Folks Eric and I have just posted a new script to the REBOL script library. You can download it directly from: http://www.rebol.org/math/decimal.r The purpose of this package of functions is to improve REBOL'S support for floating-point mathematics. It provides many of the capabilities present in languages like C and FORTRAN, but which are currently unavailable in REBOL, such as native binary I/O. The package is the result of a collaboration between Eric Long, myself, and Gerald Goertzel. Comments, questions and suggestions are welcome. We are especially interested in whether these functions (which have only been tested with the Windows version of REBOL) produce the same results on other platforms and non-Intel CPU's. Please address any comments to the REBOL mail-list or send them directly to me at [EMAIL PROTECTED] The package is heavily documented with comments and examples. The functionality is encapsulated in just three objects: REAL, IEEE, and EMPIRICAL. These are the only names that are added to the global context. The REAL object- This object contains many functions for the manipulation and examination of REBOL decimal values. Among other things, these functions provide full support for native binary floating-point file IO, compatible with C, FORTRAN, etc. REBOL decimal and money values may also be saved transparently in a native binary hex-string and loaded without incurring roundoff error. These functions are necessary because the standard REBOL representation of decimal values may round off one or two significant digits, and the rounding of money values is an even greater source of error. Outline of functions in the REAL object- Main Interface Functions FORM Returns precise decimal representation (requires format.r). SHOW Returns a string showing the bits in the IEEE representation. TO-NATIVE Converts a decimal value into a native IEEE binary FROM-NATIVEConverts an 8-byte native binary into a decimal value. SAVE Saves a value with all decimal values converted. LOAD Loads a value and restores 8-byte binaries to decimals. WRITE Writes a block of decimal values to a file in native form. READ Reads a file containing a series of decimal values expressed in native form. Helper Functions SPLIT Returns a block with the three components of the IEEE double floating point representation of a decimal value. CONVERTConverts all decimal values to native binaries, leaves other values untouched. RESTORERestores 8-byte binaries to decimal values. TO-BIN Returns a binary string representation or a numeric value. FROM-BIN Returns the integer represented by string of 1's and 0's. TO-MATRIX Converts a flat block into nested blocks of any depth. Most of the functions come in pairs: SAVE -- LOAD WRITE -- READ TO-NATIVE -- FROM-NATIVE CONVERT -- RESTORE TO-BIN -- FROM/BIN These pairs have the property of reversing exactly (i.e., FROM-BIN TO-BIN X yields X). The IEEE and EMPIRICAL objects--- These provide several utility functions useful for more in-depth exploration of the details of floating-point numbers in REBOL and testing the REBOL comparison functions. The two objects provide similar functionality but differ in implementation. In the IEEE object all of the values are calculated according to the IEEE754 standard for double-precision floating-point. In the EMPIRICAL object, the values are calculated using an iterative empirical method (similar to root-finding). Most of the calculations in both are done in binary. Outline of functions in the IEEE and ENPIRICAL objects REBTEST A function that tests the sensitivity of the REBOL EQUAL? comparison function. GET-NEXT A function that makes the minimum increment to a decimal value. GET-LAST A function that makes the maximum decrement to a decimal value. MAX-REAL The largest decimal value. MIN-NORM The smallest positive normalized decimal. (IEEE only) MIN-REAL The smallest positive decimal value. EPS The minimum increment to 1 (smallest x such that (x+1)1). REBTEST illustrates some flaws in the implementation of the REBOL comparison functions (as of version 2.2), but note that it is easy to get exact comparisons by using ZERO? NEGATIVE? and POSITIVE? to test the results of subtraction. Using FORMAT Several of the functions can optionally use the full-precision formatting available in Eric's FORMAT function. These functions are: real/form real/show/decimal IEEE/rebtest empirical/rebtest You can download FORMAT at http://www.rebol.org/math/format.r If you wish to use it in conjunction with DECIMAL, you should load format.r before loading decimal.r. Note: None of the examples given in this post make use of FORMAT. There is way too much in this package to describe in