World: r3wp
[Core] Discuss core issues
older newer | first last |
Ingo 14-Apr-2005 [919] | Thanks Vincent |
Brock 15-Apr-2005 [920x4] | Is this a bug? 1) I read a directory on our ftp server and return a set of files of which 02 EN AR final.pdf is one of them 2) I then copy a URL address that returns a 404 indicating it couldn't find the file in question ie. http://www.cpcpension.com/files/2002EN AR final.pdf 3) I do a split-paths to-url on the contents of the clipboard:// that contains item in step 2) 4) I compare the file names for equality either using "=" or equal? and both return false 5) I check the type of each file, they are both 'file' types 6) I check the length of each file, the one from step 1) returns 20, step 2) returns 26 So, somewhere it is changing the representation of a space into the actual string " ". Any ideas? 6) |
When I execute this command... print second split-path to-file to-string http://www.cpcpension.com/files/2002EN AR fin al.pdf it returns.... 2002 EN AR final.pdf it converted the 's in the URL | |
oops... url wrapped above | |
when I execute this command... print second split-path to-file to-string read clipboard:// where I have copied the URL above into the clipboard:// it returns.... 2002 EN AR final.pdf | |
MichaelB 15-Apr-2005 [924] | Could someone just show me how to get the 'unset? function return true ?! Maybe I'm a bit stupid, but I simply don't get it working. Isn't really important, but should still work. e.g. unset 'a bl: [a] unset? 'a unset? first bl ????? shouldn't this return true ????? |
Volker 15-Apr-2005 [925] | probe unset? () probe unset? get/any 'hey-what? |
Vincent 15-Apr-2005 [926] | MichaelB: unset? 'a <=> is the word 'a an unset! value -> no it's a word! value unset? first bl <=> is the first element of bl an unset! value -> no it's a word! value to know if a word as a value: value? 'word value? 'a == false but unset? () == true ; paren! are auto-evaluated, empty paren! -> unset! unset? print 2 == true ; 'print returns no value -> unset! unset? get/any 'a == true ; but as "a" is undefined, unset? a -> error! unset? unset 'a == true ; 'unset returns unset! 'unset? -> _value_'s datatype! = unset! unset! is for absence of value too: my-func [an-opt-arg [integer! unset!]][...] |
MichaelB 15-Apr-2005 [927] | - thank you for the answers, I knew there is something like that, just couldn't figure it out any more - actually I tried the unset? get .. version, but of course without the any refinement ... so couldn't work - I didn't know (or forgot) about the optional value possibility, good to know thanks again :-) |
Vincent 15-Apr-2005 [928x2] | Brock: 'to-url converts a string into an url without escaping, escaping is only done when showing the url string: to-url "http://www.cpcpension.com/files/2002EN AR final.pdf" ; works == http://www.cpcpension.com/files/2002EN AR final.pdf ; blanks -> to-url "http://www.cpcpension.com/files/2002EN AR final.pdf" ; don't works == http://www.cpcpension.com/files/2002EN AR final.pdf ; only looks the same, but contains "%" "2" "0" you can use 'do or 'load to interpret the string in clipboard: do read clipboard:// load read clipboard:// (same with 'to-file) |
Off course, I forgot: to-url dehex read clipboard:// | |
Brock 15-Apr-2005 [930] | Thanks for the explanations Vincent. The best solution appears to be to-url dehex read clipboard://. I totally forgot about dehex. |
Louis 18-Apr-2005 [931] | Thanks, Sunanda. Sorry to take so long to respond. I'm traveling and don't always have internet access. |
Brock 20-Apr-2005 [932x3] | I was thinking of adding a Cookbook entry along the following topic.... |
; Sorting Unordered Key/Value Pairs ;unordered key/value pairs, keys in each record aren't in the same order data: [ [fld1 "c" fld2 "1" fld3 "b2"] [fld1 "b" fld3 "a1" fld2 "3"] [fld3 "c" fld2 "2" fld1 "a"] ] ; sorts on first text found, value is not sorted sort data ; notice reverse sort on first text found, value is not sorted sort/reverse data ; sort on value for fld1 key - ascending order sort/compare data func[a b] [a/fld1 < b/fld1] ; sort on value for fld1 key - descending order sort/compare data func[a b] [a/fld1 > b/fld1] ; sort on value for fld2 key - ascending order sort/compare data func[a b] [a/fld2 < b/fld2] ; sort on value for fld2 key - descending order sort/compare data func[a b] [a/fld2 > b/fld2] | |
Any comments or suggestions of items to include/change prior to submitting. | |
Tomc 20-Apr-2005 [935] | when your compare func returns -1 0 1 instead of a bool you get stable sorts |
Brock 20-Apr-2005 [936] | Tom, not sure I follow. How do I check the return value of the compare func? |
Ammon 20-Apr-2005 [937] | Your /compare func is returning a boolean value because '< returns a boolean value. If you have it return -1 0 1 then you get a stable sort. |
Brock 21-Apr-2005 [938x3] | Okay, I think I am following. If my parameters to the function were numbers, then using the [sign? a/1 - b/1] would provide a more accurate sort due to the tri-state return of the sign? function. However, since I am sorting strings and can AFAIK only compare using <>=, are you suggesting I should test all of the states and return 1,0,-1 as appropriate? |
By the way, I was lead to my above solution and similar comments thanks to responses by Tom and Volker to Graham's question on AltME Rebol world - Core Group, 13 Aug,2004 @ 7:47pm. Thanks all. | |
; is this what I am after for the compare function? [ if a/1 > b/1 [return 1] if a/1 = b/1 [return 0] if a/1 < b/1 [return -1] ] | |
Sunanda 21-Apr-2005 [941] | You got it!. And a little shorter, and maybe faster: [ if a/1 > b/1 [return 1] if a/1 < b/1 [return -1] return 0 ] Of course, you only need to worry about stable sorting if you have duplicate keys and need to retain the original entry sequence for them. Other wise [return a/1 < b/1] is fine and fast. |
Tomc 21-Apr-2005 [942] | i.e. sorted by first name within sorted last name groups |
Alek_K 26-Apr-2005 [943] | I'm planning doing a database - in year it will be about 3000 records (30 fields each) What to use - some kind of rebol blocks (as here http://www.rebol.net/cookbook/recipes/0012.html ) or should I doing it with "mysql-protocol" by DocKimbel? |
Allen 26-Apr-2005 [944] | There is also http://www.dobeash.com/it/rebdb/ |
Sunanda 26-Apr-2005 [945] | REBOL.org holds nearly 42,000 emails in some kind of REBOL block -- plus various indexes. About 75meg (uncompressed) of data. So it's doable. Depends how much fun you want to have. Databases like MySQL are boring but straight-forward. Also *may* limit the platform you can run the application on. |
Alek_K 26-Apr-2005 [946] | I will do it rebol way. Thanks for answers! |
Claude 26-Apr-2005 [947x7] | hello |
i use rebol/command to connect a database (Iseries) by ODBC.. | |
i do like this | |
db: open odbc://iseries | |
stm: first db | |
insert stm {select * from filexxx} | |
well, my statement copy return data | |
Alek_K 26-Apr-2005 [954] | well - because my project is "at start" and budget is really low, i'm limited to Rebol/View functionality :o) |
Claude 26-Apr-2005 [955x5] | it is ok and good. But i would like to have the resultset metadata too !!!! |
how can i have metadata of my resultset with rebol.command | |
Alek_k, hi, i think there is already a little database name is DB.R | |
wait a minute !!! a seek to it | |
yes a have it, here is http://www.dobeash.com/it/rebdb/ | |
Alek_K 26-Apr-2005 [960] | (yes - i have it) |
Claude 26-Apr-2005 [961x2] | the real name is rebdb |
hello, someone a idea for me please !! | |
Ingo 26-Apr-2005 [963] | Hi Claude, I'm sorry I can't help you, but maybe the /core group is not the ideal place to ask about /command? Anyway, what metadata are you hinting at? |
sqlab 27-Apr-2005 [964] | Hi Claude, do you want to get the names of the columns? You do not get them by default. If you want just the names of the columns of a table, you should do like this insert stm ['columns "filexxx"] foreach column copy stm [probe column] look at sdk/doc/database.html#section-4.2 But beware, Rebol/Command does not support all datatypes, so maybe you will get some problems. Also depending how strict/relaxed your db system is "filexxx" should be written "FILEXXX" or as a fully qualified name. So better check with insert stm ['tables] what your db system expects. If you write a program, it is recommended, to name every column you want to get in your result set. Then you know the names too . |
Claude 28-Apr-2005 [965] | thank you sqlab |
Micha 28-Apr-2005 [966x3] | plis help ? |
port: make port! tcp://219.147.198.195:1080 >> port/timeout == none >> port/timeout: 0:00:30 == 0:00:30 >> open/binary port ** Access Error: Cannot connect to 219.147.198.195 ** Near: open/binary port | |
how to enlarge the time of expectation on connection ? | |
older newer | first last |