DCL Mode_tile values

CSM_MAI
Advocate

DCL Mode_tile values

CSM_MAI
Advocate
Advocate

I have a series of editboxes in a dialog box. Each edit_box tile has a toggle tile associated with it. The User can toggle the Mode tile of each edit_box to disable (1) or enable (0) the edit_box. Is there a way that I can gather the value of just the edit_boxes with mode_tile 0? There are 25 edit_boxes with their corresponding key names. Typically not all of the edit_boxes will be enabled, so I would like to filter out the disabled tiles and store the values of the enabled edit boxes. Would a cond statement come in to play with this situation? Any information would be appreciated. Thanks. 

0 Likes
Reply
Accepted solutions (1)
2,185 Views
5 Replies
Replies (5)

scot-65
Advisor
Advisor
If I understand your concern...

In order for this to work, one would have to take a "snapshot" of
the dialog when the user selects the OK button. No need to setq
any values during the run time of the dialog.

When gathering values, you want to catch all the enabled edit boxes
and not catch the disabled. Logically this makes no sense as the order/
item (and number) of values will be unique every time.

Go ahead and gather every tile and save as a list. from there, you can
access via position in the list and get the value immediately afterwards.

For example:
Dialog has three toggles next to 3 edit boxes.

Between the new_dialog and start_dialog set_tile to each of the
toggles. Value will be "0" or "1" but has to be declared regardless.

(foreach x (list "Tog1" "Tog2" "Tog3")
(set_tile x "0")
)

(action_tile "accept" "(MyProgram_GET)(done_dialog 1)")

Where:
(defun MyProgram_GET ()
(setq USER_MyProgram (list
(get_tile "Tog1")
(get_tile "Edi1")
(get_tile "Tog2")
(get_tile "Edi2")
(get_tile "Tog3")
(get_tile "Edi3")
))
)

Now:
Inside your main program code block, access the second toggle
and if the value is "1", access the edit box value.
(if (= (nth 2 USER_MyProgram) "1")
(setq a (nth 3 USER_MyProgram))
)

When dialogs get rather busy, I will screen shot the dialog, print
out, and hand write the key names onto the printout. I have also
been known to hand write the gremlin position (as n0, n1, etc.).

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


0 Likes

scot-65
Advisor
Advisor
Accepted solution
Another method to consider...

We will group as an association the toggle and edit box and wrap
them all together as one list, but only if the toggle is on/checked.

(defun MyProgram_GET ()
(setq USER_MyPgm nil)
(if (= (get_tile "Tog1") "1")
(setq USER_MyPgm (cons (list "Tog1" (get_tile "Edi1")) USER_MyPgm))
)
(if (= (get_tile "Tog2") "1")
(setq USER_MyPgm (cons (list "Tog2" (get_tile "Edi2")) USER_MyPgm))
)
(if (= (get_tile "Tog3") "1")
(setq USER_MyPgm (cons (list "Tog3" (get_tile "Edi3")) USER_MyPgm))
)
);defun
;;;;;;;;;;;;;;;;;;;;;;;

The above can be shortened considerably by calling a sub-function :
(setq USER_MyPgm nil)
...
(if (= (get_tile "Tog4") "1") (Add_Assoc "4"))

Where:
(defun Add_Assoc ( a / )
(setq USER_MyPgm (cons (list (strcat "Tog" a) (get_tile (strcat "Edi" a))) USER_MyPgm))
);defun
Note the toggle and edit share the same number...
;;;;;;;;;;;;;;;;;;;;;;;;

Now, inside the main program code block:
(foreach x (reverse USER_MyPgm) ;reverse is optional
(cond
((= (car x) "Tog1") (setq a (cdr x)) )
((= (car x) "Tog2") (setq b (cdr x)) )
((= (car x) "Tog3") (setq c (cdr x)) )
(T)
);cond
);foreach

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


CSM_MAI
Advocate
Advocate

Thanks for the information as always. To expand a little more on what my end goal is for this information. I would like to (setq eb1 (get_tile "Edi1")) the user input from each of the edit boxes, and apply that value to a block  attribute later in the routine. I don't know any other way of storing the value individually so it can be associated with the corresponding block attribute value. That's why I was trying to gather the edit boxes with mode_tile of 0 because I don't want to edit all of the attributes, just the ones the User specifies. The dialog box is designed to look like a titleblock that is used on multiple drawings, and there are certain times where I need to edit the same attributes on every drawing. I have a way of doing that with a lisp already. I just place a ";" in front of the cons statement in a list so it will omit that attribute. some like this:

 

 

(setq data ; define variable
(list ; define list
(cons "ACAD_Attribute1" eb1)

 ;(cons "ACAD_Atribute2"  eb2)

); end list

);end setq

(setq ss ; define variable
(ssget "x" ; define selection
(list ; define list
(cons 0 "insert") ; construct
(cons -4 "<or") ; construct
(cons 2 "AUTOCAD BLOCK NAME") ; construct
(cons -4 "or>") ; construct
(cons 66 1) ; construct
) ; end list
) ; end ssget
) ; end setq

 

... and so on. 

 

 

 

but i'm trying to give the dialog box the power of user input. Click the toggle to enable the edit_box (change the mode_tile to 0), enter in the information, have that information stored into a setq to apply that value to a attribute when it's ran in a batch and only the enabled tiles will have their attributes changed. I'm still working through the rest at the moment. Thanks for the info. 

0 Likes

scot-65
Advisor
Advisor
From the context of this particular explanation,
it looks like you still are not distinguishing between
"Get User Input" and "Execute Main Program".
The two examples I provided earlier (should) clearly
explain this type of program structure.

The first example gathers ALL the tiles and one will have to
manipulate the whole list by testing every other item in list
(nth 0, nth 2, nth 4, etc.).

The second example creates an association of enabled
check boxes (only) and the corresponding edit box value.
Again, one will have to manipulate this list in the "Main
Program" part of your code. The CAR of the association
tells you which edit box is enabled and the CDR is the
actual value of the edit box.

Once you have an understanding of this structure, and
have successfully applied to this program, go back to
your earlier program and clean that one up.

Hint:
Display the value of USER_MyProgram when entering into
the "Main Program".
(if (= sd 1)
(progn
(princ "\n USER_MyProgram: ")(princ USER_MyProgram)(princ)
);progn
);if
where 'sd' is the return integer from done_dialog:: (setq sd (start_dialog))

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


0 Likes

CSM_MAI
Advocate
Advocate

This worked great once I studied it enough to get it incorporated into my routine. Thanks again for the help. 

0 Likes