Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

get_tile with list_box returns nil even though items are selected.

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
doni49
2058 Views, 5 Replies

get_tile with list_box returns nil even though items are selected.

I'm working on a routine that will use DCL to create dialog boxes.

 

It displays the dialog correctly.  But when I click ok, get_tile returns nil for the first list list box (I've only set up the first one).

 

Here's a screenshot showing the dialog running in acad (C3D 2012 to be exact).  As you can see the list_box does get populated.

DCLDialog.png

 

Here's a code snippet from my dcl file (the portion that creates the list box).

    : list_box {
        multiple_select = true;
        key = "lbxFilterList";
        height = 15;
        alignment = left;
        width = 35;
        fixed_height = true;
        fixed_width = true;
      }

And here is a code snippet from the lsp file.

  ;;Just below the line that loads the dcl in memory

  (start_list "lbxFilterList")   ;start the list box

  (mapcar 'add_list filterlist)   ;fill the list box

  (end_list)   ;end list

 

  (action_tile "cancel" "(done_dialog 0)")   ;do this if Cancel button selected

  (action_tile "accept" "(done_dialog 1)")   ;do this if OK button selected

  (setq dialogstatus (start_dialog))   ;start the dialogue

  (setq readlist(get_tile "lbxFilterList"))                       <<<<-----after running the routine and choosing 3-4 items in the list, readlist is NIL.  The variable is NOT local.

 

 I'm going to post my files in case someone wants to see them.



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

5 REPLIES 5
Message 2 of 6
_Tharwat
in reply to: doni49

The get_tile function must be placed before the done_dialog funtion that related to accept tile .

Message 3 of 6
scot-65
in reply to: doni49

Try nesting the get_tile inside the "accept" line before issuing the done_dialog.

This is [usually] achieved by calling a subroutine to make code easier to read.

 

(defun My_GET ()

 (setq readlist (get_tile "lbxFilterList"))

);end My_GET

 

...

 

(action_tile "accept" "(My_GET)(done_dialog 1)")

 

 -or, without the subroutine-

(action_tile "accept" "(setq readlist (get_tile \"lbxFilterList\"))(done_dialog 1)")

 

I have not used the multiple_select attribute to know what is returned by the get_tile, but I suspect it

may not be the answer you are looking for... you are on your own here.


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


Message 4 of 6
phanaem
in reply to: doni49


@doni49 wrote:

And here is a code snippet from the lsp file.

  ;;Just below the line that loads the dcl in memory

  (start_list "lbxFilterList")   ;start the list box

  (mapcar 'add_list filterlist)   ;fill the list box

  (end_list)   ;end list

 

  (action_tile "cancel" "(done_dialog 0)")   ;do this if Cancel button selected

  (action_tile "accept" "(done_dialog 1)")   ;do this if OK button selected

  (setq dialogstatus (start_dialog))   ;start the dialogue

  (setq readlist(get_tile "lbxFilterList"))                       <<<<-----after running the routine and choosing 3-4 items in the list, readlist is NIL.  The variable is NOT local.


All dcl actions must be defined before start_dialog.

Try this

......

  (start_list "lbxFilterList")           ;start the list box
  (mapcar 'add_list filterlist)        ;fill the list box
  (end_list)                                  ;end list

  (action_tile "cancel" "(done_dialog 0)")  ;do this if Cancel button selected
  (action_tile "accept" "(done_dialog 1)")  ;do this if OK button selected
  (action_tile "lbxFilterList" "(setq readlist (get_tile \"lbxFilterList\"))")
 
  (setq dialogstatus (start_dialog))

.......

 

Also, note that the actions you defined for "accept" and "cancel" are the same as the defaults ones; you do not need to (re)define them (but it is not wrong either)

Message 5 of 6
doni49
in reply to: doni49

Thanks guys.  I was thinking that the tile info was still available until the dialog was actually unloaded.  It's been way too long since I've worked with DCL files.



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 6 of 6
doni49
in reply to: doni49

I decided to use a function to validate the data and save the data as variables for processing.  If the function finds an error, it'll return nil.  The ok button's action tile does the done_dialog ONLY if the function returned a non-nil value.

 

(defun saveVars()

  ;; validate the dialog  to make sure everything is ok.   

  ;; If it is ok, then return T.  If not ok, return nil.

  ;; The variable "return" will take on the value of ValidData.

  ;; Set ValidData to T here.  If something is wrong reset it to nil.

  (setq validData T)

 

 

 (setq return validData)

)

...........

 

(action_tile "accept" "(if (saveVars)(done_dialog 1))")



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost