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

Examining the layout object

 [1/11] from: carl:cybercraft at: 1-Jul-2002 15:37


Hi all, 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? -- Carl Read

 [2/11] 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
<<quoted lines omitted: 24>>
> ** 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

 [3/11] from: carl:cybercraft at: 1-Jul-2002 18:16


Hi again, Just realised that it's the text-list that's causing the error. Replacing the text-lists with areas in the much bigger layout I'd been having the problems with allowed the script to look all through it. So, I've narrowed the error down to 'face being a function sometimes, but while this... print type? :face gets round it for a word, I don't know how to do that for a function in an object. ie, this doesn't work...... print type? :face/pane pane still being evaluated. So, what's the solution to that? Carl. On 01-Jul-02, Carl Read wrote:
> Hi all, > I've been trying to write a script to examine layouts, but I always
<<quoted lines omitted: 24>>
> ** Near: iter/offset: iter/old-offset: id - 1 > I'm totally stumped! Any ideas for what's wrong?
-- Carl Read

 [4/11] from: nitsch-lists:netcologne at: 1-Jul-2002 9:07


Am Montag, 1. Juli 2002 05:37 schrieb Carl Read:
> Hi all, > I've been trying to write a script to examine layouts, but I always
<<quoted lines omitted: 4>>
> if not object? face [exit] > print type? face/pane
AFAIK panes can be functions (for iterated faces like lists). so face/pane can be executed..
> either block? face/pane [ > foreach pane face/pane [examine pane]
<<quoted lines omitted: 16>>
> ** Near: iter/offset: iter/old-offset: id - 1 > I'm totally stumped! Any ideas for what's wrong?
-Volker

 [5/11] from: joel:neely:fedex at: 1-Jul-2002 7:05


Hi, Carl, Carl Read wrote:
> So, I've narrowed the error down to 'face being a function sometimes, > but while this...
<<quoted lines omitted: 4>>
> pane still being evaluated. >> foo: make object! [
[ a: 1 [ b: 2 [ c: func [] [a + b] [ ]
>> print type? get in foo 'c
function HTH! -jn- -- ; Joel Neely joeldotneelyatfedexdotcom REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] { | e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]

 [6/11] from: brett:codeconscious at: 2-Jul-2002 17:30


Hi Carl, For interest, here is how RT do it: source find-key-face Regards, Brett.

 [7/11] from: carl:cybercraft at: 2-Jul-2002 22:39


On 02-Jul-02, Joel Neely wrote:
> Hi, Carl, > Carl Read wrote:
<<quoted lines omitted: 13>>
> function > HTH!
Thanks Joel, it did. (And thanks to the others who replied too.) Here's a working (at least for me) version of the layout examiner... ---8<--- REBOL [] examine-lo: func [face][ style: func [face][ if error? try [return join " Style: " face/style][""] ] examine: function [face spaces][panes][ prin join spaces type? :face if not object? :face [print "" exit] print style :face append spaces " " panes: get in face 'pane print rejoin [spaces type? :panes style :panes] either block? :panes [ foreach pane face/pane [examine :pane spaces] ][ examine :panes spaces ] remove/part spaces 4 ] examine face "" ] lo: layout [text-list] examine-lo lo ---8<--- The example at the end there prints out... object Style: none block object Style: text-list object Style: none object Style: none block object Style: box function function object Style: slider object object none none -- Carl Read

 [8/11] from: carl:cybercraft at: 3-Jul-2002 13:34


On 02-Jul-02, Brett Handley wrote:
> Hi Carl, > For interest, here is how RT do it: > source find-key-face
Hmm. I can't get find-key-face to return anything but a none or an error - probably because I don't know what a keycode is...
>> ? find-key-face
USAGE: FIND-KEY-FACE face keycode DESCRIPTION: Search faces to determine if keycode applies. FIND-KEY-FACE is a function value. ARGUMENTS: face -- (Type: object) keycode -- (Type: char word) What's the function for? -- Carl Read

 [9/11] from: anton::lexicon::net at: 3-Jul-2002 13:10


Well, as written right in front of you, it's a char! or a word! From memory, there are words like: 'page-up, 'page-down, 'left or 'left-arrow... floating around in VID-land somewhere. Otherwise, it's a specific character. Here's a quick test I did. A layout with a button that responds to the "h" key (but does nothing about it...) lay: layout [button #"h" "Hello"] find-key-face lay #"j" ; == none find-key-face lay #"h" ; does not return none - a good sign probe get in find-key-face lay #"h" 'style ; == button We seem to have found the button. Anton.

 [10/11] from: brett:codeconscious at: 3-Jul-2002 13:52


Hi Carl, As Anton has shown, it finds a face that has the specified shortcut key defined on it. It is called by another part of VID to implement shortcut keys for VID layouts. Based on the logic of this function I wrote a few face search functions that find faces given a function that tests a condition: http://www.codeconscious.com/rebsite/rebol-library/face-searches.r In answer to the next question "what have you used these for?", I used them in my "Play app" demos on Rebiste "Code. C.". These demos were an experiment automating pre-existing view applications .eg. Calculator, Effect lab. My demo uses the search functions to find buttons and activate them, etc. finally taking a screen (face) capture of the resulting screens. Given your explorations of the face (and it pane) resulting from the Layout function, I thought you might be interested. Regards, Brett

 [11/11] from: carl:cybercraft at: 4-Jul-2002 0:13


On 03-Jul-02, Brett Handley wrote:
> Hi Carl, > As Anton has shown, it finds a face that has the specified shortcut > key defined on it. It is called by another part of VID to implement > shortcut keys for VID layouts. Based on the logic of this function I > wrote a few face search functions that find faces given a function > that tests a condition: >
http://www.codeconscious.com/rebsite/rebol-library/face-searches.r
> In answer to the next question "what have you used these for?", I > used them in my "Play app" demos on Rebiste "Code. C.". These demos
<<quoted lines omitted: 4>>
> Given your explorations of the face (and it pane) resulting from the > Layout function, I thought you might be interested.
Thanks Brett (and Anton.) Yes, it's something that could prove useful. Oh, and my little script was a wee bit bugged. (: It would print the same object twice if its pane was an object and not a block. Fixed with this version... REBOL [] examine-lo: func [face][ style: func [face][ if error? try [return join " Style: " face/style][""] ] examine: function [face spaces][panes][ prin join spaces type? :face if not object? :face [print "" exit] print style :face append spaces " " panes: get in face 'pane either block? :panes [ print rejoin [spaces type? :panes style :panes] foreach pane face/pane [examine :pane spaces] ][ examine :panes spaces ] remove/part spaces 4 ] examine face "" ] lo: layout [text-list] examine-lo lo -- Carl Read

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted