REBOL3 - Core (Discuss core issues [web-public])

Return to Index Page
Most recent messages (300 max) are listed first.

#UserMessageDate
10746james_nakJaneks, Dockimbel recently put some code in the MySql group regarding how to check for Mysql port being opened.Wed 15:31
10745GreggThere's no official way. I think DocKimbel had a value in flags or state that he said worked. If he doesn't jump in, I'll dig for it.Wed 8:51
10744JaneksWhat is the right way to check is port (ODBC, mySQL) open? Is it a-port/port-id ?Wed 6:02
10743GrahamOk, sussed it out .. the compare can be an integer offsetTue 10:39
10742GrahamLooks like the comparator function takes two arguments ... which are the first of each setTue 10:22
10741GrahamAnyone know how to use sort on some data where eg. skip value is 10 and you want to sort of anything but the first element?Tue 10:20
10740GreggAlan Dechert <dechert@gmail.com> asked the same thing on the ML earlier this month. Maybe the two of you can collaborate on a solution. If you could enhance SEND to allow it, maybe with a new refinement, we can try to get Carl to make it the standard.Mon 15:35
10739JaneksO'k. But how to put Content -ID into message part?Mon 10:31
10738Grahamthe send/attach can generate the multipart components for you.Mon 10:04
10737JaneksI am working on sript, that composes and sends html e-mail. It is rather simple, but now I would like that e-mail will contain inline images. I found out that they are multipart messages, and that image is referenced with cid in html image and in image part it is marked as Content-ID:

</HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3D"Courier New" size=3D2></FONT><IMG height=3D47=20 src=3D"cid:26DB76551F2E4591BBC3B599C3A7CCAE" width=3D320></DIV> <DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV> </BODY></HTML>

------=_NextPart_001_00A9_01C8DAAB.A817E460--

------=_NextPart_000_00A8_01C8DAAB.A817E460 Content-Type: image/bmp; name="ML.bmp" Content-Transfer-Encoding: base64 Content-ID: <26DB76551F2E4591BBC3B599C3A7CCAE>

Qk22vQEAAAAAADYAAAAoAAAADwIAAEgAAAABABgAAAAAAIC9AQDEDgAAxA4AAAAAAAAAAAAA//// ////////////////////////////////////////////////////////////////////////////

How to implement such html e-mail generation in rebol script?

Mon 9:43
10736ChrisYou could use 'foreach which'd be fast, but then you'd have to block! your case as well as your fallback losing readability.Sun 1:37
10735ChrisIndeed 'all would be fastest yet, except you don't get feedback at the point of failure.Sun 1:35
10734ChrisReadability. I want it to be fast, of course, but long-term it's not worth the compromise. I want to do more with less.Sun 0:38
10733GrahamIf it's a time critical app like a web server I'd go for speed ...Sat 22:55
10732GrahamShould one go for speed or readability?Sat 22:52
10731PaulChris - 'case is native so even adding a 'not statement is going to be faster solution I think.Sat 22:16
10730Henrikwell, I tried a single line of code with it, and it didn't do what I wanted. I guess I could ask myself if I would write that kind of code today. :-)Sat 22:08
10729ChrisI get that -- a sign of personal progress, perhaps?Sat 21:59
10728Henriksorry, it does not work very well. I think I would build a new one from scratch if I needed it again.Sat 21:53
10727Henrikfound it, but I remember it being more elegant than the code I found here...Sat 21:47
10726ChrisI'm curious re. approach, expression and naming...Sat 21:17
10725HenrikChris, I guess it could work.Sat 21:16
10724ChrisThat is, I have a series of tests, each requiring a case for failure...Sat 21:13
10723ChrisH: is this the type of problem you were addressing?Sat 21:12
10722ChrisGraham, I'm still pondering naming. 'assert seems to evoke unit tests, that's not what this is. 'all-nots doesn't quite get the essence either. 'all-else is a possibility? Until then, I still lean toward 'assert-all.Sat 21:11
10721HenrikI had a function that does this a while ago, but I have to dig it upSat 21:10
10720ChrisHenrik, how does your scenario differ? Do you have a sample of your solution at work?Sat 21:09
10719ChrisPaul: it's a common enough pattern, I'd like to find the most appropriate way to express it. Actually, that's the principle behind QM (which of course, this is intended for). The alternative case above would be:

case [ not a < 10 [print "a is more than 10"] not result: a > 0 [print "a is less than 0"] ] result

Requires a 'not statement for each test, requires an extra word to track the result and does not return a meaningful value. Consider this:

if assert-all [ user/has-role? 'editor [make error! "You do not have required permission"] article: get-param 'article [redirect-to %/articles/create] 10'000 < length? article [make error! "Article is too long"] ][ save %article.txt article redirect-to %/articles/list ]

Sat 21:07
10718Grahamall-nots ?Sat 20:24
10717Henrikalthough I've recently switched to state machines for that kind of code.Sat 20:18
10716HenrikI would like to see a good implementation of a function that performs a sequence of code blocks. If a code block is good, the next one is run. If the code block causes an error, a secondary code block that is either generic for all code blocks or specific to that particular code block is run. I'm thinking step-by-step code that either runs successfully or causes a generic or specific error.

I don't know if it makes sense to do that, but I sometimes miss that if I need to do something with user friendly network connectivity.

Sat 20:16
10715PaulWhy would we need that as opposed to just changing the current evaluation of existing case?Sat 20:12
10714ChrisUsage:

assert-all [ a < 10 [print "a is more than 10"] a > 0 [print "a is less than 0"] ]

It's the opposite of 'case really. If any of the cases are false, the related block is evaluated and the function returns none/false. If all cases are true, it returns the value of the last successful case.

Sat 18:58
10713Chris; request for comments --

assert-all: func [cases [block!] /local value][ until [ set [value cases] do/next cases unless value cases/1 cases: next cases any [not value tail? cases] ] value ]

Sat 18:48
10712PaulI went into the registry and found the reference to rebview and deleted its registry keys and reassociated the .r extension with the rebol/view 2.7.6 product.23-Jun 14:11
10711PaulFixed it.23-Jun 14:08
10710PaulIt appears to see a broken path and sees the rest of the path as an argument. Not sure where it is checking yet to get this information.23-Jun 14:06
10709PaulI have reassociated my scripts in windows with the new 2.7.6 core but I now get an error whenever I attempt to open them which is:

** Access Error: Cannot open /C/Documents ** Near: do/args script system/script/args

Any ideas?

23-Jun 14:02
10708PeterWoodThere is a lot of information about Rebol's memory usage in the mailing list archive. You culd start here: http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-topic-index.r?i=memory22-Jun 7:07
10707Henrikinteresting, dockimbel. thanks.22-Jun 7:02
10706PaulThese are the kinda things I wish Carl would go over so we can best optimize our use of memory.22-Jun 1:47
10705PaulI know that in a string each character represents a byte but even then how much overhead is allocated merely by a: make string! 0?22-Jun 1:46
10704PaulI know we can initilize the block with for example:

a: make block! 10

But how do we determine what is in the block comprises a byte?

22-Jun 1:46
10703PaulSo how to we define those things in a block?22-Jun 1:45
10702PaulI that in the following the 10 represents 10 "bytes"? a: make string! 1022-Jun 1:44
10701PaulLet's talk memory...22-Jun 1:43
10700Dockimbel>> a: make list! [1 2 3 4 5] == make list! [1 2 3 4 5] >> b: at a 3 == make list! [3 4 5] >> a == make list! [1 2 3 4 5] >> b == make list! [3 4 5] >> remove a == make list! [2 3 4 5] >> b == make list! [3 4 5]21-Jun 23:05
10699Henrik(but if it were possible, some code would be greatly simplified)21-Jun 14:03
10698Henrikyes, it is. it would be too hard to track from inside rebol when an index should move.21-Jun 14:02
10697Paulyeah you'll definately have to be more judicial with your code but I'm thinking that the mechanics of it is the way it is intended to operate.21-Jun 13:58
10696Henrikyes. that's janitoring of the index, which could be prone to bugs, etc.21-Jun 13:57
10695Paulcan you just get around the problem by setting a: next a ?21-Jun 13:53
10694Henrikhalf a feature request and half trying to find a quick way to solve it. seems there is not an easy way.21-Jun 12:24
10693ChrisUnless this is a feature request, you'll need an alternative to remove...21-Jun 12:04
10692Henrikit must be the same series21-Jun 11:18
10691Grahamand if you copy the index? as well?21-Jun 10:41
10690Henriknope, it has to be the same series21-Jun 10:39
10689Grahamcopy it first! :)21-Jun 10:35
10688Henriksimple problem:

>> a: [1 2 3 4 5] == [1 2 3 4 5] >> b: at a 3 == [3 4 5] >> a == [1 2 3 4 5] >> b == [3 4 5] >> remove a == [2 3 4 5] >> b == [4 5] ; I wonder if it's possible to make the index "sticky" at [3 4 5] in a relatively simple way. If it were, that would be very cool.

21-Jun 10:06
10687AntonIt's kind of like an "apply-any".20-Jun 15:22
10686PaulVery nice Chris!19-Jun 11:42
10685ChrisOops, forgot the function at the end there...19-Jun 4:06
10684Chris; Here's a thought:

any-where: func [series [block!] test [block!]][ foreach value series compose [if (test) [break/return value]] ]

probe any-where [1 2 3 4][value > 4] probe any-where [1 2 3 4][value >= 4] probe any-where [1 2 3 4][value < 4]

; I know it's a two block solution, but it's pretty language friendly. You can recycle tests too:

test: [value > 4] probe [1 2 3 4] :test probe [5 6 7 8] :test

19-Jun 4:04
10683Paulheh but cool Gregg.18-Jun 20:50
10682GreggYou can sort of trick your way around things with ops in most cases. e.g.

