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

view indirection

 [1/9] from: pat665::ifrance::com at: 20-Nov-2001 16:00


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/9] from: ryanc:iesco-dms at: 20-Nov-2001 9:48


Hello, I am assuming the following wont work because you need to loop through your checkboxes: C5/data: true I would consider somthing like this more elegant... win: view/new layout [check user-data 1 check user-data 2 check user-data 5] set-check: func [number value] [ repeat index length? win/pane [ if win/pane/:index/user-data = number [ win/pane/:index/data: value ] ] value ] But its said "Beauty is in the eye of the beholder." --Ryan Patrick Philipot wrote:
> 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.
<<quoted lines omitted: 13>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst www.iesco-dms.com 707-468-5400 The contradiction so puzzling to the ordinary way of thinking comes from the fact that we have to use language to communicate our inner experience which in its very nature transcends lingistics. -D.T. Suzuki

 [3/9] from: sterling:rebol at: 20-Nov-2001 10:13


Here's another option: Make a list of the checkboxes either directly: checks: reduce [c1 c2 c3 c4 ...] or iteratively: checks: copy [] repeat x 16 [append checks to-word join "c" x] reduce checks Now when you need to access one: set-check: func [n [integer!]] [ checks/:n/data: true show checks/:n ] Or to just improve on what you've got below: set in wrd: get to-word join "c" n 'data true show wrd The only thing you really need to build dynamically is the word to reference the checkbox. The rest of the REBOL code can stay as REBOL code. Sterling

 [4/9] from: ingo:2b1 at: 20-Nov-2001 19:43


Hi Patrick, Once upon a time Patrick Philipot spoketh thus:
> set-check: func [n [integer!] /local code ][ > code: copy ""
<<quoted lines omitted: 5>>
> myCheckBox: guru-function( "c" 5) > myCheckbox/data: true
how about that one?
>> c1: make object! [data: none] >> probe c1
make object! [ data: none ]
>> guru-function: func [ s [string!] n [integer!]][
[ get to-word join s n [ ]
>> mc: guru-function "c" 1 >> mc/data: "yup"
== "yup"
>> probe c1
make object! [ data: "yup" ] And how 'guru-function works: 'join the string (s) and the integer (n) make a word out of it and get what you find under that word (without the 'get it would only return the name of the word 'c1, namely a word c1. With 'get, it returns the object!, c1 points too). I hope that helps Ingo

 [5/9] from: rebol665:ifrance at: 21-Nov-2001 13:37


Thanks Ingo Another great answer from the rebol-list. I have just tested it. However trying to understand more, I crash my windows with a probe. Here is my code. The probe thing is in the guru-function. Thanks again Rebol [] guru-function: func [ s [string!] n [integer!] /local mc][ mc: get to-word join s n ; print probe mc <-- freeze my windows 2000 mc/data: true show mc ] view center-face layout [ banner "Test" c1: check c2: check c3: check c4: check button "Test" [guru-function "c" 3] button "that's all folks !" [unview] ] ----- Original Message ----- From: "Ingo Hohmann" <[ingo--2b1--de]> To: <[rebol-list--rebol--com]> Sent: Tuesday, November 20, 2001 7:43 PM Subject: [REBOL] Re: view indirection
> Hi Patrick, > Once upon a time Patrick Philipot spoketh thus:
<<quoted lines omitted: 6>>
> > > > 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 :

 [6/9] from: rebol665:ifrance at: 21-Nov-2001 13:45


Hi Sterling This is clean and elegant. Thanks to the rebol-list, I have now many ways to perform the required task with style ! Thanks again Patrick ----- Original Message ----- From: <[sterling--rebol--com]> To: <[rebol-list--rebol--com]> Sent: Tuesday, November 20, 2001 7:13 PM Subject: [REBOL] Re: view indirection
> Here's another option: > Make a list of the checkboxes either directly:
<<quoted lines omitted: 18>>
> > > > 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 :
<<quoted lines omitted: 7>>
> > > > 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 :

 [7/9] from: rebol665:ifrance at: 21-Nov-2001 13:53


Hi Ryan That's working. However I don't understand what is user-data. Could you explain it to me . Thanks Patrick ----- Original Message ----- From: "Ryan Cole" <[ryanc--iesco-dms--com]> To: <[rebol-list--rebol--com]> Sent: Tuesday, November 20, 2001 6:48 PM Subject: [REBOL] Re: view indirection
> Hello, > I am assuming the following wont work because you need to loop through
your checkboxes:
> C5/data: true > > I would consider somthing like this more elegant... > > win: view/new layout [check user-data 1 check user-data 2 check user-data
5]
> set-check: func [number value] [ > repeat index length? win/pane [ > if win/pane/:index/user-data = number [ win/pane/:index/data:
value ]
> ] > value
<<quoted lines omitted: 5>>
> > > > 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 :
<<quoted lines omitted: 7>>
> > > > 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 :

 [8/9] from: ingo:2b1 at: 21-Nov-2001 16:27


Hi Patrick,
>From WordNet (r) 1.7 [wn]: (shortened!)
probe n 1: an inquiry into unfamiliar or questionable activities; "there was a congressional probe into the scandal" v 1: question or examine thoroughly and closely Once upon a time pat665, french new rebolist spoketh thus:
> Thanks Ingo > Another great answer from the rebol-list. I have just tested it. However
<<quoted lines omitted: 8>>
> show mc > ]
Now, mc at the time is a view face, and these are BIG! Probing them is like trying to cut a whale in half, using a nail-file. That said, running this code needs about 15s until the first probe output is shown, and about the same time until it's run through. I'm on a PIII 900, Linux, how long did _you_ wait? ;-) Kind regards, Ingo

 [9/9] from: rebol665:ifrance at: 21-Nov-2001 21:25


Wow ! It tooks Rebol almost seven minutes to throw it up on my Pentium 200 Mhz. Thanks for this valuable lesson. Patrick

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