AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Compiling AutoLisp Files - Page II

Visual Lisp provides you with the ability to create a single, standalone executable module for your application. This module incorporates all your application's compiled files, and can include DCL, DVB, and other files that your application may need. Executable Visual Lisp modules are known as VLX files, and are stored in files named with a .vlx extension.
A Make Application wizard guides you through the application building process in Visual Lisp. The result of this process is a Make file, which is often referred to by its file extension, .prv. The Make file contains all the instructions Visual Lisp needs to build the application executable.

To test this out, I've provided an AutoLisp Application that consists of an AutoLisp file, and a DCL file. From these 2 files we will compile one vlx executable module. (Just click here to download the source files). Unzip these files and save them in any directory within your AutoCAD Support Path.

OK, fire up AutoCAD and open the Visual Lisp Editor. Now select "Files" - "Make Application" - "New Application" from the pulldown menu :

This dialog will appear :

Select "Expert" mode as we want to compile multiple file types, and then press "Next" :

Enter the path to the directory you would like to store the files in. Select the same directory that you stored the AutoLisp source files.
Then, give your application a name. It does not have to be the same as your AutoLisp source file, but to spare any confusion, let's keep it the same.
The select "Next" :

No, we do not want our application to run in a separate namespace.
Just select "Next" :

Now we need to select our AutoLisp source file. Select "refl.lsp" then press "Next" :

In this dialog, we select and add any dependency files that our application needs to run correctly. Select "refl.dcl" and then "Next" :

No need to confuse you now, just go with the "Standard" option. Select "Next" :

OK, that's us about done. To build your compiled application, just select "Finish".

VLISP executes instructions in a Make file to build an application. Output messages from this process appear in two VLISP windows: the Build Output window and the Console window. The Build Output window contains messages relating to any compilation of AutoLISP source code into .fas files. In a successful compile, the output looks like the following :

; (COMPILE-FILES st (D:/drawings/refl.lsp))
[Analyzing file "D:/drawings/refl.lsp"]
..
......
[COMPILING D:/drawings/refl.lsp]
;
;;C:REFL
;CCC
;;MKLIST
;;SPINBAR
;;INITERR
;;TRAP
;;RESET
;
[FASDUMPING object format -> "D:/drawings/refl.fas"]
; Compilation complete.

The compiler messages identify the following items:

  • The name and directory path of the source files being compiled.
  • The functions defined in the source file. Seven functions are identified: C:REFL, CCC, MKLIST, SPINBAR, INITERR, TRAP and RESET.
  • The name and path of the output .fas files.

The VLISP Console window displays messages relating to the creation of the application executable, the .vlx file. If the Make Application process succeeds, the Console window displays the path and file name of the .vlx, as in the following example:

VLX-Application packed D:/drawings/refl.VLX
_$


Have a look in the directory where you stored the source files. You should now have 5 "refl" files :

  • refl.lsp - AutoLisp source file
  • refl.dcl - DCL source file
  • refl.fas - Compiled AutoLisp Program
  • refl.vlx - Executable Visual Lisp Module
  • refl.prv - Application Make file.

You can now distribute "refl.vlx" as a compiled application.

Note!!! You CANNOT edit a vlx file. These 5 files need to be kept in a safe location if you intend to edit or revise your vlx file.


Loading Compiled AutoLisp Applications :

Loading compiled applications is exactly the same as for normal AutoLisp functions :

(load "refl")

Here's a couple of things to keep in mind :

If you do not specify a file extension, load first looks for a file with the name you specified (for example, "refl"), and an extension of .vlx. If no .vlx file is found, load searches next for a .fas file, and finally, if no .fas file is found, load searches for a .lsp file.


Tip of the Day :

To aid you in the process of maintaining multiple-file applications, VLISP provides a construct called a Project. A VLISP Project contains a list of AutoLISP source files, and a set of rules on how to compile the files.
Using the Project definition, VLISP can do the following :

  • Check which .lsp files in your application have changed, and automatically recompile only the modified files. This procedure is known as a Make procedure.
  • Simplify access to source files by listing all source files associated with a project, making them accessible with a single-click.
  • Help you find code fragments by searching for strings when you do not know which source files contain the text you're looking for. VLISP limits the search to files included in your project.
  • Optimize compiled code by directly linking the corresponding parts of multiple source files.

Have a look at the Visual Lisp Help for further information on Projects.

 
The AutoLisp/Visual Lisp/VBA Resource Website

Copyright 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website