• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

AltME groups: search

Help · search scripts · search articles · search mailing list

results summary

worldhits
r4wp5907
r3wp58701
total:64608

results window for this page: [start: 38201 end: 38300]

world-name: r3wp

Group: Core ... Discuss core issues [web-public]
Oldes:
9-Nov-2007
No.. these are based on zlib compression... I was interested in LZW. 
Here is just a compression http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=converter.r
... never mind... I don't need it . It was just for fun.
Graham:
10-Nov-2007
this is puzzling me ... it's a little loop to remove old files
Robert:
11-Nov-2007
Is this consistent? I don't think so:

>> a: make hash! []
== make hash! []
>> b: make block! []
== []
>> a
== make hash! []
>> b
== []
>>
Robert:
11-Nov-2007
In the console yes, but this longer stuff will be returned in code 
as well. And this makes parsing a bit complex.
Robert:
11-Nov-2007
>> reduce [a]
== [make hash! []]
>> reduce [b]
== [[]]
>>
Henrik:
11-Nov-2007
how? parsing will immediately return whether it's a hash! or a block!. 
if you need to keep that information, the block of hash! blocks should 
be serialized first.
Henrik:
11-Nov-2007
>> type? first reduce [a]
== hash!
>> type? first reduce [b]
== block!
Henrik:
11-Nov-2007
>> c: mold/all reduce [a b]
== "[#[hash![]] []]"
>> load c
== [make hash! [] []]
>> first load c
== make hash! []
>> type? first load c
== hash!

No information loss.
Robert:
11-Nov-2007
I mean if you provide a reduce [...] to some parse rules and you 
have a "make hash!..." in the block you need to parse this. Hence, 
the parse rules change if you use block or hash.
Henrik:
11-Nov-2007
which would indeed make the parsing a bit more complex.
Ingo:
11-Nov-2007
Hi Robert, can you give us a an example, where you have this problem? 
I can't see it.

>> h: make hash! [3 4 5]                                    
== make hash! [3 4 5]
>> b: [1 2 3]                                               
== [1 2 3]
>> parse reduce [b] [into [some [set i integer! (print i)]]]
1
2
3
== true
>> parse reduce [h] [into [some [set i integer! (print i)]]]
3
4
5
== true
Gabriele:
12-Nov-2007
Robert, what you see at the console is the output of MOLD. there 
is no 'make and no 'hash! there. if you are *saving* the hash in 
a file or sending thru tcp and so on, use MOLD/ALL (or SAVE/ALL) 
so that hash! can be loaded properly afterwards.
DanielSz:
12-Nov-2007
Is there a built-in function that returns the platform we're running 
on (Windows or Linux or Mac or whatever)?
Ingo:
12-Nov-2007
Hi Robert, do you mean, this?

>> b: [a b c]                   
== [a b c]
>> h: make hash! [a b c]        
== make hash! [a b c]
>> parse reduce [b][block!]     
== true
>> parse reduce [h][block!]     
== false

because a hash!, is a hash! and not a block?

>> parse reduce [h][hash!]      
== true

Then you should use any-block!

>> parse reduce [h][any-block!]
== true
>> parse reduce [b][any-block!]
== true
DanielSz:
14-Nov-2007
There is a nice script that encodes strings to utf-8. It is by Romano 
Paolo & Oldes. I'd like the reverse:  decoding utf-8 strings. I found 
a script by Jan Skibinski proposing to do that, but the script doesn't 
load in rebol, exiting with an error ('map has no value). What's 
next?
DanielSz:
14-Nov-2007
BTW, I noticed that rebol.org serves pages in utf-8 encoding, but 
the scripts themselves are latin-1. This is not a problem for the 
code, but it is a problem for the comments, which may contain accented 
characters. For example, names of authors (hint: Robert Müench), 
and they consequently appear garbled. I'm not saying pages should 
be served as latin-1, on the contrary, I am an utf-8 enthusiast, 
I think rebol scripts themselves should be encoded as utf-8, (it 
is possible with python, for example). I hope Rebol3 will be an all 
encompassing utf-8 system (am I dreaming?).
btiffin:
14-Nov-2007
It's on the discussion plate.  Gabriele mentioned that unicode will 
help REBOL open up in Asia, so it's a topic at the high levels.  
A couple of rebols have done some very nice work on fonts and character 
sets.  Jerry Tsai comes to mind ... check the Unicode group for some 
of his links.  Oldes has also pulled off some nice translators...again 
links in the Unicode group.  To name but two.  Even Bi-Di is being 
discussed.
Sunanda:
15-Nov-2007
2000 sounds about the limit for R2. There's a script here that tests 
various limits like that:

http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=rebol-stress-test.r
Anton:
15-Nov-2007
Pekr, I think it depends how many local vars are used in the function. 
With one local var, I got 14263 recursions before stack overflow. 
Maybe he can optimize by moving some variables out into a shared 
context.
amacleod:
28-Nov-2007
I'm tring to open a .pdf from rebol script using "call" function. 
It works but i get that MSwindows console window poping up too. I 
know if you call the application (acrobat reader) at the same time 
you do not get the console window. any otehr wat to suppress the 
console from popping up?
BrianH:
29-Nov-2007
If the application starts and returns immediately, the console will 
close before you get a chance to see it. I think acrobat is one of 
those programs. If you are opening this pdf in the free reader, I 
would seriously suggest upgrading to reader 8.1.1 for security reasons, 
and because it's better.
Rod:
5-Dec-2007
Any binary parse wizards ever tried to tackle the on disk file format 
that postgresql uses to store row data?


I'm looking through the docs trying to get a handle on how tough 
it is.

http://www.postgresql.org/docs/8.1/static/storage.html
and

http://www.postgresql.org/docs/8.1/static/storage-page-layout.html


give a fairly detailed starting place, plus the source of course 
but my C is so rusty I think reviewing the raw data is going to be 
easier.


We are trying to recover some data that was deleted (marked for) 
by accident.  We basically need to find the serial key value and 
associate it with a text value for each row so we can rebuild the 
table and not lose the relationships that key off that serial numeric 
value in other tables.


There are some good examples of binary parsing in the rebol.org script 
library so I know rebol can help write out a text version of the 
two values if we can get a handle on the structures involved.


I'm open to suggestions or advice, this is not critical but would 
be a nice win to recover the key data.
Oldes:
6-Dec-2007
I'm quite interested and I may give it a try... but I don't know 
when
Oldes:
6-Dec-2007
here is a basic... http://box.lebeda.ws/~hmm/rebol/pgsql-db.rthis 
reads the postrge's file per pages... but I'm not sure what to do 
with the data inside and have to do something else now
BrianH:
14-Dec-2007
If script %a calls script %b, b's system/script/path is set to its 
directory, and b's system/script/parent/path is set to a's directory.
Henrik:
14-Dec-2007
perhaps a quick routine to find the root script?
BrianH:
14-Dec-2007
x will never equal a/parent.
BrianH:
14-Dec-2007
a/ -> x/
Henrik:
15-Dec-2007
I see the problem now. Or at least a problem: If you 'do the same 
script multiple times in the console, the system/script object depth 
increases.
Henrik:
15-Dec-2007
another note: parent equals none the same time as the script header 
does, so to properly check whether you really don't have a parent, 
if you want to see the header, you should check parent/header, not 
just parent.
BrianH:
15-Dec-2007
No, the script object depth only increases if the script depth increases. 
When a script ends, system/script is set to system/script/parent.
BrianH:
15-Dec-2007
Or is the script creating some functiona and objects and returning 
so the caller can use them, then being reloaded by the caller to 
do this all over again? I wrote a server application in 2000 that 
acted that way, with scripts migrating the data from the previous 
incarnation still in memory.
Graham:
27-Dec-2007
I need to map a pair from one coordinate system to another.
Graham:
27-Dec-2007
So, I have two pairs initially, specifying a top left and bottom 
right.
eg. 4x26 => 38x729, and 234x355 => 600x62

So, I need a function that works like this

remap 4x26 38x729 234x355 600x62 n1xn2
=> n3xn4


that is, it takes the 2 sets of pairs as argument, and a new pair, 
and returns the value of the new pair mapped to the new coordinates.
Graham:
27-Dec-2007
What I am doing is taking two sets of pairs on a PNG image, and trying 
to map to the EPS image as postscript coordinates.
Gregg:
27-Dec-2007
Probably not something as simple as this, though, eh?

remap: func [a-ul a-br b-ul b-br pt] [
	res-x: pt/x / (a-br/x - a-ul/x) * (b-br/x - b-ul/x) + b-ul/x
	res-y: pt/y / (a-br/y - a-ul/y) * (b-br/y - b-ul/y) + b-ul/y
	as-pair res-x res-y
]

(untested)
Graham:
27-Dec-2007
but the second rectangle uses a different coordinate system.
Graham:
27-Dec-2007
so, I'm using the actual points where the top left of the image starts 
and the bottom right where the image ends ... surrounded by a little 
whitespace
Gregg:
27-Dec-2007
; How about something like this:

remap: func [a-ul a-br b-ul b-br pt] [

 res-x: (b-br/x - b-ul/x) / (a-br/x - a-ul/x) * (pt/x - a-ul/x) + 
 b-ul/x

 res-y: (b-br/y - b-ul/y) / (a-br/y - a-ul/y) * (pt/y - a-ul/y) + 
 b-ul/y
	as-pair res-x res-y
]
remap 4x26 38x729 234x355 600x62 4x26
remap 4x26 38x729 234x355 600x62 38x729
Henrik:
30-Dec-2007
I was wondering why this happens:


>> a: does [try [2 / 0]]
>> a

** Math Error: Attempt to divide by zero
** Where: a
** Near: 2 / 0
>> try a

** Math Error: Attempt to divide by zero
** Where: a
** Near: 2 / 0
>> error? a
** Math Error: Attempt to divide by zero
** Where: a
** Near: 2 / 0



Whereas when ERROR? is put inside the function, it catches the error 
properly.


>> a: does [error? try [2 / 0]]
>> a
== true



Is returning a value or an error considered an extra step that causes 
ERROR? not to catch the error in time?
Henrik:
30-Dec-2007
>> a: does [try [2 / 0]]
>> disarm a

** Math Error: Attempt to divide by zero
** Where: a

** Near: 2 / 0
Henrik:
7-Jan-2008
is it possible to embed/serialize binding information? I have a fairly 
complex object where functions in it are supposed to be bound to 
their parent context, but when loading, they are bound to 'system 
(or nothing). to solve this, I manually rebind every function, which 
seems rather clumsy. is there a more direct way?
Chris:
7-Jan-2008
; I'm not sure you can bind whole objects, but you can at least make 
short work of the manual process.  Here's a quickie I've used:

reconstitute: func [object [object!] /local bindings][
	append bindings: [] object
	foreach word next first object [
		switch type?/word word: get in object word [

   function! [foreach context bindings [bind second :word :context]]
			block! [foreach context bindings [bind :word :context]]
			object! [reconstitute :word]
		]
	]
	remove back tail bindings
	object
]
Chris:
7-Jan-2008
Yep, if you were to do -- context: [a: b: :an-object] -- while you 
could bind a reconstituted 'a and 'b to 'an-object, it would be clones. 
 Possibility: where you are working with faces, you could specifically 
change eg. the feel to lit-word/path before saving, then allow a 
'reconstitute-like function replace that value with the related object. 
 It's a little messy, but still such functions could still be nearly 
as short...
Henrik:
8-Jan-2008
anyone know of a function to calculate the relative path between 
two branches in a file system?
amacleod:
11-Jan-2008
I want to sync some files on a server. what is the usual method? 
This file will be a rebol script so I thought placing a "version:" 
in the rebol header would be logical. I tried to "load/header" but 
I get the whole script and its no evaluated so I can not just get 
the  version value.
Anton:
11-Jan-2008
Yes, you must write your own version parsing function which loads 
only a part of the file.
btiffin:
12-Jan-2008
Alan;  You can try  var: load/header/next   first var will be the 
header as object, second var will be the rest of the script as a 
string.   var/1/version should be your tuple!  (assuming you use 
tuple).  In terms of the evaluation it is deemed "light", values 
but not code.  So   version: 3.2.1 ok,  version: to tuple! [3 2 1] 
 won't be a tuple, var/1/version will be 'to   So Anton is correct.


Another thing to check out the mezzanines (from View)  load-thru 
  read-thru  and the source for exists-thru?  These may have some 
hints for what you want.
Will:
12-Jan-2008
head clear find/last copy a #"."
ChristianE:
13-Jan-2008
If it wasn't for that extra TO-FILE in SUFFIX?, you'd just use COPY/PART:


>> suffix?: func [path [any-string!] "Return the suffix (ext) of 
a filename or url, else NONE."] [if all [path: find/last path %. 
not find path #"/"] [path]]
>> file: %my.test.file.txt
== %my.test.file.txt
>> copy/part file suffix? file
== %my.test.file
[unknown: 5]:
13-Jan-2008
I'm just curious if there is a way to make a function think an argument 
was passed to it even though an argument wasn't passed to it.
Henrik:
13-Jan-2008
a: func [b [word! unset!]] []
[unknown: 5]:
13-Jan-2008
that might work Henrick, I'm trying a few things now.
Graham:
14-Jan-2008
should have a native that does this
Gabriele:
16-Jan-2008
i have one i've used for a long time too... also adds ' every three 
digits... i added support for scientific notation recently (because 
form always gives sci notation on Wine)
Henrik:
24-Jan-2008
how is it again that I can rebind a function to a different context?
Henrik:
25-Jan-2008
>> a: does [print b] 
>> c: make object! [b: 4]
>> a

** Script Error: b has no value
** Where: a
** Near: print b
>> bind second :a 'c

== [print b]
>> a
** Script Error: b has no value
** Where: a

** Near: print b
Henrik:
25-Jan-2008
solved with:

bind second :a c
BrianH:
25-Jan-2008
You don't rebind the function, you rebind its code block - not quite 
the same thing. Bind/copy wouldn't work because it creates a copy 
rather than rebinding the original block. You can alter the contents 
of the code block of a (R2) function, but you can't change the function's 
reference to that block to point to another block.
BrianH:
25-Jan-2008
If you can create a new function, you can use bind/copy. It is occasionally 
possible to arrange your algorithm so that it is possible to replace 
a function without worrying about aliased references, but usually 
not.
Anton:
25-Jan-2008
I think I remember, bind/copy is just a short equivalent to bind 
copy/deep.
btiffin:
30-Jan-2008
What is the deal with mod and modulo?   What should   mod 10 3   
 mod 10 -3    mod -10 3   mod -10 -3   return?  Not what REBOL returns 
... what's the math of it supposed to be.


I accept  1 and 2, but -4 (mod -10 -3) freaks me out.  I don't use 
mod very often (and never with negative divisors or dividends), but 
it came up in a conversation with some student programmers (and I'm 
trying to convince them to give REBOL a try).
Tomc:
31-Jan-2008
I do not have a mental model of what a modulo < 2 could be never 
mind less than zero.  until is has an accepted definition in mathematics 
programming languages ought steer clear
btiffin:
31-Jan-2008
Thanks.  I just needed to source mod to see where it was coming from. 
 REBOL's mod does make mathematical sense, just needed to get my 
head round it.    Things like  mod -10 -11 being -21.


And Tom, yep.  :)  But I think I've grown to like REBOL's definition. 
  And I would expect anyone that needs negative divisors for a modulo 
calculation will understand the implications.
Oldes:
31-Jan-2008
>> ?? mod
mod: func [
    "Compute a nonnegative remainder of A divided by B."
    [catch]
    a [number! money! time!]
    b [number! money! time!] "Must be nonzero."
    /local r
][
    all [negative? r: a // b r: r + b]
    a: abs a
    either all [a + r = (a + b) positive? r + r - b] [r - b] [r]
]
>> ?? modulo
modulo: func [

    {Wrapper for MOD that handles errors like REMAINDER. Negligible
^-^-values (compared to A and B) are rounded to zero.}
    [catch]
    a [number! money! time!]
    b [number! money! time!] "Absolute value will be used"
    /local r
][
    throw-on-error [
        any [number? a b: make a b]
        r: mod a abs b
        either any [a - r = a r + b = b] [make r 0] [r]
    ]
]
Oldes:
31-Jan-2008
the // is same like the mod(a, n) = a - n * floor(a / n) (from the 
Wiki page above)
Gregg:
31-Jan-2008
Ladislav spent a lot of time, and much discussion was had, on those 
functions.
Pavel:
8-Feb-2008
To Oldes, any way to create general event (not gui) port? And create 
on demand events (fire and receive). Can such a port be global accesible 
to independent rebol processes? Can some scheme solve this?
Pavel:
8-Feb-2008
Must this be a TCP port?
Henrik:
8-Feb-2008
the easiest way is via TCP or a file, I think
Robert:
9-Feb-2008
IIRC I posted this topic once but there was no real good solution 
to it. I often face the following problem:


My app performs a bunch of calculations based on user input. Now, 
if a user hacks in extremly big numbers, the app crashes because 
of "math overflow".


The hard part is that it's mostly impossible to predict at which 
calculation step this will happen. Making code "division by zero" 
proof is not problem, but how do I make my code "math overflow" proof?
Gregg:
10-Feb-2008
What about having a central calculation engine in the app, and passing 
everything through that?
Robert:
11-Feb-2008
Example: We have this simple formular:

result: (a * b) + (c * d)

There are three points of failure:
1. a * b overflows
2. c * d overflows
3. (a * b) + (c * d) overflows


And if you need to give feedback to the user you have to check every 
single operation.
Sunanda:
11-Feb-2008
I'd suggest something like this:

-- calculations are done in a special function that is passed a string, 
eg
   ans: calc "(a * b) + (c + d)"
-- the 'calc DOes the string, protected by an 'attempt
-- if it succeeds, it passes back the result

-- if not, it throws an error report. If necessary, you can parse 
the original string and try each part of the calculation to find 
the first failure....Recursively via 'calc to drill down nested parentheses 
of course.

**

Two obvious drawbacks to this suggestion:

1. all variables need to be global -- unless you do a lot of other 
work

2. beware side effects of malformed calc strings. You would not like 
it to be "delete/any *.*"
Henrik:
12-Feb-2008
>> read http://store.apple.com

connecting to: store.apple.com
connecting to: store.apple.com

** User Error: Error.  Target url: http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore
could not be retrieved.  Server response...
** Near: read http://store.apple.com

That's not a particularly useful error?
Reichart:
13-Feb-2008
Would be cool to reduce that argument (debate) to a table (like Gregg 
did for Python).  If someone does that part, I will update the Qwiki...
Reichart:
13-Feb-2008
Would love to have a collection of REBOL vs EVERYTHING
Oldes:
13-Feb-2008
And one can always use  trace/net on  to see, where is a problem
Henrik:
13-Feb-2008
must have been while the store was down. some one came up with a 
bash script to check when it would come up again, and thought it 
would be easy to do in rebol, but no. :-/
Henrik:
13-Feb-2008
when the store is down, the replace the page with a message. it's 
not like the site goes entirely down.
Oldes:
13-Feb-2008
the server response is truncated only in console... I've just tested 
it with a very long invalid local url.
Oldes:
13-Feb-2008
and someone should fix the altme to display correctly urls... is 
it just me who don't like it? Such a visible thing:/
Oldes:
13-Feb-2008
and it's such a simple fix.. it just needs to enhance the width of 
the face which is used to measure the width of the text.... I bet 
it's just a one byte fix.
james_nak:
15-Feb-2008
Here's something I haven't figured out yet: Let's say I have an object 
that includes other objects
make object! [
lists: ["tom" "fred"]

objs: [ [ make object! [ name: "hello"] ] [make object! [name: "world"] 
]  ]
]

When I "load" this back from a file, is there a way I can "do" the 
entire object. It appears that the obj/objs remain in their rebol 
form but are not "real" objects. For now I have been just "doing" 
them as I get to them but it sure would be nice to simply get it 
done all at once.

Thanks, I hope you understand what I mean.
Graham:
15-Feb-2008
do you try save/all to save the object to a file?
Anton:
15-Feb-2008
James,
Create some nested objects:


 objects: context [objs: reduce [reduce [context [name: "hi"]] reduce 
 [context [name: "there"]]]]
	
Save them in a binary (should be just like saving to file):

	bin: make binary! ""
	
	save/all bin objects
	
Load back from the binary (should be like loading from file):
	
	objects2: do as-string load bin
	
Test to see if the nested objects were created properly:	
	
	>> type? objects2/objs/1/1
	== object!

	>> probe objects2/objs/1/1
	make object! [
		name: "hi"
	]
[unknown: 5]:
16-Feb-2008
I need to be able to explicitly determine if something some functions 
return false as their value.  I wrote a quick function to do this 
but shouldn't we already have something that does this?

My function is:


false?: func [val][either all [logic? val not val][return yes][return 
no]]
btiffin:
16-Feb-2008
That would be truefalse  :)   Sorry, couldn't resist.  But, yes, 
REBOL is very tri-state with the t f none thing. And zero being true, 
as a forther still rubs wrong, but that chaffing is almost over and 
done with.  Plus RebGUI now supports bi-state options, so life is 
good(er).  :)
btiffin:
16-Feb-2008
Sorry, I meant   a "true" false.
btiffin:
16-Feb-2008
strict-equal? compares value and type, and then there is identical 
testing with =?   where

