Analyzing the Code

The defun function statement defines the new function. Notice the main function is named C:GPath. The C: prefix establishes that this function is callable from the AutoCAD command line. GPath is the name users enter to launch the application from the AutoCAD Command prompt. The functions that obtain input from users are named gp:getPointInput and gp:getDialogInput. The function that draws the garden path outline is gp:drawOutline. These names are prefixed with gp: to indicate they are specific to the garden path application. This is not a requirement, but it is a good naming convention to use to distinguish application-specific functions from general utility functions you frequently use.

In the main function, princ expressions display the results of the program if it runs successfully, or a warning message if the program encounters an unexpected event. For example, as will be seen in Lesson 2, if the user presses ENTER instead of picking a point on the screen, the call to gp:getPointInput ends prematurely, returning a nil value to the main function. This causes the program to issue a princ message of “Incomplete information to draw a boundary.”

The call to princ near the end of the program serves as a prompt. Upon application load, the prompt informs users what they need to type to initiate the drawing of a garden path. The final princ without a string argument forces the program to exit quietly, meaning the value of the main function's final expression is not returned. If the final suppressing princ were omitted, the prompt would display twice.