DCL Value not passing to the Lisp Variable

DCL Value not passing to the Lisp Variable

ChaitanyaHeb
Advocate Advocate
1,564 Views
8 Replies
Message 1 of 9

DCL Value not passing to the Lisp Variable

ChaitanyaHeb
Advocate
Advocate

Hello Everyone, 

I hope skilled people from this group can help some less skilled one like me here.. 

 

I have started to learn about DCL through online videos. I have created a test DCL and LISP.  Lisp will get longer as I succeed in this.

 

So coming to the conversation, my LISP is getting loaded, dialog box pops up and I provide value in the edit box. After hitting OK button the value stored in the DCL is not passing to the variable I set in LISP. To dig deeper I added a princ line and it says No Value. So can anyone look into this and let me know where I am going wrong or what wrong line I have written because of which value from DCL is not passing to the Lisp variable.

 

THANKS IN ADVANCE 

 

======LISP Code=====

 

(defun c:test ()

(setq dcl_id (load_dialog "test_inputs.dcl")) 

(if (not (new_dialog "test_inputs" dcl_id))
(progn
(princ "\nFailed to load dialog.")
(exit)
)

 

(action_tile "ok_button" "(done_dialog 1)")

(action_tile "cancel_button" "(done_dialog 0)")

(setq dialog_result (start_dialog))

 

(setq NAC_Address (get_tile "Starting_Strobe_Address")) 

(princ (strcat "\nRetrieved Address: '" (if NAC_Address NAC_Address "No value") "'"))

 

(unload_dialog dcl_id)

(princ)

 

)

 

==========DCL Code===========

 

test_inputs : dialog {

  label = "Enter Notification Address";

 

  : edit_box {

    key = "Starting_Strobe_Address";

    label = "Strobe Address:";

  }

  ok_cancel;

}

0 Likes
1,565 Views
8 Replies
Replies (8)
Message 2 of 9

paullimapa
Mentor
Mentor

You are almost there.

I see that you place this in your dcl:

ok_cancel;

You need to look up what is the key the ok & the cancel buttons each are.

These are stored under base.dcl

To locate this at AutoCAD command prompt enter:

(findfile"base.dcl")

AutoCAD will return the location of the file as under your windows roaming profile for example:

"C:\Users\your-windows-profile\AppData\Roaming\Autodesk\AutoCAD 2025\R25.0\enu\Support\base.dcl"

Open this file in your lisp editor and search for ok_cancel which shows the following:

ok_cancel : column {
    : row {
        fixed_width = true;
        alignment = centered;
        ok_button;
        : spacer { width = 2; }
        cancel_button;
    }
}

Now search for ok_button : & then cancel_button : :

ok_button : retirement_button {
        label           = "  OK  ";
        key             = "accept";
        is_default      = true;
}

cancel_button : retirement_button {
        label           = "Cancel";
        key             = "cancel";
        is_cancel       = true;
}

This shows the ok_button's key = "accept"

The cancel_button's key = "cancel"

So your action callback statements must reference these two keys and not "ok_button" or "cancel_button":

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

(action_tile "cancel" "(done_dialog 0)")

But closing the dialog will not get you the current value entered into your edit_box key "Starting_Strobe_Address"

So you should move your get_tile statement inside the callback statement before your done_dialog like this:

(action_tile "accept" "(setq NAC_Address (get_tile \"Starting_Strobe_Address\"))(done_dialog 1)")

But to check if the OK button is selected vs the Cancel button, you should test using the following condition statement after start_dialog like this:

(setq dialog_result (start_dialog))
(cond 
 ((= dialog_result 1)
  (alert (strcat "\nRetrieved Address: " NAC_Address))
 )
 ((= dialog_result 0)
  (alert "Canceled button selected")
 )
)

Now I would place a default entry into your NAC_Address by using the set_tile function before the action_tile functions so a default value can be retrieved when OK is selected like this:

(set_tile "Starting_Strobe_Address" "This is address")

It may help if you read up on my recent article I wrote called "Dialog Fun Facts: Get Ready, Set, Action!!!"

AUGIWORLD by AUGI, Inc. - Issuu

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 9

Sea-Haven
Mentor
Mentor

Because your wanting to learn you can speed up the process using this, it allows for multiple edit boxes, the limit is around 20. A screen limit. If you change this line it will write a dcl for you so you can learn from it. It will show you the multi edit box code. You can use the program to write dcl code so make complex dcl fast, combination of radio buttons and edit boxes.

 

Another is that RLX has written a dcl to lisp so all the code including dcl is in the one lisp file.

 

NOTE the answer returned in the code is a list of string answers so you may need to use (nth x ans) with (atoi or (atof for numbers.

 

 

(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))

(setq fo (open (setq fname "d:\\acadtemp\\test.dcl") "w")) ; change to your directory name.

 

Ps have Multi Radio buttons & Multi Toggles also.

 

Ps Ps have a make DCl from Autocad objects very primitive radio buttons and edit box version.

0 Likes
Message 4 of 9

ec-cad
Collaborator
Collaborator

Paulli,

Hope you don't mind, but I put all your suggestions to use in attached.

Should work fine.

🙂

 

ECCAD

0 Likes
Message 5 of 9

paullimapa
Mentor
Mentor

I don't mind at all but I had already attached the updated lisp file in my original reply.

You actually don't need to make any changes to the dcl. The reason I went through the process of searching through the base.dcl was to show to @ChaitanyaHeb the process of getting to the root of what the keys are when the predefined ok_cancel; cluster is used.

So you really do not need to replace that with these in the dcl:

  : ok_button : retirement_button {
        label           = "  OK  ";
        key             = "accept";
        is_default      = true;
  }

  : cancel_button : retirement_button {
        label           = "Cancel";
        key             = "cancel";
        is_cancel       = true;
  }

But simply leaving as the OP had it like this works:

  ok_cancel;

As for the revised lisp you attached, I would remove the following action callback statements since these keys referenced do not exist:

(action_tile "ok_button" "(done_dialog 1)")

(action_tile "cancel_button" "(done_dialog 0)")

Now I also did add this action callback statement for the cancel key:

(action_tile "cancel" "(done_dialog 0)")

But you are correct that there's no need to include it because by default when the cancel key is clicked it'll return a 0.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 6 of 9

Sea-Haven
Mentor
Mentor

I have a paper copy of R12 Customization manual so very helpful when looking up stuff for dcl. So default buttons.

 

ok_cancel

ok_cancel_help

ok_cancel_help_info

ok_cancel_help_errtile

 

Then you can make your own exit button page 166 or online help.

 

An important thing to remember is that a lot of the dcl coding needs to be lower case. It seems that is how they wrote its use all those years ago. 

0 Likes
Message 7 of 9

paullimapa
Mentor
Mentor

wow those paper copies are invaluable now-a-days...


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 9

Sea-Haven
Mentor
Mentor

Yes have a full set. Even ADS programming.

0 Likes
Message 9 of 9

paullimapa
Mentor
Mentor

I bet you still have the original fold out of the autocad template for a 12x12 tablet


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes