Hello,
While playing with contexts, I threw together this little function to show the words
that are defined in a context (and their values in that context).
(something like that have been discussed before AFAIR, but a 1min. search didn't find
it, sooo :-)
It goes like this:
show-context: func [word [word!]] [
foreach x-word next first system/words [
if value? bind x-word :word [
print [:x-word "|" get bind x-word :word]
]
]
]
Attached is a script that demonstrates the use of the function with contexts created
with func, use and make object!
Best regards
Thomas Jensen
REBOL []
show-context: func [word [word!]] [
foreach x-word next first system/words [
if value? bind x-word :word [
print [:x-word "|" get bind x-word :word]
]
]
]
a: "global-a"
b: "global-b"
c: "global-c"
x: "global-x"
v: "global-v"
o1: make object! [
a: 1
b: 2
o2: make object! [
b: 20
c: 30
test: func [test-arg /local x] [
x: "local-x"
print [a b c]
print "^/-- show-context 'a --"
show-context 'a
print "^/-- show-context 'b --"
show-context 'b
print "^/-- show-context 'x --"
show-context 'x
]
]
]
o1/o2/test "argument to o1/o2/test"
print "^/-- show-context in o1/o2 'b --"
show-context in o1/o2 'b
use [v w] [
v: "local-v"
w: "local-w"
print "^/-- show-context 'v --"
show-context 'v
]