debugging an object
[1/4] from: tim::johnsons-web::com at: 12-Sep-2003 15:14
Hello Rebols:
I'm attempting to write a debug function
which will print out both a data member of an object
and the object name (but not the rest of the objects,
methods etc).
And if it is not an object, just do a simple print-out
as in '??
Given the following code:
; ======================================================================================
obj: context[
_blk_: ["one" 1 "one" 2 "two" "" 1 "here"]
]
dbg: func [ 'name ][
either system/options/cgi/server-name[print <pre>][prin ""]
either all[object? name (in name '_blk_)][
print [ head insert tail form name reduce [": " mold get in name '_blk_] ]
][
print either word? :name
[ head insert tail form name reduce [": " mold name: get name] ]
[ mold :name ]
]
; ====================================================================================
;where
>> some-number: 2
== 2
>> dbg some-number ; just like '??
some-number: 2 ; okay, that's good
>> dbg obj
obj:
make object! [
_blk_: ["one" 1 "one" 2 "two" "" 1 "here"]
]
; that's more than I want to see, really
>> dbg :obj
?object?: ["one" 1 "one" 2 "two" "" 1 "here"]
; Now that's closer, but what I really want to do
; would be
dbg obj
obj: ["one" 1 "one" 2 "two" "" 1 "here"]
any suggestions?
Thanks
tim
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
http://www.johnsons-web.com
[2/4] from: antonr:iinet:au at: 13-Sep-2003 14:53
I don't advise that, because there's nothing to
distinguish this object from a block anymore,
(maybe put a little "o" in front?) but if you
really must, then check out:
>> third obj
== [_blk_: ["one" 1 "one" 2 "two" "" 1 "here"]]
Then just mold that.
Anton.
[3/4] from: ingo:2b1 at: 13-Sep-2003 12:51
Hi Tim,
does this come near?
dbg: func [ 'name /local 'int][
either system/options/cgi/server-name[print <pre>][prin ""]
int: any[all[word? name get name] none]
either all[object? int (in int '_blk_)][
print [ "data of" head insert tail form name
reduce [": " mold get In int '_blk_] ]
][
Print either word? :name [
head insert tail form name reduce [": " mold name: get :name]
][
mold :name
]
]
]
>>
>> obj: context[
[ _blk_: ["one" 1 "one" 2 "two" "" 1 "here"]
[ ]
>> num: 1
== 1
>>
>> dbg obj
data of obj: ["one" 1 "one" 2 "two" "" 1 "here"]
>> dbg num
num: 1
>> dbg 3
3
I added the intermediate 'int, because
in :name '_blk_
didn't work.
I hope that helps,
Ingo
Tim Johnson wrote:
[4/4] from: tim:johnsons-web at: 13-Sep-2003 8:16
* Ingo Hohmann <[ingo--2b1--de]> [030913 03:12]:
Hey Ingo:
You nailed it right on the head!
thanks, that did it.
tim
> Hi Tim,
> does this come near?
<<quoted lines omitted: 39>>
> To unsubscribe from this list, just send an email to
> [rebol-request--rebol--com] with unsubscribe as the subject.
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
http://www.johnsons-web.com
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted