r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Pekr
15-Mar-2006
[3700x3]
if I have something like following:

event: wait [server client1 client2 ... clientx 0.001]
if block? event [event: first events]


and now I just maintain one port and its data, I wonder what happens 
with next 'wait? Remember I am not using wait/all, but still I am 
not sure, what happens if there is even waiting on more than one 
port?
... or simply without /all refinemet 'wait will always return only 
one of ports, even if data is waiting on multiple of them?
will not I loose data when 'wait is entered for the second time because 
of "if block? event [event: first event]"? Hopefully not ... or maibe 
wait without /all never returns a block, even if there is event on 
more than one port at a time?
sqlab
15-Mar-2006
[3703]
If I remember right, you get only the first event, the others will 
still appear as long as you did not satisfiy them.
Pekr
15-Mar-2006
[3704]
ok ... so what happens if there is still data on first port in the 
wait-list? will it always return that one? So it means that other 
ports will simply wait for maintanance, because first port in the 
wait-list is still receiving a data?
sqlab
15-Mar-2006
[3705]
I do not know if you will get your first port again as the first, 
if you did for example just copy/part from it.

But imagine, that you do a copy on it, and new data arrives at the 
same time. This will probably raise a new event on it and this port 
will probaby the last in your queue of waiting events.
Pekr
15-Mar-2006
[3706]
ah, thanks a lot ... so wait [port1 ... portn] does not anything 
in common with the order how 'wait returns the events? That is good, 
because otherwise I would maintain only first port, till the data 
would not stop appearing ...
sqlab
15-Mar-2006
[3707x2]
Just what I think is a little bit annyoing, that sometimes you do 
not get the proper timeout, if you have a timeout value in your wait 
list  and many events.

Yes, I always thought that I got the ports ordered according their 
event time and not according their position in the event list.
I have to correct me.
I just tested this approach, and it does not look so good.
It always gave me the data from one port
Pekr
15-Mar-2006
[3709x4]
ah, that is bad .... but expectable ... so I have to prioritise ports 
myself and probably always use wait/all ... but then - I am not sure 
I want to maintain them all at once ....
but maybe that is the only corrent aproach - to use wait/all and 
maintain data on all ports in a loop, then go for the next wait ...
or, to use random to pick ports randomly :-) .... but it is interesting 
that 'wait returns events according to wait-list order ....
anyway - I am doing very small util for my friend who programs our 
new board for kiosk system event detection and am having fun with 
it :-)
sqlab
15-Mar-2006
[3713]
Just use small messages.

I gather every day messages in the tenth of thousands with peaks 
during the working hours and it is working so far.
Pekr
15-Mar-2006
[3714]
yes, it surely will work ... I was just curious what would by the 
correct aproach for multiplexing engine ....
sqlab
15-Mar-2006
[3715x2]
My test now revealed, that you will maintain the port you get as 
first, until it is empty, but then there is always some prioritize.
I just tested it with awake functions and this gave me data from 
two ports alternately.  Thanks god, that I use this approach since 
I heard about it. Probably the efficiency and the time granularity 
there is higher.
Robert
21-Mar-2006
[3717x4]
How can I avoid the scientific notation?
>> round/to (sm/n * sm/s * 0.9) 0.0001
== 9E-2
I want to get back: 0.09
>> round/to (sm/n * sm/s * 1.111231) 0.0001
== 0.1111
It seems that only for values < 0 the E notation is used.
Pekr
21-Mar-2006
[3721]
I wrote the function for it. It was debated several times, but I 
do not remember if some solution came-up ...
Tomc
21-Mar-2006
[3722x4]
robert the short but usless answer is don't use windows
other platforms do not have this behavior
should also be noted that other  langs i.e. perl exibit the same 
behavior on windows do it is apt to be an OS call that decides two 
decimal places is wau too heady for its users
that said it has been solved here and on the maillist several times
Geomol
21-Mar-2006
[3726x2]
Robert, here is my solution used in Canvas:

form-decimal: func [n /local p d] [
	n: form n
	if p: find n #"E" [
		if d: remove find n #"." [d: index? d p: back p]
		if not d [if d: remove find n #"," [d: index? d p: back p]]
		if not d [d: index? p]
		either p/2 = #"-" [
			insert/dup n #"0" (to-integer skip p 2) - d + 1
			insert n "0."
		][
			insert/dup p #"0" (to-integer next p) - (index? p) + d
		]
		clear find n #"E"
	]
	n
]
>> form-decimal 9E-2
== "0.09"
JaimeVargas
21-Mar-2006
[3728]
Robert you can use the PRINTF wrapper function in rebol.org. It helps 
with all kinds of number formating.
Robert
21-Mar-2006
[3729]
Thanks a lot. But I really can't believe that this formatting stuff 
isn't supported by default.
sqlab
22-Mar-2006
[3730x2]
>> form-decimal -0.099
== "0.-99"
rebol []
form-decimal: func [n /local p d s] [
	all [s: negative? n n: abs n]
	n: form n
	if p: find n #"E" [
		d: index? any  [
			all [ d: remove find n #"." 	p: back p	d]
			all [ d: remove find n #"," 	p: back p	d]
			p
		]
		either p/2 = #"-" [
			insert/dup n #"0" (to-integer skip p 2) - d + 1
			insert n "0."
		][
			insert/dup p #"0" (to-integer next p) - (index? p) + d
		]
		clear find n #"E"
	]
	if s [insert n "-"]
	n
]
Maxim
22-Mar-2006
[3732x2]
can anyone refresh my memory as to how to insert new lines within 
blocks so that saved blocks are tidy?
I have searched the net, the update docs and have no found it.  ' 
:-/
Ladislav
22-Mar-2006
[3734]
see NEW-LINE
Maxim
22-Mar-2006
[3735x3]
thanks !   I feel a little dumb ... hehe
strange, I just searched it again, and for some reason, now, new-line 
is the first thing returned in google... damn... last week it wasn't 
in the first 3 pages   > :-(
ahhh...  I had searched for "rebol newline" ,  searching is subtle 
sometimes.<Petra2PnrXmlResponse>
Anton
23-Mar-2006
[3738]
I knew that name would cause trouble.
Pekr
24-Mar-2006
[3739]
how to substract two dates including time?
Sunanda
24-Mar-2006
[3740]
difference in recent versions will subtract dates and times
Pekr
24-Mar-2006
[3741x2]
hmm, not sure .... is difference any different from date1 - date2
I mean - when substracting two 'now values, the time is not being 
taken into account ..
Sunanda
24-Mar-2006
[3743]
>> a: now - 125:00:00
== 19-Mar-2006/9:08:07
>> a - now
== -5    ;; five days
>> difference a  now
== -125:00:16    ;;; 125 hours
That's the difference!
>>
Rebolek
24-Mar-2006
[3744]
There must be no timezone present
Pekr
24-Mar-2006
[3745]
why should be difference call different to simple usage of minus 
op?
Sunanda
24-Mar-2006
[3746]
it's a strange hack -- difference was originally for sets. So making 
it work for time is seriously non-orthogonal.
Pekr
24-Mar-2006
[3747]
I hate those hacks
JaimeVargas
24-Mar-2006
[3748]
Maybe we need three types instead of two. date! time! and idate! 
or stamp!
Gabriele
24-Mar-2006
[3749]
difference hadles timezones too.