World: r3wp
[Core] Discuss core issues
older newer | first last |
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 ? | |
Vincent 28-Apr-2005 [969] | does port: open/binary tcp://219.147.198.195:1085 work? |
Anton 28-Apr-2005 [970] | >> system/schemes/default/timeout == 30 |
Micha 28-Apr-2005 [971x5] | open 219.147.198.195 1080 ping: 6312 |
how do to check loam time it will to flow away when port opens ? | |
handler: func [port action arg /local cmd send ping] [ switch action [ init [print "init" set-modes port [timeout: 00:05:00]] adress [print arg ] open [ping: to-integer (0:05:00 - get-modes port 'timeout )* 1000 ] close [print "close" close port] ] ] check: func [ p h] [ open/direct/binary/async join tcp:// [ p ":" h ] :handler ] check 219.147.198.195 1080 halt | |
how do to write this using harbour / awake ? without using from port / async ? | |
handler: func [port action arg /local ping] [ switch action [ init [print "init" set-modes port [timeout: 00:05:00]] adress [print arg ] open [print "open" ping: to-integer (0:05:00 - get-modes port 'timeout )* 1000 ] close [print "close" close port] ] ] check: func [ p h] [ port: open/direct/binary/async join tcp:// [ p ":" h ] :handler ] check 219.147.198.195 1080 | |
Anton 28-Apr-2005 [976x2] | gm: func [port][reform ["timeout:" get-modes port 'timeout]] handler: func [port action arg /local cmd send time] [ time: now/time/precise switch action [ init [ print [time gm port "--- init"] set-modes port [timeout: 0:00:05] ; five seconds ] address [print [time gm port "--- address lookup: " arg]] open [print [time gm port "--- open:" now/precise]] close [print [time gm port "--- close"] close port] error [print [time gm port "-- error:" mold disarm :arg] close port] ] ] check: func [p h][ open/direct/binary/async join tcp:// [ p ":" h ] :handler ] check 219.147.198.195 1080 |
I do not know how to do it non-async. | |
Micha 28-Apr-2005 [978x3] | how I use open / async harbour this after a dozen or so minutes application be closes |
handler: func [port ] [ ping: to-integer (0:00:30 - get-modes port 'timeout )* 1000 print [ "open" port/remote-ip port/remote-port "ping:" ping ] insert port join #{0401} [debase/base skip to-hex 80 4 16 to-binary 193.238.73.117 #{00} ] ] port: make port! tcp://219.147.198.195:1080 set-modes port [timeout: 00:01:00] port/awake: :handler insert tail system/ports/wait-list port open/binary port | |
how do to send to portu data when it is open ? | |
Pekr 30-Apr-2005 [981x5] | You can send data to your port using 'insert .... syntax is: insert port "hello" |
Micha - look at some cookbook articles for e.g. - http://www.rebol.net/cookbook/ | |
More about Rebol TCP networking - http://www.rebol.com/docs/core23/rebolcore-13.html | |
http://www.rebol.com/docs/core23/rebolcore-14.html | |
http://www.rebolforces.com/ | |
Micha 30-Apr-2005 [986] | rebol [] conn: make port! tcp://:80 black-lista: [ 69.64.51.223 194.69.207.145 80.252.0.145 194.69.207.165 217.73.17.115] adns: open/no-wait make port! dns:///async adns/awake: func [port /local dat][ data: copy port print data false ] insert tail system/ports/wait-list adns heandler: func [ port /local data dns ] [ print "new connetion" serwer: first port client: make port! tcp://222.76.73.113:1080 serwer/sub-port: client client/sub-port: serwer set-modes client [no-wait: true timeout: 00:01:00] set-modes serwer [no-wait: true ] wait serwer data: copy serwer dns: to-tuple copy/part skip to-binary data 4 4 insert adns dns ;print dns name either find black-lista dns [ close serwer print "firtled" print read join dns:// dns ] [ insert serwer join #{005A} [debase/base skip to-hex serwer/port-id 4 16 to-binary dns ] insert tail system/ports/timeout-list client open/binary client ping: to-integer (0:01:00 - get-modes client 'timeout )* 1000 print [ "open" ping ] insert client data wait client data: copy client client/awake: :response serwer/awake: :request insert tail system/ports/wait-list client insert tail system/ports/wait-list serwer ] false ] request: func [ port /local data ] [ data: make string! 10000 read-io port data 10000 either data <> {} [ insert port/sub-port data ] [ close port remove find system/ports/wait-list port port print "close connetion serwer" print length? system/ports/wait-list ] halt] response: func [ port /local data ] [ data: make string! 10000 read-io port data 10000 either data <> {} [ insert port/sub-port data ] [ close port remove find system/ports/wait-list port port print "close connetion client" print length? system/ports/wait-list ] halt] conn/awake: :heandler set-modes conn [no-wait: false] insert tail system/ports/wait-list conn open/direct/binary conn print "proxy" halt |
older newer | first last |