>> fn: func ['op a b] [op: get op op a b] >> fn < 1 2 == true

But I avoid doing that. It ends up not being worth it, IMO, when you start to reuse things, generate code, etc. Just use func alternatives.

18-Jun 19:51
10681Paul;a bit revised: lop?: func ['op][if all [op? get op find form op charset "<>="] [return true] false]18-Jun 17:14
10680Paulcould be modified to become a true mezz18-Jun 17:09
10679Paulseems handy to me.18-Jun 17:08
10678HenrikI see.18-Jun 17:07
10677Paul>> lop? + == false >> lop? < == true18-Jun 17:06
10676Paullop?: func ['op][if find form op charset "<>=" [return true] false]18-Jun 17:06
10675Paulall the ones that return logic are those operators that are or have in their form the characters "<" ">" or "="18-Jun 17:05
10674PaulI'm just checking the charset18-Jun 17:05
10673Henrikplease explain, because I can't see where you do that. :-)18-Jun 17:04
10672Pauljust like I do in the function above that I wrote.18-Jun 17:01
10671Paulyeah you can18-Jun 17:01
10670Henrikwell, you wouldn't know without running actual tests with the operator.18-Jun 17:01
10669Paullop? would be a function18-Jun 17:00
10668Henrikok18-Jun 17:00
10667Henrikwhat do you mean?18-Jun 17:00
10666Paullop? - returns true or false if operator returns logic values.18-Jun 17:00
10665Paulwould be nice to have lop?18-Jun 16:59
10664Paulyeah I know I thought it would return logic and op depending on the test.18-Jun 16:59
10663Paul>> op+ [1 2 3 4 > 2] == true18-Jun 16:58
10662Henrikwhat you return is that the datatype is op!, not logic!, so logic? returns false.18-Jun 16:58
10661Paul>> op+ [1 2 3 4 + 1] == [2 3 4 5]18-Jun 16:58
10660Paulop+: func [blk /local op args arg blk2 blk3][ op: first back back tail blk blk3: copy [] arg: last blk if word? :arg [arg: get :arg] args: copy/part blk find blk op blk2: reduce [op arg] foreach item args [ insert blk2 item if item: attempt [do blk2][ either find form blk charset "<>=" [return item][append blk3 item] ] remove blk2 ] if not empty? blk3 [return blk3] false ]18-Jun 16:57
10659Paulsome modifications made:18-Jun 16:57
10658PaulI guess because it doesn't return true or false until it operates on something it wont return a logic value. But maybe we should at least subclassify some operators to distingish them more.18-Jun 16:51
10657Paul>> logic? get to-word "<" == false >>18-Jun 16:49
10656PaulShouldn't < > and = return as a logic values as well as being op values?18-Jun 16:49
10655PaulI'm sure we can do something in the mezz sense once R3 gets released.18-Jun 16:30
10654HenrikI would love to see it in R3, but so far nothing from Carl WRT this particular feature. I think it might complicate op! way too much.18-Jun 16:28
10653PaulNo outside of a single block though.18-Jun 16:24
10652PaulI could make that change to my function and easily accomodate that.18-Jun 16:24
10651Henrikbecause I would also like to see:

>> 1 + [2 3 4 5] == [3 4 5 6]

in R3 there are ways to do this with a bit more code.

18-Jun 16:23
10650PaulMy function is actually very restricted in that it looks for the op! as the second to last value and the comparator as the last item.18-Jun 16:22
10649HenrikI remember from my HP48 calculator that any numbers put in a block, could be operated on like that. But I think this is the beginnings of vector operations, which is a big area that should be done right.18-Jun 16:21
10648Paulyeah that is what I initially wanted to do Henrik.18-Jun 16:21
10647PaulWould be nice if we use op! values as an argument to functions.18-Jun 16:20
10646Henrika < [1 2 3 4]18-Jun 16:20
10645HenrikI would want to put all values that are going to be tested in a block.18-Jun 16:20
10644PaulI think we can. One that can probably accomodate much more.18-Jun 16:20
10643Henrikit's good, but I wonder if we can come up with an even better syntax.18-Jun 16:19
10642PaulFor example:

any+ [1 2 3 4 > 3]

18-Jun 16:19
10641Paulfor the any+ function you put the multiple items on the left side of your block and the single item to compare to on the right side18-Jun 16:19
10640Paul;here is my little 'any+ function:

any+: func [blk /local op args arg blk2][ op: first back back tail blk arg: last blk if word? :arg [arg: get :arg] args: copy/part blk find blk op blk2: reduce [op arg] foreach item args [ insert blk2 item if attempt [do blk2][return true] remove blk2 ] false ]

18-Jun 16:17
10639Paulnice Gregg.18-Jun 16:17
10638GreggThere isn't anything built in that does that. For simple min/max comparisons, you could do something like this:

if a < first maximum-of [1 2 4] [print "cool"]

I also have a shortcut for FIRST MAXIMUM-OF.

pick-max: func [series [series!]] [attempt [pick maximum-of series 1]] if a < pick-max [1 2 4] [print "cool"]

For the general case, I would use a map and anonymous func combo. R3 has a native MAP func, but you have to roll your own in R2.

18-Jun 16:16
10637PaulI have a handy little function I made and don't know if there is already an easy way to do this in REBOL but I have a function called 'any+ that simply keeps me from repeating any statements. For example:

>> a: 3 == 3 >> if any+ [1 2 4 > a][print "cool"] cool

Got a bit tired of writing ANY [1 > a 2 > a 4 > a] This is one of those things that I often wonder if we already can do this easlier and I just don't know what it is.

18-Jun 14:16
10636Paullooks like in R3 we get 'AT expanded to 64 bit possible to access the open/direct files.16-Jun 23:37
10635PaulWould be nice to have the feature to access the currently indexed position of the open port and perform a function on it. For example, modify /awake to work with files. Such that any reference to the file or altering of the position can be handle via an awake/handler.16-Jun 23:22
10634BrianHNope. Anyone else want to give this a shot?16-Jun 23:03
10633PaulAny ideas what the numbers mean in the port/state/misc section of a file port?16-Jun 23:02
10632PaulThat isn't the kinda of answer I was looking for but expected.16-Jun 23:00
10631BrianHThis may be one of those use-another-tool-through-call or use-R3's-64-bit-integers situations.16-Jun 22:38
10630Paulahhh time to eat - be back in a few.16-Jun 22:36
10629PaulA work around?16-Jun 22:36
10628PaulDo you know anyway around this limit?16-Jun 22:36
10627PaulI don't know what the port flags or the port/state/misc counters are used for.16-Jun 22:36
10626BrianHI expect that /direct is just using file handles and isn't setting offsets like /seek.16-Jun 22:35
10625PaulMy need is to be able to get the tail or index of files larger than the 32 bit integer limit.16-Jun 22:35
10624PaulWell I would assume that the 32 bit integers are being used on open/direct so I'm not sure why this limitation only affect /seek and not /direct as well.16-Jun 22:34
10623BrianHThe source of OPEN, isn't. It seems likely that the 32-bit integers of R2 are at fault here.16-Jun 22:33
10622PaulSo next question - do we have any source of /seek to understand why we have such a limitation?16-Jun 22:30
10621PaulThe only limitation I could find is in /seek.16-Jun 22:29
10620PaulI noticed using his refinements I no longer have access to tail from querying the port.16-Jun 17:23
10619PaulI tried Oldes method and able to get it over the limit.16-Jun 17:20
10618PaulREBOL should be able to break this limitation. Even if it means holding a pointer to a file position and then looping over again.16-Jun 16:45
10617PaulI would have thought that write would be using open also.16-Jun 16:45
10616HenrikI wonder if WRITE/APPEND allows files over 4 GB?16-Jun 16:44
10615PaulNot sure how OLDES was able to get his file over 5GB on NTFS as my test was also on NTFS.16-Jun 16:43
10614PaulNow the port can still be read via open/direct but no longer accessible via open/seek at that point.16-Jun 16:41
10613Paulwhen the port/state/tail value reaches 2 ** 31 it converts it to a negative number and gives an error which is an "access error writing to port".16-Jun 16:40
10612PaulInteresting the limit for file size in REBOL is 2 ** 3116-Jun 16:28
10611PaulThat is where my interest lies Anton.16-Jun 14:21
10610PaulWell I'm testing a new indexing system for TRETBASE and need to know some significant data to fine tune it.16-Jun 14:20
10609OldesI'm not going to read such a file if I have only 1GB memory:)16-Jun 14:20
10608Antonyou run into a problem then.16-Jun 14:20
10607AntonI think it's when you want to seek to a position greater than 2 ^ 31 - 116-Jun 14:20
10606OldesBut not impossible I guess. Using such a big files is not practical imho.16-Jun 14:20
10605PaulYou having problem reading that file now?16-Jun 14:19
10604OldesThe problem is with reading anyway16-Jun 14:19
10603Paulon the port rather.16-Jun 14:18
10602PaulI want to be able to do some probes on the file once I get it to size.16-Jun 14:18
10601Paulok cool.16-Jun 14:18
10600OldesWIN/ ntfs16-Jun 14:18
10599Paulwhat OS?16-Jun 14:17
10598Oldescreated file ower 5GB here... than I stoped it.16-Jun 14:17
10597Oldesp: open/direct/write/new %/k/test.bin b: make binary! 1000000 insert/dup b #{00} 1000000 i: 0 while [not error? try [insert tail p b]][i: i + 1]16-Jun 14:17
10596AntonOk, that makes sense.16-Jun 14:16
10595PaulThat number I posted is the highest in my algorithm I could hit.16-Jun 14:16
10594AntonMaybe it was 2 ^ 31 - your buffer size ?16-Jun 14:16
10593PaulOh it was a generic range number based on a algorithm I was running. I expect the number to be the 32 bit signed number that John posted.16-Jun 14:15
10592AntonI don't know where you got that number from; If I remember correctly the first time you can get a problem with rebol file size is at 2 ^ 31 - 116-Jun 14:14
10591PaulActually a bit larger than that.16-Jun 14:13
10590PaulI was curious because I'm interested in what happens when I hit 2099999999 size.16-Jun 14:13
10589Paulahhh ok.16-Jun 14:13
10588AntonSorry, not using Rebol, but in Linux, creating a file in a FAT32 partition.16-Jun 14:12
10587PaulAnton, you created a 4GB file using REBOL or was reading one when you got the error?16-Jun 14:11
10586Paulcurrently still writing a file which is only at 668 Megs at the moment.16-Jun 14:09
10585PaulI'm on NTFS. I'll post what I find out.16-Jun 14:09
10584AntonYep, hit it today on FAT32 - 4GB file was produced.16-Jun 14:01
10583HenrikFAT32 is the one with that limit.16-Jun 13:47
10582GeomolThe file system might have max-size for files. I remember something about 2 or 4GB for some file systems.16-Jun 13:47
10581Geomol:-) Be sure, you have enough HD space!16-Jun 13:45
10580PaulI'm actually running an experiment now. I'm going to write a file that will attempt to exceed those sizes.16-Jun 13:27
10579GeomolLargest 32-bit signed int is 2 ** 31 - 1 = 2'147'483'647 If REBOL internally use 32-bit unsigned, it's 2 ** 32 - 1 = 4'294'967'295 If REBOL internally use 64-bit unsigned, it's 2 ** 64 - 1 ca. = 1.845E+1916-Jun 13:20
10578PaulOk, I checked for a file size limitation in REBOL but haven't found one. I noticed the documentation for open/direct for example says that /direct can be used for files of any size. I don't see how that can be if it is calculating the size as an integer and integer has a limitations.16-Jun 13:12
10577PaulSince integers greater than that number cause errors.15-Jun 1:00
10576PaulI'm also assuming since a port/size is integer! that the file size can be no greater than 2099999999 bytes.15-Jun 0:59
10575PaulI'm assuming there must be a iimit that open/direct can't just mount any file size. I'm assuming that the limitation is roughly 2 Gigs.15-Jun 0:45
10574PaulWhat is the limitation on file size that REBOL 7.6 can handle?15-Jun 0:38
10573JoshNevermind, I think I just had a typo in my code. :)12-Jun 22:11
10572JoshWhich version of rebol allows for evaluation in paths? (i.e. block/(1+i): "hello" ) Or am I not remembering this correctly?12-Jun 22:05
10571Willmy bad, thanks Dock, I can refactor to ifs: func [c b][either c b [""]] ;like if but return empty string ifb: func [c b][either c b [[]]] ;like if but return empty block so ifs is like your if* 8)1-Jun 15:03
10570WillI use these quite often: ifs: func [c b][either c [do b][""]] ;like if but return empty string ifb: func [c b][either c [do b][[]]] ;like if but return empty block1-Jun 15:00
10569GrahamSince I might be grabbing the image as jpg and then saving it to png, I guess I should save it to memory as binary and do the calculation that way.1-Jun 7:34
10568Henrikor if you want to avoid loading the image twice:

