World: r3wp
[Core] Discuss core issues
older newer | first last |
Gabriele 25-Sep-2006 [5444x2] | henrik, use a block, not a url, i.e. open [scheme: 'ftp user: "\\\" ...] |
anyway, the problem is that rebol decodes percent-encoded characters in urls way too early, otherwise you would just encode the problematic char. (block format is still easier imo) | |
Graham 28-Sep-2006 [5446] | is it faster to load a string to see if it is a date, or try make date! and catch the error to peform the alternate action ? |
Oldes 28-Sep-2006 [5447x4] | I do error? try [date: to-date date] |
to-date! | |
no to-date:-) | |
>> t: now/time/precise loop 10000 [error? try [to-date "sss"]] now/time/precise - t == 0:00:00.047 >> t: now/time/precise loop 10000 [date? load "sss"] now/time/precise - t == 0:00:00.016 >> t: now/time/precise loop 10000 [error? try [to date! "sss"]] now/time/precise - t == 0:00:00.047 | |
Graham 28-Sep-2006 [5451] | so, it appears to be more than twice as fast to use 'load |
Henrik 28-Sep-2006 [5452] | I remember a discussion where it was concluded that load would sometimes not be useful for determining date validity. |
Graham 28-Sep-2006 [5453x4] | but then if the string is not a valid datatype .. you could cause an untrapped error. |
So, you have to wrap the whole operation around a try block anyway | |
Does 'load affect the global name space at all? | |
Henrik .. you're suggesting use to-date instead ? | |
Henrik 28-Sep-2006 [5457] | haven't tested it. I just remember the discussion. :-) |
Gabriele 28-Sep-2006 [5458] | to date! supports more date formats than load (for obvious reasons) |
Graham 28-Sep-2006 [5459x2] | got a quick example? |
of what you mean ..? | |
Gabriele 28-Sep-2006 [5461] | >> to date! "10 10 06" == 10-Oct-2006 |
Graham 28-Sep-2006 [5462] | oh .. interresting. Didn't know you could do that. |
Gabriele 28-Sep-2006 [5463] | >> to date! "2006.10.10" == 10-Oct-2006 |
Graham 28-Sep-2006 [5464x2] | In fact I didn't know u didn't need the "-" in to-date ! |
are 'to and 'make the same words? | |
Gabriele 28-Sep-2006 [5466x3] | no, but they should be the same in this case. |
>> to block! 10 == [10] >> make block! 10 == [] | |
(as an example of the difference) | |
Graham 28-Sep-2006 [5469] | I'm goingt to stick to my to-date and error trap it ... :) |
sqlab 29-Sep-2006 [5470] | I am just transferring many files via ftp to a FTPZilla on Windows. Aftert some time the ftp hangs. If I use one steady connection, it hangs writing. If I use one connection per file, it hangs with the message connecting. Anyone seen a similar behaviour ? |
Graham 29-Sep-2006 [5471x2] | are u using Romano's patches? |
Latest core etc ? | |
sqlab 29-Sep-2006 [5473] | I use the ones based on 2.6.3 |
Graham 29-Sep-2006 [5474] | trace/net ? |
sqlab 29-Sep-2006 [5475] | It seems, that it is dependant of system/console/break. With false, it hangs, with true it works. |
Oldes 29-Sep-2006 [5476] | Graham: as I need the date conversion again, I found that to make it useful, you have to add the error check anyway so it's: >> t: now/time/precise loop 10000 [all [not error? try [d: load "sss"] date? d]] now/time/precise - t == 0:00:00.031 >> t: now/time/precise loop 10000 [all [not error? try [d: load "1-1-2007"] date? d]] now/time/precise - t == 0:00:00.047 >> t: now/time/precise loop 10000 [error? try [to-date "1-1-2007"]] now/time/precise - t == 0:00:00.047 I would not use loading. to-date is more clear, shorter and with same speed. |
Graham 29-Sep-2006 [5477x8] | I agree. |
Anyone got a csv parser that works with embedded quotes? | |
I tried Bo's, Gabriele's, Gregg's ... all fail as far as I can see. | |
Gabriele's parser dies with empty fields eg ,"", ... | |
Gregg's, and Bo's and mine don't report an error and parse it incorrectly | |
Joel Neely's ... written in Sep 2000 takes the prize for parsing by reporting an error in the line in question. | |
Excel managed to parse the file correctly ... | |
Moving to parse group | |
james_nak 29-Sep-2006 [5485] | I'm attempting to add a "repeat command" button to an app but I need to capture the what was sent to a function including the refinements. I'll put that capturing code inside the function called and store it in a global. The arguments, of course, are no problem to save. |
Gordon 29-Sep-2006 [5486] | When you import data using "data: read/binary {sometextfile}" you seem to get a string of hex values. Ex: probe 'data' of a file containg the word "Hello" results in #{48656C6C6F} but if you probe first data it returns 72. So when you probe the entire data stream it returns it in hexidecimal format but when you probe each character it returns a decimal value. At any rate how do you convert the characters in the variable 'data' back into ASCII values? IOW, how do you convert the decimal value of 72 back into an "H" or the #{48656C6C6F} back into "Hello"? |
PeterWood 29-Sep-2006 [5487] | >> a: 72 == 72 >> to char! a == #"H" >> b: #{48656C6C6F} == #{48656C6C6F} >> to string! b == "Hello" |
Maxim 29-Sep-2006 [5488] | sometimes REBOL is to simple. we forget that it can be as simple as that. ;-) |
Gabriele 30-Sep-2006 [5489] | graham: i think mine dies because of the wrong quoting, not empty fields, but i haven't tested it. i would actually be surprised to see a csv parser that handles quoting that way, because the only way to handle them is to ignore them. |
Anton 30-Sep-2006 [5490] | Gordon, use TO-STRING or AS-STRING. |
MikeL 30-Sep-2006 [5491] | Gordon, This may be too obvious to mention but if you know it is not a binary file then don't read it with the /binary refinement then you won't need to convert. |
Gordon 30-Sep-2006 [5492] | Hi guys; Thanks for the input. PeterWood & Anton: I could have sworn that I tried both to-char and to-string. It is the obvious answer, but I have been trying so many things in solving a parse problem that I missed it. Now I remember, I did try them but at the time I complicated the character testing by using quotes and brackets and braces, or in the case of the hex string - not using the #{}. Anyway, thanks for your time in answering. Gabriele: As I was waking up this morning, I was thinking about modifying your CVS parser to make it work with (improperly) quoted strings. That may be the simplier answer to my parsing problem. MikeL: I started by not using the /binary but then the 'read' converts the #{0D0A} sequences to just #{0A} so I was going to try using the /binary option to preserve the original #{0D0A} and got sidetracked into changing the rest of the file back into a string. Turns out that I will be going back to just using the 'read' without the /binary option and try modifying Gabriele's, CVS parser to handle improperly embedded quotes. |
Gabriele 30-Sep-2006 [5493] | gordon, can you just ignore the quotes? (if you know they are not really relevant in your file) |
older newer | first last |