Starting With DCL Lisp
Starting With DCL Lisp
Contact
Site Map
AutoLISP
Beginners' Tutorials
Intermediate Tutorials
Advanced Tutorials
Application Tutorials
Tips'n'Tricks
Visual LISP
Beginners' Tutorials
Intermediate Tutorials
DCL
Beginners' Tutorials
Intermediate Tutorials
VBA
VBA Tutorials
VBA Applications
Tips'nTricks
AutoCAD
Customization Tutorials
Tips'n'Tricks
Reference
AutoLISP Functions
Visual LISP Sample Files
DXF Group Codes
The AutoCAD APIs
DCL Tile Attributes
AutoLISP DCL Functions
System Variables
AutoCAD Object Model
Sin and Cos Functions
VLAX Enumeration
Download
Forum
See also:
Getting Started with DCL - Part 2
Dialog Control Language, or DCL, always seems to frighten off a lot of Lispers. I admit, it did me too until I
was forced into a situation were I had to learn it and quickly. (make it work, or you're out boy!)
Well, I would hate for any of you to be in the same situation, so for the next few issues, I'll be taking you step by
step, hand in hand, through the minefield of the DCL language. I will share your pain and misery, and will wipe
away your tears, I will… ("Hey Kenny, get on with it!"). Oops, sorry!
Copy and paste this into Notepad and save it as test_dcl1.dcl. Oh, before I forget, please ensure that you save
this file, and it's namesake AutoLisp file, into a directory that is within your AutoCAD search path.
//DCL CODING STARTS HERE
test_dcl1
: dialog
{
label = "Test Dialog No 1";
: text
{
label = "This is a Test Message";
alignment = centered;
}
: button
{
key = "accept";
label = "Close";
is_default = true;
fixed_width = true;
alignment = centered;
}
}
//DCL CODING ENDS HERE
We'll have a closer look at what this all means a bit later. First, let's load some AutoLisp coding and try out our
new dialog box. Copy and paste this into Notepad and save it as test_dcl1.lsp.
;AUTOLISP CODING STARTS HERE
(prompt "\nType TEST_DCL1 to run...")
(defun C:TEST_DCL1 ()
(action_tile "accept"
"(done_dialog)"
);action_tile
(start_dialog)
(unload_dialog dcl_id)
(princ)
);defun
(princ)
;AUTOLISP CODING ENDS HERE
A very simple dialog box containing a message should appear on your screen. It did? Good, well done!!
(thunderous applause from the peanut gallery.)
Right, let's dissect the DCL coding. (theme music from an old Dracula movie starts in the background.)
test_dcl1
The name of the dialog.
: dialog
The start of the dialog definition.
{
The opening bracket for the dialog definition.
: text
The start of a text tile definition.
{
The opening bracket for the text tile definition.
alignment = centered;
The alignment attribute of the text tile.
}
The closing bracket of the text tile.
: button
The start of a button tile definition.
{
The opening bracket for the button tile definition.
key = "accept";
The key, or name of the button tile.
You will use this name to reference this button in your AutoLisp coding.
label = "Close";
The label attribute. What appears on it.
is_default = true;
The default attribute. If this is true, this button will automatically be selected if the <Enter> key is pressed.
fixed_width = true;
Forces the button to be just large enough for the label attribute.
alignment = centered;
The alignment attribute.
}
The closing bracket for the button tile.
}
The closing bracket for the dialog definition.
OK, that was easy hey? By the way, did you notice that each of the attribute lines finished with a semicolon(;)?
Another important thing that you must remember when dealing with attributes is that their values are case
sensitive. (e.g. "True" does not equal "true".)
Now let's have a wee look at the AutoLisp coding that puts this whole thing together. Again, we'll take it line by
line :
(prompt "\nType TEST_DCL1 to run...") Inform the user how to start the program. Just good manners.
(exit)
Exit the program if the dialog definition is not found.
);if
End if
(action_tile "accept"
If the user selects the tile who's name is "accept", then do the following :
"(done_dialog)"
Close the dialog
);action_tile End of action_tile
(start_dialog)
Start the dialog
(unload_dialog dcl_id)
Unload the dialog from memory
(princ)
finish clean
);defun
End of function
(princ)
Load clean
Many people get confused in regards to the order of AutoLisp statements when dealing with DCL files. I don't
blame 'em really. I mean look at the coding above!
Haha. But did you notice that the action_tile statement was quoted? e.g. "(done_dialog)".
Yep, that's it. But remember, no values will be returned until (done_dialog) is called, which is also quoted. So,
the sequence is like this :
When a tile that contains the (done_dialog) function is selected, we unload the dialog and return all tile values.
In Part 2, we'll have a look at some predefined tiles, how to enter and retrieve values from a dialog, and how to
validate these values.
Free Trial
Structural engineering software at
it's best. Try STAAD.Pro now for
free!
AfraLISP Archive
‘Hey, what's happened to AfraLISP?’ If you've visited our site before, you'll notice some big changes. We're
currently revamping the entire site to bring you updated tutorials and a better user experience. However, if
there's something you can't find, the AfraLISP Archive contains a full copy of the original site as originally
created by Kenny Ramage.
Online Books
The ABC's of AutoLISP
The Visual LISP Developer's Bible
AutoLISP Forums
CADTutor
Autodesk Discussion Groups
Autodesk User Group International (AUGI)
The Swamp
Back to top
Home
Cared for by David Watson © 2018