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

[REBOL] printing a path and its value Re:

From: jkinraid:clear at: 9-Sep-2000 15:49

> I want to print a path (ie, what the path is) and then the value of that path... how can I do so? > > diag: func [path-block [block!]] [ > foreach p path-block [ > prin p > print " " > print reduce p > ] > ] > > diag [ system/schemes/ftp/passive > system/schemes/ftp/proxy/host > system/schemes/ftp/proxy/port-id > system/schemes/ftp/proxy/type > ]
You were close, but you were one step of evaluation ahead... 'prin p' needs to be changed to 'prin :p', because 'prin p' will evaluate the path, whereas 'prin :p' won't evaluate 'p, so the path is printed, not what the path points to. This also means that you don't need to use reduce, because an implicit reduction is done with 'print p'. This is the result: diag: func [path-block [block!]] [ foreach p path-block [ prin :p print " " print p ] ] If you want the output on one line, you can just do this: diag: func [path-block [block!]] [ foreach p path-block [ print [:p p] ] ] Hopefully I haven't confused you too much, my brain is very foggy right now :) Julian Kinraid