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

[REBOL] Re: Examining the layout object

From: gscottjones:mchsi at: 1-Jul-2002 5:59

From: "Carl Read"
<snip> > I've been trying to write a script to examine layouts, but I always > get an error. Here's an example of the problem... > > REBOL [] > examine: func [face][ > print type? face > if not object? face [exit] > print type? face/pane > either block? face/pane [ > foreach pane face/pane [examine pane] > ][ > examine face/pane > ] > ] > lo: layout [text-list] > examine lo > > And this is the output I get from it... > > object > block > object > object > object > block > object > ** Script Error: Cannot use subtract on block! value > ** Where: pane > ** Near: iter/offset: iter/old-offset: id - 1 > > I'm totally stumped! Any ideas for what's wrong?
Hi, Carl, These out-of-no-where-and-seemingly-totally-"off-topic" errors are frequently the result of indirectly evaluating an expression out of the context. That was a convoluted sentence, I know. In this case that nested structures reaches a point where pane is neither a block nor an object. It is a function, and print is trying to evaluate that function without the proper arguments. Given that I don't know your ultimate goals with your project, here is one work-around that may help to get you back on track. examine: func [face][ print type? face if not object? face [exit] either not error? try [print type? face/pane] [ either block? face/pane [ foreach pane face/pane [examine pane] ][ examine face/pane ] ][print "error - this pane element is probably a function call"] ] lo: layout [text-list] examine lo Hope this is of some help. Maybe a guru will be able to articulate this point more clearly. --Scott Jones