dcl controls addressing

Started by Tokot, January 18, 2011, 11:30:12 PM

Previous topic - Next topic

Tokot

Sry, can't share the code, but its not vital. I got kinda complicated odcl form with tens of textboxes and hundreds of comboboxes. For now i handle them one-by-one, loading lists to every one of comboboxes on form initialize, and reading every one of them separately on clicked ok button. Of course its not usual practice, but i didn't find a way to address control names by concatenating string and cycle counter or something. Can you give me a hand with this issue?

Fred Tomke

Hi, I'm not sure wether I understood you correctly, but try something like this:

Code (autolisp) Select


(setq lstLists (list (list "cbbCombo1" "Layer1" "Layer2" "Layer3" "Layer4" "Layer5" "Layer6")
                        (list "cbbCombo2" "Style2" "Style2" "Style3" "Style4")
                        ...))

(foreach lstList lstLists
  (dcl_combobox_setlist "MyProj" "MyForm" (car lstList) (cdr lstList))
  (dcl_combobox_setcursel "MyProj" "MyForm" (car lstList) 0)
); foreach






Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Tokot

Yep, sorry for my english, its not my native language, as you see.
I can't imagine a way to use this sample. Let me try to explain further, maybe you'll find one.
Code (autolisp) Select
(if (> comb21 10)
(progn
  (setq switch (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox27) " ")
iswitch (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox42) " ")
cont (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox57) " ")
icont (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox72) " ")
relay (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox87) " ")
irelay (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox102) " ")
cable (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox117) " ")
cablen (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox132) " ")
cablel (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox192) " ")
engine (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox147) " ")
power (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox162) " ")
current (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox177) " ")
offset1 (- offset1 10))
  (drawengine comb212 offset1 switch iswitch cont icont relay irelay cable cablen cablel engine power current)
)
      )

this is one of 15 similiar pieces of code differing from each other by 1 and calling the same function. I was asking for a way to make a single while cycle like
Code (autolisp) Select
;not a code, it sucks
(while (> comb21 i)
(progn
  (setq switch (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox(15*i+1)) " ")
iswitch (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox(15*i+2)) " ")
cont (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox(15*i+3)) " ")
icont (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox(15*i+4)) " ")
relay (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox(15*i+5)) " ")
irelay (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox(15*i+6)) " ")
cable (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox(15*i+7)) " ")
cablen (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox(15*i+8)) " ")
cablel (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox(15*i+9)) " ")
engine (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox(15*i+10)) " ")
power (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox(15*i+11)) " ")
current (strcat (dcl_ComboBox_GetEBText GenTP_Form2_ComboBox(15*i+12)) " ")
offset1 (- offset1 10)
                i (1+ i))
  (drawengine comb212 offset1 switch iswitch cont icont relay irelay cable cablen cablel engine power current)
)
      )

Fred Tomke

Hi, Tokot,

as far as I understand your code you should have a closer look where strcat started. Please have a look at the samples of this post.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

BazzaCAD

ya check out Fred example or try something like this:

Code (autolisp) Select

(setq myList nil)
(setq i 1)
(while (> comb21 i) 
  (setq myList (append myList (list (dcl_ComboBox_GetEBText "GenTP" "Form2" (strcat "ComboBox" (itoa i))))))
  (setq i (1+ i))
)
(drawengine comb212 offset1 (nth 1 myList) (nth 2 myList) (nth 3 myList) .....)


However, it doesn't look like you ComboBox are numbered in order so this wont work exactly as is.
Maybe your (15*i+1) will handle that.
But this should get you on the right track...
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

Tokot

Actually I did when was searching this forum before posting, but didn't see a way to use it. Anyway, looks like Bazza's sample is exactly what i've been looking for. I'll need two nested loops to cycle through the whole form, but i think thats it! Thank you both!