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

[REBOL] Re: Make_user_manual.r ?

From: sunandadh:aol at: 25-Jan-2002 6:22

Brett:
> As for the searching functions we talked about, try these (which are totally > due to the fact that I looked at the source of find-key-face):
Thanks for that. Just to show I'm contributing something to this project rather than Oliver Twist-like just asking for more, here's an extended version of your example. The find-faces is the same, I've changed the example to: -- correct a couple of typos -- make it more emailable friendly ({...} rather than "...") -- show how to find a Choice box -- show how flexible find-faces is as it returns a Block. This last part is particularly useful to me as my prototype application runs off a tree viewer. To run it successfully, we need to be able to click the nth "+" or "-" box to close/open a branch. Rebol [] find-faces: func [ {Search faces - returns those that result in the function evaluating to true.} face [object!] funct [block! function!] {A function or a function body block} /local w f result ] [ if block? :funct [funct: func [face] funct] result: copy [] if funct face [append result face] w: in face 'pane either block? w: get w [ foreach f w [if all [object? f] [append result find-faces f :funct]] ] [ if object? :w [append result find-faces w :funct] ] result ] do-it: func [] [ ;; Change first (should be only) face whose text is "two" ;; to red fce: first find-faces lyo [equal? face/text "two"] fce/color: red show fce ;; get a block of all faces whose text is "+" ;; and turn them pink faces: find-faces lyo [equal? face/text "+"] foreach f faces [f/color: pink show f] ;; Change the last "+" box to a blue "-" if (length? faces) > 0 [ set in last faces 'text "-" set in last faces 'color blue show last faces ] ;; get first item whoses TEXTS is ["alpha" "beta"] ;; and change selected option to "beta" fce: first find-faces lyo [equal? face/texts ["alpha" "beta"]] fce/text: "beta" show fce return true ] ;; Display the layout unview/all view/new lyo: layout [ Button "Click to do it" [Do-it] text "one" text "two" box "three" Box "+" 25x25 olive box "+" 50x50 wheat box "+" 60x60 ivory c1: choice "alpha" "beta" c2: Choice "alpha" "beta" "gamma" ] do-events In the real world, of course, there'd be a lot more error trapping , Sunanda.