a: "abc"  b: "abc"     a =? b  is false   c: a   a =? c  is true 
(pretty much has to occupy the same ram)
[unknown: 5]:
16-Feb-2008
that is what I thought btiffin - when you mentioned using strict-equal? 
you have me confused.  How did you see it being used in a true false 
function?
[unknown: 5]:
17-Feb-2008
Yeah I don't see a need for a true function only a false function.
[unknown: 5]:
17-Feb-2008
Anyone know of a bug in REBOL where the word "end" shows up in a 
list! of values?  I have got this weird problem where the word "end" 
shows up in what should be a list! block of nothing but integers 
but instead I have integers and a few references of the word "end" 
without the string as it is not a string datatype.  If I do a foreach 
and attempt to step through each item it crashes on that entry.  
I can't determine what datatype it is.  I looked at my code and nothing 
in my code or the data it handles contains the word "end".
[unknown: 5]:
17-Feb-2008
I did some more research and it appears that the "end" I seen is 
a datatype.  I didn't even know there was an end! datatype.
[unknown: 5]:
17-Feb-2008
here is what the list block looks like for example:


== make list! [1 4 5 end unset 6 7 8 9 10 11 12 13 14 15 16 17 18 
19]

except it is a lot longer


I'm not sure why I'm getting the unset! or the end! datatypes at 
this point.  I only use insert to add to this list and all the values 
being inserted should be integer datatypes.
[unknown: 5]:
17-Feb-2008
I actually did that and it got no errors which really has me a bit 
stumped.
[unknown: 5]:
17-Feb-2008
Hmm... ok then that might explain something.   I recall a copy function 
I had that caused the interal code of REBOL to spill out so I assume 
it has something to do with my port handling as that copy function 
I had did similiar.
[unknown: 5]:
17-Feb-2008
So it might be in the area where I have a copy/part on file data 
which would result in a block.
Geomol:
17-Feb-2008
What do you see, if you do a
>> ? system/version
Geomol:
17-Feb-2008
Have you checked the bug database, if it's a known issue?
http://www.rebol.net/cgi-bin/rambo.r
38201 / 6460812345...381382[383] 384385...643644645646647