DCL dialog box not show

DCL dialog box not show

tim11_manhhieu
Advocate Advocate
158 Views
6 Replies
Message 1 of 7

DCL dialog box not show

tim11_manhhieu
Advocate
Advocate

I am learning about lisp and tried a small program that shows a Hello World message box but failed.

I ran the APPLOAD command then found the hello.lsp file and Load, then typed the hello command.

I checked FILEDIA and CMMDIA both have the value of 1.

 

hello.dcl

hello_dialog : dialog {
    label = "Message";
    : text {
        label = "Hello World";
    }
    : button {
        key = "ok_btn";
        label = "OK";
        is_default = true;
        is_cancel = true;
    }
}

 

hello.lsp

(defun c:HELLO ( / dcl_id)
  (setq dcl_id (load_dialog "hello.dcl"))
  (new_dialog "hello_dialog" dcl_id)
  (action_tile "ok_btn" "(done_dialog 1)")
  (start_dialog)
  (unload_dialog dcl_id)
  (princ)
)

 

0 Likes
Accepted solutions (1)
159 Views
6 Replies
Replies (6)
Message 2 of 7

_gile
Consultant
Consultant
Accepted solution

Hi,

The "Hello.dcl" file have to be in an AutoCAD search path directory.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 7

tim11_manhhieu
Advocate
Advocate

Many thanks.

After moving "Hello.dcl" to AutoCAD search path directory, it run fine.

0 Likes
Message 4 of 7

Moshe-A
Mentor
Mentor

@tim11_manhhieu  hi,

 

Dialog Control Language (DCL) has build-in buttons for OK and Cancel (see attached dcl code)

and react to a default callback function. picking OK will close the dialog as calling (done_dialog 1) and picking Cancel will close the dialog as calling (done_dialog 0).

you do not have to add nothing to your code this is default behavior unless you want to do other work on picking OK like updating some data only then you need to define these functionality (callback functions)

 

Moshe

 

 

 

hello_dialog : dialog {
    label = "Message";
    : text {
        label = "Hello World";
    }
    : button {
      key = "hello";
      label = "hello";
    }
    
 ok_cancel;
}

 

 

 

Message 5 of 7

tim11_manhhieu
Advocate
Advocate

thank for additional information.

0 Likes
Message 6 of 7

Sea-Haven
Mentor
Mentor

If you ask here, people can provide you with some more simple DCl examples. Think of a task you want as a dcl.

 

Step 2 you can put dcl code into a lisp so only have one file.

 

SeaHaven_0-1757042160980.png

 

YesNo : dialog 	{
	label ="Yes or No" ;
	: row	{
	: boxed_radio_row	{
	: radio_button	{
key = "Rb1";
label = "No";
	}
spacer_1 ;
	: radio_button	{
key = "Rb2";
label = "Yes";
	}
spacer_1 ;
	}
	}
spacer_1 ;
	ok_cancel;
	}

 

(defun YesNo ( / dcl_id)
  (setq dcl_id (load_dialog "D:\\acadtemp\\yesno.dcl"))
  (if (not (new_dialog "YesNo" dcl_id) )
   (exit)
  )
  (action_tile "accept" "(setq ans (get_tile \"Rb1\"))(done_dialog)")
  (action_tile "cancel" "(done_dialog)(exit)")
  (start_dialog)
  (unload_dialog dcl_id)
  (princ)
)
(yesno)

Note for radio buttons it returns a 0 or 1 indicating a button has been selected. Similar for toggles. 

Message 7 of 7

tim11_manhhieu
Advocate
Advocate

thank you for reply.

0 Likes