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

World: r3wp

[Core] Discuss core issues

Graham
12-Mar-2005
[669]
I used 1'000'000 here .. don't know if it's enough

    generate-messageid: does [

     rejoin [ "<" enbase form now/time/precise "." enbase form random 
     1000000  "@" server-name ">"]
	]
Gabriele
12-Mar-2005
[670]
basically you need 13 random characters, don't you?
Graham
12-Mar-2005
[671x2]
I"m not sure ...
where does the 13 come from?
Gabriele
12-Mar-2005
[673x2]
a 64 bit number has 64 digits in base 2, and 12-13 digits in base 
36
anyway, since you just need some randomness, a random 12 character 
string will do
Graham
12-Mar-2005
[675]
so use base 32 ?
Gabriele
12-Mar-2005
[676x2]
>> s
== "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
>> pool: "" insert/dup pool s 12
== ""
>> random/seed now
>> copy/part random/secure pool 12
== "GQOTTWDZZXNL"
>> copy/part random/secure pool 12
== "JOFF6QY4T2H8"
>> copy/part random/secure pool 12
== "8RJ2MFTQ0IJQ"
>> copy/part random/secure pool 12
== "ZKCS1DX7UTHL"
>> copy/part random/secure pool 12
== "DY3VJH4UTNFF"
>> copy/part random/secure pool 12
== "KWPNQRIJ40KN"
note that "well seeded" usually means you're seeding from some truly 
random value, rather than the current time
Graham
12-Mar-2005
[678]
I guess since I'm not processing that many email, it doesn't have 
to be truly random.
Gabriele
12-Mar-2005
[679x2]
i think that for your purposes, enbase/base 64 would be just fine
so you could use something like:
Graham
12-Mar-2005
[681]
which is default for enbase ...
Gabriele
12-Mar-2005
[682x2]
generate-messageid: does [

    rejoin ["<" enbase checksum/secure random/secure mold system/error 
    "@" server-name ">"]
]
you could randomize the message itself and then checksum it, too
Graham
12-Mar-2005
[684]
what's the mold system/error for ?
Gabriele
12-Mar-2005
[685x2]
get some (long) text to randomize and then checksum
any random data would do
Graham
12-Mar-2005
[687x2]
generate-messageid: func [eml [string!] [

    rejoin ["<" enbase checksum/secure random/secure eml "@" server-name 
    ">"]
]
sort of ..
Gabriele
12-Mar-2005
[689]
i think that's good for your purposes.
Graham
12-Mar-2005
[690]
ok, thanks Gabriele
Gabriele
12-Mar-2005
[691]
not sure if any char in base 64 could be a problem as a message id 
char, but i think MTAs do use base64 for message ids so probably 
it's fine.
Graham
12-Mar-2005
[692]
might be better to restrict myself to the first 1000 chars or so 
in case the eml is megabytes long ..
Micha
14-Mar-2005
[693x2]
a: make object! [
    b: 4
    c: 6
]
how to remove element b ?
Chris
14-Mar-2005
[695x2]
It's not possible to add or remove values within an object.
You can create a new object based on your object that adds or omits 
values, the latter being trickier.
Pekr
14-Mar-2005
[697]
or you can set b to none ....
Chris
14-Mar-2005
[698]
construct head remove remove find third a to-set-word 'b
Pekr
14-Mar-2005
[699]
:-)
Chris
14-Mar-2005
[700x2]
That would fail under the following circumstance:
a: context [c: to-set-word 'b b: 123]
Pekr
14-Mar-2005
[702]
strange result, I would expect obtaining error here?
>> unset in a 'b
>> probe a

make object! [
    b: unset
    c: 6
]
>> a/b
>>
Micha
14-Mar-2005
[703]
how to add object e: 7 to a ?
Graham
14-Mar-2005
[704]
you have to clone the object with the new instance variable
Ammon
14-Mar-2005
[705]
a: make a [ e: 7 ]
Micha
14-Mar-2005
[706x2]
ok
how to [ d: 5]
word: "d"
integer : "5"
Ammon
14-Mar-2005
[708]
Lookup 'parse for that one..
Pekr
14-Mar-2005
[709]
parse? why parse? What do you mean, Micha?
Graham
14-Mar-2005
[710x3]
what do you want to do?
do [ d: 5 ]
>> d
== 5
Pekr
14-Mar-2005
[713]
>> word: "d"
== "d"
>> integer: 5
== 5
>> set to-set-word word integer
== 5
>> d
== 5
Ammon
14-Mar-2005
[714]
Or did you mean something more like...

foreach [word integer] [a 1 b 2 c 3] [
    print ["Word: " to string! word newline "Integer: " integer]
]
BrianW
14-Mar-2005
[715x2]
I'm getting a confusing error about using paths on a logic! object 
when trying to use the methods of a created object. I figure I'm 
missing something obvious, but I can't figure out what it is:

test-result: make object! [
    run-count: 0
    error-count: 0

    test-started: does [
        run-count: run-count + 1
    ]

    test-failed: does [
        error-count: error-count + 1
    ]

    summary: does [
        return join  run-count [ " run, " error-count " failed" ]
    ]
]


; ...


            ed: make test-result [ ]
            ed/test-started
            ed/test-failed
            assert [ ed/summary == "1 run, 1 failed" ]

; output of code:

[[wisti-:-us1-dhcp-227-65] xUnit]$ rebol xunit.r
** Script Error: Cannot use path on logic! value
** Where: test-failed-result-formatting
** Near: ed/test-started
ed/test-failed
assert [ed/summary == "1 run, 1 failed"]
The code is just me working my way through the book "Test-Driven 
Development" by Kent Beck. I like applying educational exercises 
to new languages as I find them :-)
Ammon
14-Mar-2005
[717]
Where is 'ed defined?
BrianW
14-Mar-2005
[718]
ed: make test-result [ ]