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

World: r3wp

[Core] Discuss core issues

Geomol
15-Oct-2005
[2332x2]
form-decimal: func [n /local p d] [
	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
]
Maybe there should be a
n: form n
in the beginning to support more datatypes.
Louis
15-Oct-2005
[2334]
Is there any way Rebol files can be made to be multi-user friendly?
Geomol
15-Oct-2005
[2335]
Louis, multi-user friendly!? What do you mean? That one user can 
lock a file for some time, so others can't access it? Or what?
Anton
16-Oct-2005
[2336x2]
Louis, in Core or View ? In View, you can read/write to the public 
cache.

This is VIEW-ROOT (the directory you selected during install, by 
default it is in a windows user profile directory).

When you click on an app from a rebsite, it is saved (by READ-THRU, 
PATH-THRU) into the public cache before running.
So, if it is your app, say at 
http://yoursite.com/app.r
then it could save prefs files to
path-thru http://yoursite.com/app-prefs.r
eg.
	save path-thru http://yoursite.com/app-prefs.r[my prefs data]
In Core, I define some of those useful functions from View (VIEW-ROOT, 
PATH-THRU etc..) in the user.r to allow the same functionality.
Louis
16-Oct-2005
[2338x2]
Geomol, I have written accounting software, and I would like for 
two or three people on a lan to be able to be intering data at once.
intering = entering
Henrik
16-Oct-2005
[2340x2]
Louis: I solved ths by having a separate Rebol task running that 
manages the file in question. It's a simple databaseserver that accepts 
requests from various clients on a LAN using Rugby. Performance is 
surprisingly good.
The database server manages the data and writes it to multiple copies 
of the database file in rotation (to avoid loss of data on write 
on power failure) every 10 seconds if there are requests from the 
clients.
Louis
16-Oct-2005
[2342x2]
Anton, I'm using encmdface from the SDK.  I am writing to an object 
database.
Henrik, so the data from different computers is sent to your dbserver 
which saves the records one at a time?
Henrik
16-Oct-2005
[2344]
basically yes
Louis
16-Oct-2005
[2345]
Sounds like what I am looking for.  Could you share the code?
Henrik
16-Oct-2005
[2346x2]
I could... but I'm going out the door in a few minutes so it's going 
to have to be later this evening.
advice: Learn Rugby :-)
Louis
16-Oct-2005
[2348x3]
Yes, I did play around with Rugby a while back, but could think of 
any way to use it at the time. Now I have a use.
cound not
could not
Geomol
16-Oct-2005
[2351]
Louis, I'm doing something similar as Henrik with a DB, I made in 
REBOL a couple of years ago. A REBOL task is listening on a TCP port 
and is handling the multiuser functionality. The clients could update 
the data in the DB themselves, or a task could do that too. My DB 
(NicomDB) isn't a product yet, but I could make it a product, if 
you're ready to pay for it?
Pekr
16-Oct-2005
[2352]
isn't it a bug that start: now wait 5 print (now - start) returns 
zero?
Henrik
16-Oct-2005
[2353x3]
pekr, it calculates date, not time difference that way. you need 
to:

start: now/time/precise wait 5 print (now/time/precise - start)
there is an interesting "bug" that way: you'll be shifted back 24 
hours if the difference is calculated across midnight.
it would be nice if it calculated the complete time and date difference
Graham
16-Oct-2005
[2356]
Use 'difference
Henrik
16-Oct-2005
[2357x2]
ah... thanks
(but IMHO not particularly obvious)
Graham
16-Oct-2005
[2359]
You pick up these things by talking to people ... not reading obscure 
manuals :)
Henrik
16-Oct-2005
[2360]
and then you write them down in wikibooks :-)
Louis
16-Oct-2005
[2361]
Geomol, let me see what I can do myself first. I like to know what 
is happening in my scripts.
Geomol
17-Oct-2005
[2362]
Isn't this a bit strange?
>> 3 // 3
== 0
>> 3 // 2
== 1
>> 3 // 2.6
== 0.4
>> 3 // 3.4
== 3.0
Sunanda
17-Oct-2005
[2363]
Very!
Ladislav
17-Oct-2005
[2364]
yes, it is, try MOD and MODULO functions, if you need a different 
behaviour
Geomol
17-Oct-2005
[2365]
Same behaviour:

>> mod 3 3
== 0
>> mod 3 2
== 1
>> mod 3 2.6
== 0.4
>> mod 3 3.4
== 3.0
Ladislav
17-Oct-2005
[2366x2]
right, in these specific cases, otherwise the behaviour may differ.
what would did you expect to get?
Geomol
17-Oct-2005
[2368x2]
I guess, I was just surprised, that it worked with decimals. Then 
it can maybe be argues, if 3 // 3.4 should return an integer or a 
decimal.
argues = argued
Ladislav
17-Oct-2005
[2370]
the definition is as follows: if r = a // b, then a - r // b should 
be zero
Sunanda
17-Oct-2005
[2371]
Been thinking about it too....It is surprsing, but does make sense.
It's returning the remainder:
3 // 2.6 --> remainder is 0.4
3 // 3.4 --> remainder is 3
Ladislav
17-Oct-2005
[2372]
other formulation: if r = a // b, then a = some-integer * b + r
Geomol
17-Oct-2005
[2373x2]
In rebcode, I guess the upcode rem is remainder. It works a little 
different there:
set a 3
rem a 3

now a is 0. If doing this:
set a 3.0
rem a 3

then a is 3.0.
I guess, it has to do with the internal floating-point representation 
of numbers.
Gabriele
17-Oct-2005
[2375]
rebcode's rem does *not* support decimals.
Pekr
21-Oct-2005
[2376x2]
will it be possible to do easy types conversion with rebcode? regard 
me being stupid, but I regard following being  bug or at least inconsistence:

type? #{77}
== binary!    ; so no excuse it is a string later!

to-integer #{77}
== 119

to-binary to-integer #{77}
== #{313139}
If pure functions which serve datatype conversion work one way, it 
is imo inconsistent that it does not work the same way in the reverse 
mode ....a
Rebolek
21-Oct-2005
[2378x3]
If you want to convert a number to binary, number must be enclosed 
in brackets, to binary! [119] , not to binary! 119
so your example should look like:
to binary! reduce [to integer! #{77}]
== #{77}
Pekr
21-Oct-2005
[2381]
we are not converting here string of "119" values, but integer!