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

[view] object indirection

 [1/3] from: pat665::ifrance::com at: 18-Nov-2001 9:40


Hi, I am stuck in a should-not-be-so-difficult problem with view. I have a lot of checkboxes in a layout, named c1, c2, ... c16. At one time, given a number X, I would like to do something on the cX checkbox. For now, I have this sort of code : set-check: func [n [integer!] /local code ][ code: copy "" code: join join "set in c" n join " 'data true show c" n print ["generated code ; " code] do code ] IT IS WORKING ! (the print is only for debugging purpose). However I am not satisfied with this code. I'am looking for a more elegant way to do that. Something like : myCheckBox: guru-function( "c" 5) myCheckbox/data: true Patrick

 [2/3] from: brett:codeconscious at: 20-Nov-2001 16:56


Hi Patrick,
> I am stuck in a should-not-be-so-difficult problem with > view. I have a lot of checkboxes in a layout, named c1, c2, ... c16. > At one time, given a number X, I would like to do something > on the cX checkbox.
I'm wondering if you need to name the checkboxes. The example below shows a way of using some code to traverse the generated layout to set the checkboxes. Also, an interesting program to read is rebodex.r in the Rebol script library. Brett ; ; Lets generate a layout of 10 checkboxes. ; When the button is pressed a function runs ; through the layout searching for check boxes. ; It sets the every other check box it finds. ; ; I wrap all the code in a context just to tidy things up, ; you can run the code without using a context too. ; checkbox-example: context [ layout-script: copy [ title "A checkbox manipulation example" button "Set checks" [set-odd-boxes] across ] for i 1 15 1 [ append layout-script [check] ] lay: layout layout-script set-odd-boxes: does [ check-count: 0 for i 1 length? lay/pane 1 [ fce: lay/pane/:i if equal? fce/style 'check [ check-count: check-count + 1 if equal? 0 (and check-count 1) [ fce/data: true ] ] ] show lay ; Update the display ] go: does [ ; See the result view lay ] ]

 [3/3] from: rebol665:ifrance at: 21-Nov-2001 13:24


Many thanks Brett Your answer give me more than I wanted. I tested your code, and it works. However I don't know what a context is and have to remove it. Thanks again