Programming dialog boxes in AutoLISP: DCL
Print This Post
![]() |
Author | Muharrem Koçyiğit |
| Profession | Mechanical Technician | |
| AutoCAD & Prosteel Specialist | ||
| Location | Germany | |
All VisualLISP versions
Hello Daily AutoCAD readers,
After a long period of time, I am back again with this article about AutoLISP. Today’s subject is to give an example function for dialog box programming by using DCL dialog control language. DCL:GETINT function prompts from the user to enter an integer (Fig. 1). Program is prepared in a portable manner. It can be used as a library for those who are interested in LISP programming language.

Fig.1 - DCL - Dialog Box
In order to run DCL:GETINT function, we need 6 arguments. You have to pass all of the arguments while running the function, which means that you must assign the unneeded arguments as Nil.
- “Title“: Name of the window; it is the name that is seen in the title bar when the dialog box is opened. Data type is ‘STR‘ (String).
- “Prompt“: The message that is prompted to the user. Data type is ‘STR‘ (String)
- “Flag” Separately from the other arguments, some additional control purpose is assigned to this argument.
- Bit 1 = Does not accept empty value.
- Bit 2 = Zero values are not accepted
- Bit 4 = Values smaller than zero (negative) are not accepted.
- Data type is ‘INT (Integer ) or Nil if not needed.
- “Default“: A default starting value is assigned. For example, final entered value is reminded to the user. Data type is ‘INT‘ (Integer ) or Nil if not needed.
- “Max“: It determines the maximum number of integers that the user can enter Data type is ‘INT‘ (Integer ) or Nil if not needed.
- “Min“: It determines the minimum number of integers that the user can enter Data type is ‘INT‘ (Integer ) or Nil if not needed.
(DCL:GETINT “ENGINE” “1. gear” nil nil nil nil)
(It is prompted from the user to enter any integer without any restrictions)(DCL:GETINT “ENGINE” “1. gear” nil 4 20 5)
(Default value is 4. It is prompted from the user to enter any integer between 5 and 20.)(DCL:GETINT “ENGINE” “2. gear” 6 nil nil nil)
(All of the values can be entered except zero and smaller than zero)
We will also need global variables in these functions, just like we need them in other programs. As it can be understood from its name; global variables are the variables that can be directly accessed from anywhere inside the program. In order to define a variable in global level, we are using GLV: prefix. If you examine the AutoLISP file carefully, you will notice that (DCL:INIT:GLOBAL:VALUE)has been added at the end of the file (Fig. 2). By this way, as soon as the AutoLISP file is loaded, this file will automatically be loaded and the variables that is included in it are initialized.

Fig.2 – Sub function “UTL:INIT:GLOBAL:VALUE“
DCL:GETINT-TEST function (Fig.3) tests the program.

Fig.3 - Main function “C:DCL-GETINT-TEST” or “C:X“
DCL:GETINT function (Fig.4) forms up the basis of the program. Name of the dialog control is located inside the dcl_name variable as “KML_EDITBOX” (1). Dialogs forms up mosaic shapes that are called tiles. Similar to using bricks to construct a building, you need these labels to construct a dialog box. In order to access these labels, you must give a name (key). You can separate these variables from the other variables by assigning key: prefix to these variables (2).



Fig.4 - Sub function “DCL:GETINT“
DCL:USER:INPUT:INTEGER function (Fig.5) controls if the entered variables are valid according to required criterions. These criterions depend on how the program is called, thus the arguments.

Fig.5 - Sub function “DCL:USER:INPUT:INTEGER“
DCL:USER:CHECK:IS:NUMERIC function (Fig.6) controls if the values that were entered are only made up of numbers. If the entry is not valid, then the entered value is deleted and prompted to be entered again.

Fig.6 - Sub function “DCL:USER:CHECK:IS:NUMERIC“
DCL:USER:CHECK:FLAG function (Fig.7) controls if the entered value is empty, zero or larger than zero.