i: read/binary %image.png checksum i i: load i

1-Jun 6:33
10567Henrikconvert it to binary first1-Jun 6:31
10566Grahamguess I can't1-Jun 6:25
10565GrahamIf I wish to compute a checksum on an image file, I can do this

checksum read/binary %image.png

but how do I get the same result when I have the image as image data ?

eg. i: load %image.png

and to compute the checksm on i ?

1-Jun 5:35
10564Paula: compose [(pick [["b"][]] 0 > 1)]24-May 19:44
10563DockimbelClean and simple solution.24-May 15:32
10562ChristianEIn cases like this, Robert, I usually use somthing like

>> pass: func [value] [any [value []]]

which makes code somewhat readable

>> a: compose [ (pass if 0 > 1 ["b"]) ]

24-May 15:05
10561PaulI might be able to figure this out if I take a look at the protect-system.24-May 14:28
10560PaulDoes protect work inside an object's context? For example if i have a: context [b: 0] can I then protect 'b from being changed?24-May 14:14
10559Henrik>> a: compose [(either 0 > 1 ["b"][])] == []24-May 13:24
10558Dockimbel>> if*: func [cond body][either cond body [[ ]]] >> a: compose [ (if* 0 > 1 ["b"]) ] == [ ]24-May 12:57
10557Dockimbelif you want to hide the "tricky part" :24-May 12:57
10556RobertOk... very tricky. ;-)24-May 12:39
10555Dockimbel>> void: [ ] >> a: compose [ (either 0 > 1 ["b"][void]) ] == [ ]24-May 12:22
10554RobertHi, how can I avoid to get back NONE for something like this: a: compose [ (if 0 > 1 ["b"]) ]

I just want to get nothing back, like the parens were never there.

24-May 12:14
10553BrianHGoogle is really specific about which languages it will support itself - they won't even let their employees use alternate languages for Google products. REBOL's niche is taken up by Python there. Nothing stopping you from cloning one of the official APIs for a third-party API though.20-May 20:51
10552GrahamNo REBOL included of course20-May 20:06
10551GrahamGoogle api client libraries ... http://code.google.com/apis/gdata/clientlibs.html20-May 20:06
10550sqlabLooks my solution for changing the name.)19-May 16:07
10549Geomol>> to integer! #7fffffff == 2147483647

No unsigned version directly. You might be able to make code, that can implement unsigned int.

19-May 16:06
10548RobertI know it's 2 ** 31 - 1 but any other way? Is there an unsigned version as well?19-May 14:54
10547RobertIs there a way to get MAX-INT from Rebol?19-May 14:49
10546OldesUse Resource Hacker http://www.angusj.com/resourcehacker/ to change the title and or icons.19-May 6:26
10545GrahamActually maybe it was Terry that wrote this .. can't recall now.18-May 23:41
10544Grahamwin-lib: make object! [ user-lib: load/library %user32.dll

SetWindowText: make routine! [ handle [integer!] Title [string!] return: [integer!] ] user-lib "SetWindowTextA" set 'WindowTitle func [ Title [string!] ] [ SetWindowText get-modes system/ports/system 'window Title ] ]

18-May 23:40
10543eFishAntshucks.18-May 23:38
10542GrahamI asked Carl years ago to allow us to change this within REBOL ... he agreed but has not done this. So, I too use Winapi calls.18-May 20:37
10541PaulI do that via winapi calls currently.18-May 17:47
10540eFishAntRight now it is "REBOL/View" on the console title bar. I know I'm gonna be embarrased when I find out what it is...18-May 17:22
10539eFishAntAs better at REBOL I am getting, I am trying to find the trick to rename the title of the Console window itself. I am glad I can probe system, but I just haven't probed it in the right orafice...18-May 17:16
10538btiffinA psych prof I knew, wrote papers on the quantum clock in our brains. Google "kristofferson professor rate of tone and brain clock" for some references to his research. Sorry for clogging Core. But yeah, his experiments concluded that we definetly think in "waves"; some events go undetected if they occur between 'brain ticks'. He couldn't explain the 'how or why', but he could measure the effect.10-May 23:41
10537Gabrielewave equations have nothing to do with the human brain as far as we know it. if you know more, you should publish an article somewhere, as that would be a breakthrough.10-May 17:41
10536Gabrielebesides... neurons are know to only be able to fire or not to fire. they are digital, not analog. if the input is above the threashold, the neuron fires. otherwise it does not fire.10-May 17:39
10535Gabrieleif you feed a human a 32 bit int and ask him/her to get you back a password, and it has to give you the same password for the same int, then how many password would the user give you?10-May 17:37
10534Gabrieleabout 2 ** 32, that's a limitation of *your* algorithm, not RANDOM. indeed, if you don't reset the seed each time, and use random/secure, you probably get all of the possible passwords (and very likely more than humans would pick). besides, it is not proven that random/seed only takes 32 bits of data when seeded with a date!. (C rand() is most likely 32 bit, but random/secure could be using more than that.)10-May 17:36
10533Gabrielea human picking chars "randomly" will most likely not be random. sadly, i guess we're not going to be able to do a test with a few million people to get a decent sample.10-May 17:34
10532GreggA long time ago, I remember reading something where the author suggested, as a shared seed, using a substring of PI.9-May 13:51
10531GeomolMoving to chat9-May 11:21
10530Dockimbelreading mouse moves is usually a good source for seeding9-May 11:13
10529Dockimbelcan = can't9-May 11:11
10528DockimbelMaybe this thread should be move in another channel9-May 11:10
10527GeomolHow do I use a better random function, now that it's a routine programmed in REBOL? I could get the source of a better routine and implement it myself. That will give me a better result, yes. I'm not going to do that, as my current routine is good enough for the purpose.

How do I access a source of true randomness from within REBOL? random.org has been suggested. Other ways?

9-May 11:10
10526DockimbelWell...the magical "quantum" is back again. :-) Sorry, but you still didn't prove anything...Do we need to get back to how a neuron fires ? Show me any experiment that has been done proving that neuron's firing is not deterministic (meaning it can be predicted knowing the inputs).9-May 11:10
10525Geomol"That needs to be proved. It can be very high without being infinite." I think, it's proven by quantum mechanics in the number of possible outcome from a wave equation.9-May 11:07
10524DockimbelBy using a better than REBOL default RANDOM function and using a source of true randomness for seeding.9-May 11:07
10523GeomolIn my password generator, how would you feed it with more input?9-May 11:05
10522Dockimbel"In general, I would say the pool from human thoughts and decisions is infinite". That needs to be proved. It can be very high without being infinite.9-May 11:01
10521DockimbelWhy restricting the computer to 32bits input only, when you can feed it with gigabits of inputs ? That's not a fair comparaison.9-May 10:59
10520GeomolYes, valid points, but it's not what I described at first. If I should construct a random password given the rules, my output will land in a pool of 60 ** 8 possible passwords. I don't have to actual do it. The statement holds anyway. If a computer should construct a random password given the rules (using any deterministic computer and any algorithm, but only with a 32-bit integer input, as in the case of REBOL random/seed), the output will land i a pool of 2 ** 32 possible passwords at most.

Of course we can change the frame and get a better result from the computer, but then we change the 'experiment'. In general, I would say the pool from human thoughts and decisions is infinite. It's not from a deterministic computer. So we need true random input and true analog computing with infinite states, if we want our computers to be as good as our brains.

9-May 10:51
10519DockimbelGiven a good algorithm (like Mersenne twister), and a true random generator for seeding (like hardware sensors) a computer could cover the 60**8 range. A humain brain, even given enough time, can't (I'm talking about generating random combinations, not using loops to generate every single combination). Even worse, humain results would show heterogeneous distribution of results, while computer will give a uniform distribution. So in that case, computers would give you better randomness than analog brains.9-May 10:35
10518GeomolI'm not fair using the word "ignorance". I don't think, you are. I base my conclusion on the following:

See the password generator as a black box, that you feed with an integer, and out come a password. The integer input has 2 ** 32 different combinations and is used for the random/seed. Out come a password, and there can only be 2 ** 32 different passwords coming out at most. It doesn't matter, how the algorithm is constructed, if you put time delay in, call random or random/seed more than once, etc, as long as you don't get other input as the first integer. This is basic in information theory. And it's related to the determinism in digital computing.

9-May 10:15
10517Geomol"so if you pick each character separately you don't make 60 ** 8 different password?"

If I, as a human, pick each char separately, I can make 60 ** 8 different passwords. If I make a digital computer do it based on 2 ** 32 integer pseudo-randomness, I can't! If you disagree, then show me. Doc seems to get it now, so I'm not completely alone with my insight.

9-May 10:01
10516Geomol(For the record, I'm not religious.)9-May 9:58
10515Geomol:-) No, it's what happens, when insight takes the place of ignorance.9-May 9:57
10514Gabrielelol, so if you pick each character separately you don't make 60 ** 8 different password? Geomol, you're being really funny. I guess this is what happens when religion takes the place of logic.9-May 8:54
10513ReichartKeno, yup....keno programmers are like script kiddies...8-May 23:42
10512btiffinYep. Bean counter code by bean counter people. :) But the random packages, there are at least five, go into great detail and the issues. Then again, this is REBOL/Core. Beats the pants off R, we just lack the bean counters. :)8-May 19:55
10511GeomolI installed R on my Mac more than a year ago, but haven't found the time to use it yet (or did't find the need). I've heard, it should be good at doing graphs.8-May 19:48
10510btiffinJohn; If you ever get a chance, check out R. http://www.r-project.org It's a statistical analysis language (in the main) and goes to great length to ensure a reproducible random sequence on each run. This allows for verification, stable screen shots of sample graphs etc. I like the fact that REBOL has the same feature of "known" random numbers across runs, until a forced seeding.

In Quebec, someone figured out the sequence of the provinicial Keno game. He won three times before someone got suspicious. The lotto corp wanted to deny him his prize money. A judge ruled that if they did, they would have to deny and claw back all winnings from everyone. So they paid. And fumed and puffed out their chest, and then went back to school to learn better programming. :) Last I heard, the guy hasn't cracked the new sequence ... yet.

8-May 19:16
10509Reichart"And if a hacker get acces to the state stored on disk, we're screwed again. ;-)"

And that is why we set the random seed randomly...

8-May 18:59
10508GreggThis is the randomize func I use, FWIW: Alan Parman did quite a bit of R&D and posted this as his best solution.

randomize: func [ "Reseed the random number generator." /with seed "date, time, and integer values are used directly; others are converted." ][ random/seed either find [date! time! integer!] type?/word seed [seed] [ to-integer checksum/secure form any [seed now/precise] ] ]

8-May 16:36
10507Dockimbel"The algorithm used in the C library provided with gcc has a period of 2.88 * 10E9" http://hepwww.ph.qmul.ac.uk/sim/random.html8-May 16:03
10506GeomolAnd if a hacker get acces to the state stored on disk, we're screwed again. ;-)8-May 15:50
10505GeomolCool, thanks! :-)8-May 15:47
10504DockimbelExactly.8-May 15:47
10503GeomolSo a way to get good random numbers over a long period of time, is to start such a routine (like the Mersenne twister) only once. The routine should then work with a high number of bits, the more the better and store the state, it has come to, to disk. Every time the computer is turned on, it can pick the state from disk, and start from where it left off. A password generator should use this routine and call it between each character in the password. If the routine has high enough resolution, it should be possible to produce 60 ** 8 different passwords.8-May 15:46
10502DockimbelYou should maybe search for a free implementation of Mersenne twister generator, it can give you up to 2**19937 unique combinations which is far enough for covering the 60**8 range. http://en.wikipedia.org/wiki/Mersenne_twister8-May 15:36
10501Geomol!!! :-)8-May 15:35
10500DockimbelThe more I think about it, the more I come to the conclusion that you're right. REBOL's random function might have a period of 2**32 (with a 32bits seed) maybe even less (I can't find the exact period of C rand( )).8-May 15:34
10499GeomolPeter, yes random.org is a solution, and a good one. But it doesn't hold in a real application, because what if there's no web connection. I have a routine, that is good enough for my problem. What I'm after, is the best way to do this. I and others might learn from this.8-May 15:30
10498GeomolDoc, then I can't see, how I can get close to 60 ** 8 different passwords, as you claimed.8-May 15:27
10497PeterWoodA psuedo-random generator should always give the same sequence if you start with the same seed. That's what Reichart was saing. Try the site that Sunanda suggested for an explanation; random.org8-May 15:26
10496GeomolPeter, I'm just investigating, what's the best way to produce random passwords. In some applications, they might need to be unique, not in others. If they need to be unique, the easiest would be to check with passwords produced in the past, I guess.8-May 15:26
10495Dockimbel"that random/secure give the exact same sequence of numbers every time, if started with the same seed" That's an intended feature ! You should set the seed only *once* with a random (or pseudo-random) value like now/time.8-May 15:24
10494PeterWoodDo you need the passwords to be unique?8-May 15:24
10493GeomolMy test show, that random/secure give the exact same sequence of numbers every time, if started with the same seed. Check it with code like: >> random/seed 1 loop 1000000 [random/secure 10000000] random/secure 10000000 == 1253129 >> x: 1 loop 10 [random/seed 1 loop 1000000 [random/secure 10000000] if 1253129 <> random/secure 10000000 [print x] x: x + 1]

So I conclude, that I can only make 2 ** 32 different passwords with this, not 60 ** 8.

8-May 15:21
10492GeomolIt puzzles me, how you can get more than 2 ** 32 possible outcome from 2 ** 32 different input, so I'll start reading... :-)8-May 15:05
10491DockimbelI guess that a good start woul be : http://en.wikipedia.org/wiki/Pseudorandom_number_generator8-May 15:01
10490Dockimbelpseudo random number generator8-May 15:01
10489Dockimbelgoogle for pseudo number generator8-May 15:00
10488Geomol"The seed just gives the starting point in a series of values produced by a math formula with a far greater range than the 32 or 64bits would give. So, if your code is correctly written, you'll get close to 60 ** 8 possible passwords"

That's interesting. Do you know a good link, where I can read more about this?

8-May 14:50
10487ReichartJohn wrote "It seems to be 1."

And this is probably correct from a social point of view. But I will stick with "unkown without extensive testing" because many integers can give the same sequence, and might even give the same sequence for a long time before they diverge.

This is the subtle point I'm trying to make about what is random vs pattern.

Things that "seem" are the reason hackers crack codes…this is where I used to start when I cracked other people's systems…

8-May 14:44
10486DockimbelThe pseudo-random generator used in REBOL (rand( ) C function) like in most other languages, is not limited to the size of the seed, it doesn't work that way. The seed just gives the starting point in a series of values produced by a math formula with a far greater range than the 32 or 64bits would give. So, if your code is correctly written, you'll get close to 60 ** 8 possible passwords (depends on the quality of value distribution in the internal math formula). The C rand( ) is notoriously poor, but far enough for most uses. IIRC python, for example, uses a different generator with a period or 2**19937-1.8-May 14:39
10485GeomolYes, something like that would be needed between each character to raise the number of possible passwords produced.8-May 14:23
10484SunandaYou could grab some starter randomness from http://random.org8-May 13:55
10483GeomolThis might be a good example to illustrate my point in the other thread about randomness and the difference between digital computers and analog human brains.

In my example, I'm about to produce a 8 character random password. Each character can be one of 60 possible chars. So I set up a random/seed with 2 ** 32 = 4'294'967'296 possible start values, so I can at best produce the same amount, 4'294'967'296, different passwords with my routine. I can't change this by putting new random/seed in after each character found, because of the determinism in how a computer work. I would need to get input from the outside to produce more different 8 char passwords.

As a human, I can pick between 60 possible chars, and I have to do it 8 times, so I can make 60 ** 8 = 167'961'600'000'000 different passwords. That's a lot more than the computer. When we go to abstract thoughts with no clear limits (like 60 and 8), we are far superior to the digital computer.

It would be much easier to make an artificial intelligence, if our computers were analog.

8-May 13:11
10482GeomolSo this should be about as good: random/seed to integer! 2 ** 32 / 86400 * (to decimal! now/time/precise) - (2 ** 31)8-May 12:48
10481GeomolNow I think of it, all this probably isn't necessary, because the actual number of possible outcome of my routine still is low compared to all the bits in an integer. I don't get 2 ** 32 possible passwords from this. If the routine is mainly used doing the day (maybe 12 hours), I still just get half the possible outcome, even with all this, right?8-May 12:45
10480GeomolA suggestion for an algorithm to produce a random seed from the time:

s: to integer! 2 ** 32 / 86400 * (to decimal! now/time/precise) - (2 ** 31) s: enbase/base debase/base to-hex s 16 2 reverse s s: to integer! to issue! enbase/base debase/base s 2 16 random/seed s

It does this: 1) convert now/time/precise to an integer using all possible bits 2) make a string of 0 and 1 from it 3) reverse the string 4) convert it back to an integer 5) And finally use it as a seed

Doing it this way, I hope to have a good span of possible start values for the random generator. Did I miss anything?

8-May 12:36
10479GeomolOh no, I go for 0:00. :-)8-May 11:27
10478Pekrtry to switch you PC to 23:59 and do some loop which will print time :-)8-May 11:26
10477Geomolthat -> what8-May 11:24
10476GeomolDoes anyone know, that now/time show at midnight? Is it 24:00 or 0:00?8-May 11:22
10475GeomolIt seems, that random/seed now does exactly the same as random/seed now/precise (Only tested under OS X so far.)8-May 10:54
10474GeomolThis is misleading to me. I got the impression, that I could do random/seed to decimal! now/time/precise but that's no good! Should it be reported as a bug/flaw?8-May 10:50
10473GeomolYes, random/seed with a decimal doesn't use the seed: >> loop 10 [random/seed 1 random/seed to decimal! now/time/precise prin [random 100 ""]] 52 52 52 52 52 52 52 52 52 52

So I need to construct an integer from the time.

