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

World: r3wp

[Core] Discuss core issues

BrianH
12-Jan-2006
[3176]
Does the file execute setting of the secure native mean anything 
on Windows. What is it supposed to mean?
Pekr
13-Jan-2006
[3177x4]
how to easily do base conversion? e.g. working with bitmasks, I want 
to be easily able to obtain e.g. 255, #FF, "11111111"
... and convert between those ...
ah, probably enbase/base #{FF} 2 ..... I just wrongly tried with 
#FF ..... but then each char got converted separately ...
I also found Sunanda's 'base-convert.r script, so forget my question 
....
Gregg
13-Jan-2006
[3181]
From RAMBO group: I don't know about "pretty " versus loadable, but 
what specific issue does it cause that you don't want that extra 
information available? WRT "form 1.0"
Luca
22-Jan-2006
[3182]
I need to "filter" the content of an object. Any better idea on how 
to do it other the this one:
obj: make object! [
	bb: 1
	cc: 4
	dd: 7
]


block: [bb dd]

filter: func [obj block /local newobj][
	newobj: make object! []
	foreach [s v] third obj [
		if find block to-word s [
			newobj: make newobj reduce [
				s v
			]	
		]
	]
	newobj
]

probe filter obj block

Result:

make object! [
    bb: 1
    dd: 7
]
Gregg
22-Jan-2006
[3183]
Here's something I did that may work for you:

obj-spec: func [
    "Returns the object spec as a single line (flat) string."
    obj [object!]
    /only "no surrounding brackets"
    /mold "Multi-line MOLDed format"
    /local res
][
    res: copy find/tail system/words/mold obj "make object! "
    if not mold [trim/lines res]
    if only [res: trim/auto next head remove back tail next res]
    res
]

remove-words: func [

    "Returns a copy of the object with the specified words removed."
    object [object!]
    words  [word! block!] "The word, or words, to remove"
    /local spec
][
    spec: load obj-spec object
    foreach word compose [(words)] [
        remove/part find spec to set-word! word 2
    ]
    make object! spec
]


The reason it doesn't use THIRD on the object is because of how words 
are returned. I use OBJ-SPEC to save object spec blocks to disk for 
the same reason.
Henrik
22-Jan-2006
[3184x3]
if the solution gregg posts is better, use that, but:

a: make object! [
  bb: 1
  cc: 4
  dd: 7
]

block: [bb dd]


make object! foreach word difference first a block [head remove remove 
find third a to-set-word word]
nah, doesn't work
d: third a

make object! foreach word next difference first a block [head remove 
remove find d to-set-word word]

seems to work
Luca
22-Jan-2006
[3187]
Gregg: Thank you, you are right, I forgot the 'THIRD problem. In 
other scripts I used the following solution to bypass it.

'prefs is an object containing various data types.
'rp2pcprefs is the file to save it to

save-prefs: func [/local prefstmp][
	prefstmp: copy/deep [] 
	foreach w next first prefs [
		append prefstmp reduce [to-word w get in prefs to-word w]
	]
	save rp2pcprefs prefstmp
]

load-prefs: func [/local prefstmp][
	prefstmp: make object! [] 
	if exists? rp2pcprefs [
		foreach [w v] load rp2pcprefs [

   prefstmp: make prefstmp reduce [to-set-word w ""] set in prefstmp 
   to-word w v
		]
	]
	prefstmp
]


Henrik: 'difference is a good point I didn't think to, then I like 
the one-liner :), thank you.
Henrik
22-Jan-2006
[3188]
luca, check for stability and binding though. there are always a 
few holes, when messing with objects like that :-)
Luca
22-Jan-2006
[3189]
I will keep it in mind... :-)
Gabriele
23-Jan-2006
[3190x3]
i wrote this a few years ago:
extract-object:
    func [source [object!] dest-template [block! object!]]

    [   if block? dest-template [dest-template: context dest-template]
        foreach word next first dest-template

        [   set in dest-template word get any [in source word 'none]]
        dest-template
    ]
>> obj: make object! [
[     bb: 1
[     cc: 4
[     dd: 7
[    ]
>> probe extract-object obj [bb: dd: none]
make object! [
    bb: 1
    dd: 7
]
Volker
23-Jan-2006
[3193x2]
!>>obj: context[bb: 1 cc: 4 dd: 7]
!>>probe context intersect/skip third obj [bb: - cc: -] 2   
make object! [
    bb: 1
    cc: 4
]
(a few years later ;)
Henrik
23-Jan-2006
[3195]
I should advertise this group some more. Just insert some code, and 
it comes out optimized a few days later. :-)
Gregg
23-Jan-2006
[3196]
Volker, THIRD doesn't work with word! values though; great otherwise. 
:-)
Luca
23-Jan-2006
[3197]
'intersect is very cool. But what the - (minus) sign stay for? What 
does it mean?
Gregg
23-Jan-2006
[3198]
Just dummy values to match the skip 2 format.
Luca
23-Jan-2006
[3199]
Does the minus sign stay for dummy anywhere or just in the intersect? 
I never met it before?
JaimeVargas
23-Jan-2006
[3200]
the dash is just a value. You can put anything there: [NONE + word 
empty] are some options.
Gabriele
24-Jan-2006
[3201]
THIRD *does* work for words, as long as you use CONSTRUCT to rebuild 
the object.
Coccinelle
24-Jan-2006
[3202x2]
I wonder to know the kmeaning of the negative value returned by the 
read-io and write-io function.

- I understand that when a TCP port is close at the other end of 
the communication, the value is either 0 or -1.

- it seems that read-io return -4 when there is no available data 
on the port
But I am not sure to be right.
kmeaning = meaning (sorry)
Henrik
24-Jan-2006
[3204]
does anyone know what PATH is good for?
Gregg
24-Jan-2006
[3205]
Ah! Thanks Gabriele! I don't know why I didn't think of that. :-\
Allen
24-Jan-2006
[3206]
To illustrate for those who may not know what the issue is with third 
/ make

>> c: make object! [a: 'print b: "hi"]
>> ? c
C is an object of value:
   a               word!     print
   b               string!   "hi"

>> spec: third c
== [a: print b: "hi"]

;Using make object! fails
>> e: make object! spec
hi
** Script Error: a needs a value
** Near: a: print b: "hi"

;Contruct works
>> f: construct spec
>> ? f
F is an object of value:
   a               word!     print
   b               string!   "hi"
Anton
25-Jan-2006
[3207]
Henrik, PATH is a function used internally by rebol but probably 
accidentally exposed globally.
Luca
25-Jan-2006
[3208]
'Construct!!!!! How long I've searched for you. :-) Thank you Gabriele
Gabriele
25-Jan-2006
[3209x2]
Coccinelle: the only info available about read-io return codes is 
in the async case. from async:// :
0 or -1: peer closed (ssl:// seems to consider -1 an error and not 
close)
-2: error
-3: would block (i.e. no data ready)
< -3: error
Pekr
26-Jan-2006
[3211x6]
I tried Carl's site monitor - Gismo, but it converts sites to tcp 
ports, instead of staying with http ... how can I easily add proxy 
support to manually constructed tcp port? I do remember some tricks 
with subport where actually port is, but can't make it work easily 
...
looking at sterling's proxy script, I somehow can't understand that 
sub-port concept :-) Looking at rebol core manual, it does not make 
my life any easier :-) Although I can understand the concept of root-protocol 
and how to establish new scheme, it does not help with understanding 
of lower level issues ...
maybe that is why DocKimbel was thinking about dividing port model 
into two layers ....
simply put - scheme model is not so complicated, you can even rather 
easily go and use tpc and udp ... but unless you need something like 
a proxy support ....
can I prevent the black shell window appearance? I try to call/console 
"ping 10.0.0.10", but the black window always appears ...
ah, it is call/console "cmd /C ping 10.0.0.10"
MichaelB
26-Jan-2006
[3217x2]
I'm having the same problem right now. But the black window nevertheless 
appears.
other bad thing I didn't think about/expect was that upon using output/error 
refinement it becomes blocking like with wait refinement
JaimeVargas
26-Jan-2006
[3219]
There is no way around it. Unless you have library access an use 
the asyc-console script from Dockimbel. Or the one shipping with 
the Detective.
MichaelB
26-Jan-2006
[3220x3]
now I can live with the blocking behavior, but would like to show 
the output in a view window - but as it blocks might not be possible
ok, good to know Jaime
so I should really start getting the SDK or pro :-)
JaimeVargas
26-Jan-2006
[3223]
Yep.
MichaelB
26-Jan-2006
[3224]
:-)
Terry
26-Jan-2006
[3225]
I'll pay RT $50 if we change "=" to "==" .. don't know HOW many bugs 
I've generated with other languages over that.