DOSLib - DOS Library Programmers Reference
I don't know if you are aware, but there is an application included
with AutoCAD that makes dealing with the operating system a breeze when
working with AutoLisp. This is DOSLib.Arx, designed and distributed by Robert
Mcneel and Associates.
DOSLib, or DOS Library, is a library of LISP-callable functions that
provide Windows operating system and DOS command-line functionality to
various CAD applications, including AutoCAD and IntelliCAD.
DOSLib extends their LISP programming languages by providing the following
functionality:
- Drive handling functions to change between drives and check disk
space.
- Path handling functions to manipulate path specifications.
- Directory handling functions to create, rename, remove, select and
change directories.
- File handling functions to copy, delete, move, rename, and select
files. Functions for getting directory listings, searching and finding
multiple instances of files, and changing attributes are provided.
- Print handling function to get and set default printers, and spool
files.
- Initialization file handling functions to manipulate Windows-style
initialization (INI) files, and Windows Registry access functions.
- Process handling functions to run internal DOS commands or other
programs.
- Miscellaneous functions, like changing the system date and time, and
displaying Windows message boxes.
In this Tutorial we will have a quick look at how to use some of the
various functions available within DOSLib.
Creating a "Splash Screen"
This is a great way to promote yourself or your company.
DOSLib Function : dos_splash
Syntax : (dos_splash filename duration)
Arguments :
- filename - A 256-colour Windows BMP File.
- duration - Duration Time in Seconds.
Returns : nil if successful or on error.
Example :
(dos_splash "afralisp.bmp" 5)
Getting a Directory Path
This will display a Windows Browse for Folder Dialogue box and will
return
a fully qualified path to the selected directory.
DOSLib Function : dos_getdir
Syntax : (dos_getdir title [path])
Arguments :
- title - A dialogue box title.
Options :
- path - An existing directory.
Returns : A qualified path to the current directory selected by the user.
nil on cancel or error.
Example :
(setq udir (dos_getdir "Select a Directory" "c:\\"))
Multiple File Selection
Displays a Windows common file open dialogue box that will allow you to
select
multiple files.
DOSLib Function : dos_getfilem
Syntax : (dos_getfilem title path filter)
Arguments :
- title - A dialogue box title.
- path - An existing directory.
- filter - A filename filter string. The filter string consists
of two components: a description (for example, "Text File"),
and a filter pattern (for example, "*.txt"). Multiple filter
patterns can be specified for a single item by separating the
filter-pattern strings with a semi-colon (for example,
"*.TXT;*.DOC;*.BAK"). The components must be separated by a
pipe character ("|"). The filename filter string can consist
of one or more filter strings, each separated by a pipe character.
Returns : A list of filenames. The first element of the list is a
qualified path to
the selected directory. nil on cancel or error
Example :
(setq ufiles (dos_getfilem "Select Drawings" "c:\\drawings\\"
"Drawing Files (*.DWG)|*.DWG"))
AutoCAD Message Box
This displays a Windows Message Box. Much more flexible than the
standard
AutLisp "Alert" function. Very similar to the VBA Message Box
function.
DOSLib Function : dos_msgbox
Syntax : (dos_getfilem text title button icon)
Arguments :
- text - The message to be displayed.
- title - The message box title.
- button - The push button format.
The allowable values are :
- 0 - Abort, Retry and Ignore.
- 1 - OK.
- 2 - OK and Cancel.
- 3 - Retry and Cancel.
- 4 - Yes and No.
- 5 - Yes, No and Cancel.
- icon - The icon.
The allowable values are :
- 0 - Asterisk.
- 1 - Exclamation.
- 2 - Hand.
- 3 - Information.
- 4 - Question.
- 5 - Stop.
Returns : The return values of dos_msgbox are as follows :
- 0 - Abort
- 1 - Cancel
- 2 - Ignore
- 3 - No
- 4 - OK
- 5 - Retry
- 6 - Yes
nil on error.
Example
(dos_msgbox "Continue Batch Process?" "Batch Purge" 5 4)
These are just a couple of examples of some of the functions available
within DOSLib. There are 72 callable functions covering all areas of DOS
usage. On the next page we'll have a look at an AutoLisp application
designed using the DOSLib. See you there......
Page II. |