World: r3wp
[Core] Discuss core issues
older newer | first last |
Geomol 15-Oct-2005 [2316] | ok |
Pekr 15-Oct-2005 [2317x3] | try this - found some arcane version, hopefully it will work ... |
form-decimal: function [num][tmp main rest sign base][ either found? find tmp: to-string num "E" [ parse tmp [ copy main to "." skip copy rest to "E" skip mark: (sign: copy/part mark 1) skip copy base to end ] either sign = "-" [ tmp: "0." loop ((to-integer base) - 1) [insert tail tmp "0"] insert tail tmp rest ][ tmp: copy "" insert tail tmp join main rest loop ((to-integer base) - (length? rest)) [insert tail tmp "0"] ] tmp ][num] ] | |
but please - take into account that my coding capabilities are, ehm, rather weak :-) | |
Geomol 15-Oct-2005 [2320] | :-) Ok, thanks Pekr! |
Pekr 15-Oct-2005 [2321x7] | eh, does not seem to work ... |
I will look into it and try to post correct version ... | |
Try this one: | |
form-decimal: func [num /local tmp main rest sign base][ either found? find tmp: to-string num "E" [ parse tmp [ [copy main to "." skip copy rest to "E" | copy rest to "E" (main: copy "") ] skip mark: (sign: copy/part mark 1) skip copy base to end ] either sign = "-" [ tmp: copy "0." loop ((to-integer base) - 1) [insert tail tmp "0"] insert tail tmp rest ][ tmp: copy "" insert tail tmp join main rest loop ((to-integer base) - (length? rest)) [insert tail tmp "0"] ] tmp ][num] ] | |
first one did not take into account 1E-2, simply a version, where there is no "." in it .... | |
and I believe folks here will introduce just few lines version later :-) | |
On 6-October Volker posted this reply: Pekr: "I did not find an easier way, so I parse for E, then I distinguish the sign, the number -5 in above case, and then I compose the string :-)" !> a: 123.456 reduce[to integer! a remainder a 1] == [123 0.456000000000003] Maybe the base for something better (dont know how easy that parsing is?) | |
Volker 15-Oct-2005 [2328] | turned out to be http://polly.rebol.it/test/test/snippets/epad1.r . longer and not so readable. but seems to work. |
Geomol 15-Oct-2005 [2329x5] | I think, this version do the job: 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: 2] either p/2 = #"-" [ insert/dup n #"0" (to-integer skip p 2) - 1 insert n "0." ][ insert/dup p #"0" (to-integer next p) - (index? p) + d ] clear find n #"E" ] n ] |
nope, not quite | |
This must be it: | |
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 |
older newer | first last |