8-May 10:48
10472GeomolMaybe random ignore the /seed and just give me a decimal random number?8-May 10:44
10471GeomolAh yes, there is a 24 hour cycle problem with my approach. I could construct a more unique decimal taking year, month and day into account. Hm, random/seed returns a value, if called with a decimal!? Called with an integer, it doesn't. A reason for this? >> random/seed 100 >> random/seed 100.0 == 41.08-May 10:43
10470GeomolThe starting seed seems to be 1.8-May 10:39
10469Gabrieleno /seed - rebol always starts with the same seed (not sure, maybe 0), in order to allow testing8-May 10:33
10468Gabrielerandom/secure - it has been explained already, instead of using the libc rand() call, a crypto-safe random algo is used.8-May 10:33
10467GabrieleGeomol, you need a single daemon to give you out random numbers, or, if you're on Linux, use /dev/random or something like that. to decimal! now/time/precise means that your numbers just cycle in 24 hours, that is, i can easily predict what your password will be at a certain time of the day.8-May 10:31
10466Sunandarandom/seed now/time/precise followed by an indeterminate number of random/secure to-decimal now/time/precise or a few waits will make it harder for anyone trying to guess your passwords.

But none of that guarantees you won't produce a random number you already have. If you need your passwords to be unique, you need to do one of several things: -- check each one against all previously issued (as I've suggested) -- generate a unique pool in advance (as Gregg suggests)

Both approaches introduce a potential security flaw: the table/pool of passwords is an attack point for a hacker.

8-May 9:23
10465GeomolI think, I should do, as I first suggested: random/seed to binary! now/time/precise before making my random password. If I put in a little wait, I can also make sure, I don't produce the same password two times in a row.8-May 8:34
10464Geomol"REBOL has a starting seed value (unknown with out extensive testing)" It seems to be 1. The first random call right after a startup will give the same result as random/seed 1 followed by the same random call. It's hard for me to see, what secure does, as seen in this example: >> loop 10 [random/secure/seed 1 prin [random/secure 100 ""]] 47 47 47 47 47 47 47 47 47 478-May 8:30
10463Geomol:-D8-May 8:25
10462ReichartLOL...8-May 5:50
10461Grahamjust pick words out of the evolution thread .. for random noise8-May 5:44
10460Reichart"what happens if no random/seed is used in a REBOL program?"

That same thing that happens with almost all random generators, which is a pattern is used. REBOL has a starting seed value (unknown with out extensive testing). However, it will (and should) have the same value upon start up.

The problem (you are perceiving) is with the word "RANDOM"

Perhaps it should be called PATTERN instead.

However, if seeded, RANDOM in turn will use a formula to generate more in the series. This is indeed true random, in as much as the seed's size sets the size of the universe.

So, if you want to always have a random set, you need to get fresh random data (hmmm, I seem to recall mentioning this in another thread).

Of note, the RANDOM we use in slot machines is NOT like REBOL's random function.

REBOL's RANDOM (like most language random functions) is really SEED+OFFSET in a series. (thus a pattern).

I'm not sure what Carl did to make it secure, but my best guess is he is sucking in what ever he can find to make it Random (this doing what I'm suggesting in the first place).

For example, reading the mouse port, temperature, current time (to the jiffy), etc. This would make RANDOM what you expected it to be in the first place…but in theory this would be slower. In your case, this would be the way to go.

8-May 5:27
10459GeomolGreat idea! :-) And a simple solution.7-May 17:45
10458GreggGenerate pools of passwords, and store a counter to use when you need to re-seed and generate a new pool. That way you can generate them over a long period of time and just pull them as necessary.7-May 17:44
10457GeomolI need to do something like Sunanda suggest. But before I do that, I would like to know, if I can do it in another way. And then it would be cool, if I learned, what exactly random/secure mean.7-May 17:21
10456GeomolTo illustrate my point, try create this rebol script (call it random.r or whatever) on you disk:

REBOL []

print random 100 ask "OK"

Now click it from the explorer in windows. I get the result 95 every time. That's not random!

7-May 17:19
10455GeomolEdgar, I know that. My question is, what happens if no random/seed is used in a REBOL program? My other question is, what does random/secure mean?7-May 17:11
10454EdgarGeomol, the problem with your loop is that yuo have the random/seed in the loop. The random/seed is called once then make your loop with just the random or random/secure.7-May 17:05
10453SunandaAs I suggested above, if it is a webservice, you can use other things in addition to the precise time: -- caller's ip address -- referer URL They will vary between calls -- unless exactly the same incoming URL is processed at exactly the same moment....That's unlikely, even if someone is resetting the server's time.7-May 15:34
10452GeomolWhat I'm after, is a secure way to produce a password, also in a webservice, that could be called many times each second. RANDOM/secure can produce the same output again and again, as can be seen with this: >> loop 10 [random/seed now/precise prin [random/secure 100 ""]] 61 61 61 61 61 61 61 61 61 61 See the block as the webservice. So here it's not good to use random/seed. If I leave out random/seed, what then define the initial state of the random generator? I need to know this to figure out, if this is a secure way to produce a password or not.7-May 11:08
10451SunandaIt claims to be a "cryptographically secure random". That won't stop clashes though

http://www.rebol.com/docs/words/wrandom.html

7-May 10:38
10450GeomolWhat do random/secure do precisely? Does anyone know?7-May 10:36
10449SunandaYou could drop the seeding and just use random/secure loop 10 [prin [random/secure 100 " "]] 99 22 67 18 31 6 54 80 94 247-May 10:33
10448GeomolGabriele, I'm afraid, that's not good enough. Try this: >> loop 10 [random/seed now/precise print random 100] 28 28 28 28 28 28 28 28 28 28

While if I do it my way, I get this: >> loop 10 [random/seed to decimal! now/time/precise print random 100] 75 53 21 3 2 57 54 69 74 15

(I did it under OS X with version 2.7.6)

7-May 10:28
10447GabrieleGeomol, use RANDOM/SEED NOW/PRECISE (no /time and no to decimal!)7-May 10:21

Return to Index Page