Fig.7 - Sub function “DCL:USER:CHECK:FLAG“
DCL:USER:CHECK:MIN-VALUE function (Fig.8) controls if the entered value exceeds the minimum limit. Other vise, the unaccepted value is removed from the value input box and the user is prompted to enter from the beginning.

Fig.8 - Sub function “DCL:USER:CHECK:MIN-VALUE“
DCL:USER:CHECK:MAX:VALUE function (Fig.9) controls if the entered value exceeds the maximum limit. Otherwise, the unaccepted value is removed from the value input box and the user is prompted to enter from the beginning.

Fig.9 - Sub function “DCL:USER:CHECK:MAX-VALUE“
DCL:SET:DIALOG function (Fig.10) determines the user interface file that has .dcl extension to AutoCAD system. If the file is not found, it gives an error and stops the program by vl-exit-with-value command. In general, AutoCAD searches among “Support file search path” part. By using tools->options in AutoCAD, you can see the folders that were defined.

Fig.10 - Sub function “UTL:SET:DIALOG“
DCL:LOAD:DIALOG function (Fig.11) loads the user interface file that has .dcl extension to AutoCAD system. If the file is not found, it gives an error and stops the program by vl-exit-with-value command. In general, AutoCAD searches among “Support file search path” part. By using tools->options in AutoCAD, you can see the folders that were defined.

Fig.11 - Sub function “UTL:LOAD:DIALOG“
UTL:IS:NUMERIC function (Fig.12) controls if data entered by the user is composed of numbers only. It returns the value of T if entered as numbers or Nil other vise. These values are Boolean value types. T means TRUE, which is 1. And Nil (Not in List) is generally used in AutoLISP language and it means FALSE or 0.

Fig.12 - Sub function “UTL:IS:NUMERIC“

Fig.13 - Dialog Control Language “DCL-GETINT.dcl“
DCL commands that are used in the program:
- new_dialog
- load_dialog, unload_dialog
- start_dialog
- set_tile
I am looking forward to hear from your questions about the subject. You can download file from here.
Have a nice day.
Related Articles: AutoLISP page, VisualLISP page
Technorati Tags: AutoCAD, AutoLISP, DCL
Read in other languages: TR
Similar Posts
Rate this article:


July 16th, 2007 22:30
In case your readers are not aware, there is a free open source replacement for DCL called OpenDCL (http://www.opendcl.com) that offers much more advanced capabilities and is easier to use than the built in DCL implementation. I hope the contributors to this excellent blog will consider writing about OpenDCL in a future article.
July 17th, 2007 14:20
Hi Owen,
It’s a great pleasure to see your comment in Daily AutoCAD again. I think the best article about OpenDCL can be written by you
. We’re waiting your article about OpenDCL.
July 17th, 2007 22:04
Orhan, I will see what I can do. First I need to get OpenDCL 4.0 released!
August 5th, 2007 22:24
hi,
i dont know anything about dcl.i m first trying to modify one dcl file i got from internet.i can move buttons as i wish.thats what i learnt.
it displays blocks from .slb files in tiles.i just want to add name of the block(file) below it.how to do it?
any help is appreciated
thanx
November 12th, 2007 23:41
I have created 2d piping reducers and other 2d piping symbols and would like to have them into a lips file so i can insert them. I purchase a DLC and lisp program but i’m still learning autolisp. I wish there was a lisp book that took you step by step or a book for dummys.
I have been customizing AutoCAD menu for year with menu commands and scripts file but never lisp files.
how much work is it to create DLC and Lisp file to do what i’m looking for!
or is there a lisp file ouyt there i can modify. I want to learn but trying to find the time and a good book that will be every basic to i can learn.
November 21st, 2007 23:45
Hi Curt,
“AutoCAD Developer’s Guide to Visual LISP” is a good book (Author Nikolai Poleschuk)
http://www.amazon.de/AutoCAD-Developers-Guide-Visual-LISP/dp/1584500913/
Thank you for your visit
November 28th, 2007 10:06
[…] started to my first article about DCL, I am just thinking how I can teach you easy and fast user interface programming technique. This is […]