Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] context exploration

From: rebol:svendx:dk at: 24-Jul-2000 4:03

Warning: This is a message in MIME format. Your mail reader does not support MIME. Some parts of this message will be readable as plain text. To see the rest, you will need to upgrade your mail reader. Following are some URLs where you can find MIME-capable mail programs for common platforms: Amiga............: YAM http://www.yam.ch/ Unix.............: Metamail ftp://ftp.bellcore.com/nsb/ Windows/Macintosh: Eudora http://www.qualcomm.com/ General info about MIME can be found at: http://www.cis.ohio-state.edu/hypertext/faq/usenet/mail/mime-faq/top.html --BOUNDARY.149080856.2 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable 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 --BOUNDARY.149080856.2 Content-Type: text/rebol; name="context-fun.r" Content-Disposition: attachment; filename="context-fun.r" 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 ] --BOUNDARY.149080856.2--