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

getting dynamically to object word ...

 [1/5] from: petr:krenzelok:trz:cz at: 23-Jan-2003 14:33


Hi, let's suppose I have dynamically generated UI ... now I need to create some function to iterate thru UI elements and get their values. I found following way works, but I have two questions ... for i 1 7 1 [for j 0 4 1 [print do join 'fld [i j "/text"]]] I simply have fld10, fld12, fld13, fld14 .... fld74 ... 1) Is it safe to use 'do? 2) Is there any other way of how to dynamically compose name of already existing object and get to its words using 'in? Thanks a lot, -pekr-

 [2/5] from: joel:neely:fedex at: 23-Jan-2003 9:51


Hi, Petr, How about an alternative...? Petr Krenzelok wrote:
> Hi, > let's suppose I have dynamically generated UI ... now I need to
<<quoted lines omitted: 5>>
> 2) Is there any other way of how to dynamically compose name of already > existing object and get to its words using 'in?
Instead of dynamically composing the name of an existing object, why not add the object to a collection (e.g. block) at the point of its creation? Then you can simply iterate over the collection, calling whatever method(s) you need for any purpose. I've had *VERY* little time with /View (still waiting for the MacOS/X version...) but did use that technique in a couple of little demos I wrote early on. (Please forgive any stylistic ugliness or cut&paste goofs! ;-) A simplified version of the relevant portions would look something like this: btnArray: copy [] ... btnX: none uiSpec: [ style xbtn button 20x20 "x" goodColor [flipLeft face/user-data] ... btnX: xbtn user-data 1 do [append btnArray btnX] btnX: xbtn user-data 2 do [append btnArray btnX] ... btnX: xbtn user-data 10 do [append btnArray btnX] ... ] ui: layout uiSpec run: func [ ] [ repeat btnX 10 [ setBtnArrayText btnX ] view ui ] The net effect is that btnArray holds all of the button objects, so that other functions/methods (e.g. setBtnArrayText) can access the buttons at any time. IMHO this has advantages over dynamically composed source/names for the following reasons: 1) no scope worries 2) faster 3) fewer opportunities for breakage (fewer moving parts) -jn- -- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446

 [3/5] from: g:santilli:tiscalinet:it at: 23-Jan-2003 17:19


Hi Petr, On Thursday, January 23, 2003, 2:33:43 PM, you wrote: PK> let's suppose I have dynamically generated UI ... now I need to create PK> some function to iterate thru UI elements and get their values. I found PK> following way works, but I have two questions ... PK> for i 1 7 1 [for j 0 4 1 [print do join 'fld [i j "/text"]]] PK> I simply have fld10, fld12, fld13, fld14 .... fld74 ... You could iterate in the pane that contains the fields, instead of giving them a name (and using up a precious word :-). Or, if your fields are too much "scattered" in the pane, you could do something like: fields: [] layout [ ; ... tmp: field ; ... do [append fields tmp] ; ... ] so that you will have all of your fields in the FIELDS block. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [4/5] from: petr:krenzelok:trz:cz at: 23-Jan-2003 19:22


Joel Neely wrote:
>Hi, Petr, >How about an alternative...?
<<quoted lines omitted: 24>>
>goofs! ;-) A simplified version of the relevant portions would look >something like this:
Hmm, sounds like grid would be helpfull to me :-) Appending into pane is good thing probably, although I am not sure how should I position the stuff by simply appending it into pane ... and also - it would have to be some kind of subpanel better .... Right now I have following code: txt "Severka:" fld11: fld 30 fld12: fld 150 fld13: fld 30 fld14: fld 30 fld15: fld return txt "Prelač:" fld21: fld 30 fld22: fld 150 fld23: fld 30 fld24: fld 30 fld25: fld return txt "Kozubova:" fld31: fld 30 fld32: fld 150 fld33: fld 30 fld34: fld 30 fld35: fld return ......... sections: [ [ <!--Severka provoz--> <!--Prelac provoz--> <!--Kozubova provoz--> <!--Pod Louckou provoz--> <!--Na Gruni provoz--> <!--Mosty_centrum provoz--> <!--Bahenec provoz--> ] <!--podminky--> <!--teplota--> <!--vyska--> <!--aktualizace--> ] ......... ski: read %ski.html preview-ski-data: does [ for i 1 7 1 [ tmp: head ski for j 1 5 1 [ change/part tmp: find/tail tmp either j == 1 [sections/1/:i][sections/:j] do join 'fld [i j "/text"] find tmp <!--end--> ] ] write %xxx.htm ski browse %xxx.htm ] .... and kind of insane parse replacement - find named section, replace items in html code ... As I now think about it - it can be all done several ways .... Thanks anyway ... -pekr-

 [5/5] from: petr::krenzelok::trz::cz at: 23-Jan-2003 19:20


Joel Neely wrote:
>Hi, Petr, >How about an alternative...?
<<quoted lines omitted: 24>>
>goofs! ;-) A simplified version of the relevant portions would look >something like this:
Hmm, sounds like grid would be helpfull to me :-) Appending into pane is good thing probably, although I am not sure how should I position the stuff by simply appending it into pane ... and also - it would have to be some kind of subpanel better .... Right now I have following code: txt "Severka:" fld11: fld 30 fld12: fld 150 fld13: fld 30 fld14: fld 30 fld15: fld return txt "Pr(elac(:" fld21: fld 30 fld22: fld 150 fld23: fld 30 fld24: fld 30 fld25: fld return txt "Kozubová:" fld31: fld 30 fld32: fld 150 fld33: fld 30 fld34: fld 30 fld35: fld return ......... sections: [ [ <!--Severka provoz--> <!--Prelac provoz--> <!--Kozubova provoz--> <!--Pod Louckou provoz--> <!--Na Gruni provoz--> <!--Mosty_centrum provoz--> <!--Bahenec provoz--> ] <!--podminky--> <!--teplota--> <!--vyska--> <!--aktualizace--> ] ......... ski: read %ski.html preview-ski-data: does [ for i 1 7 1 [ tmp: head ski for j 1 5 1 [ change/part tmp: find/tail tmp either j == 1 [sections/1/:i][sections/:j] do join 'fld [i j "/text"] find tmp <!--end--> ] ] write %xxx.htm ski browse %xxx.htm ] .... and kind of insane parse replacement - find named section, replace items in html code ... As I now think about it - it can be all done several ways .... Thanks anyway ... -pekr-

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