Create Multiple Defun C: in a Loop
Trying to do something I haven't done before and so far haven't been able to figure this out.
I am trying to create multipe Defun C: functions for OpenDCL drivers for multiple OpenDCL tabs which would allow me to really condense the code. See the sample below:
I have tried various Defun, Function, Defun-q, etc. and nothing creates that defun C: type function I am looking for, foreach item in the fastenertype list.
PS my old version of creating these Defun C: individually works fine (1997), just doing a rewrite and thought this would be cool if I can do it.
Thanks for any help!
Mike
(setq FastenerTypeList '( "SH" "LH" "BH" "FH" "ST" "SE" "TH"))
(foreach tab FastenerTypeList
(function
(lambda (tab)
(read (strcat "c:Fasteners/Form1/ListBox" tab "#OnSelChanged")) (ItemIndexOrCount Value /)
(vl-registry-write MasterKey (strcat tab "FastenerThread") (set (read (strcat "#" tab "FastenerThread")) ItemIndexOrCount))
(dcl-ListBox-Clear (read (strcat "Fasteners/Form1/ListBox" tab "2")))
(dcl-ListBox-AddList (read (strcat "Fasteners/Form1/ListBox" tab "2")) (FastenerLengthList (nth (read (strcat "#" tab "FastenerThread")) (car (FastenerThreadList tab (read (strcat "#" tab "FastenerUnits"))))) tab))
(dcl-ListBox-SetCurSel (read (strcat "Fasteners/Form1/ListBox" tab "2")) (vl-registry-write MasterKey (strcat tab "FastenerLength") (set (read (strcat "#" tab "FastenerLength")) 0)))
(prompt "\nHi Mike!")
)
)
)
Comments
-
So yeah, lots of tabs all with multiple List Boxes, Option Lists, etc
1 -
An easier to read:
(setq FastenerTypeList '( "SH" "LH" "BH" "FH" "ST" "SE" "TH"))
(foreach tab FastenerTypeList
(defun (read (strcat "C:" tab "ListBox")) (a b /)
(prompt "\nDo something")
)
)0 -
Solved - Found a Lee Mac post:
(eval (list 'defun (read (strcat "att" (itoa i))) '() '(princ "\nSe realizo") '(princ) ) )
0