Welcome to the Southern African Autolisp Website.
You are Visitor Number
|
| Home. | Page II. | Page III. | Page IV. |
This tutorial will take you through all the steps of designing an
AutoLISP routine with, a Dialogue Box Interface.
It will guide you through the coding of the DCL file, to the retrieval
of the data from the Dialogue Box.
The dialogue box we will be designing will consist of the following :

samp1 : dialog { //dialog name
label = "Structural Holes" ; //give it a label
ok_cancel ; //predifined OK/Cancel
} //end dialog
Note the use of the predefined OK/Cancel tile. This is a standard tile
Now for the AutoLISP coding that calls the dialogue and handles
each tile :
(defun C:samp1 () ;define function
(setq dcl_id (load_dialog "samp1.dcl")) ;load dialog
(if (not (new_dialog "samp1" dcl_id) ;test for dialog
);not
(exit) ;exit if no dialog
);if
(action_tile
"cancel" ;if cancel button pressed
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
" (done_dialog)(setq userclick T))" ;close dialog, set flag
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(princ)
);defun C:samp
(princ)

samp2 : dialog { //dialog name
label = "Structural Holes" ; //give it a label
ok_cancel ; //predifined OK/Cancel
: paragraph { //*define paragraph
: text_part { //*define text
label = "Designed and Created"; //*give it some text
} //*end text
: text_part { //*define more text
label = "by Kenny Ramage"; //*some more text
} //*end text
} //*end paragraph
} //end dialog
And the coding remains the same except for name change :
(defun C:samp2 () ;define function
(setq dcl_id (load_dialog "samp2.dcl")) ;load dialog
(if (not (new_dialog "samp2" dcl_id) ;test for dialog
);not
(exit) ;exit if no dialog
);if
(action_tile
"cancel" ;if cancel button pressed
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
" (done_dialog)(setq userclick T))" ;close dialog, set flag
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(princ)
);defun C:samp
(princ)

samp3 : dialog { //dialog name
label = "Structural Holes" ; //give it a label
ok_cancel ; //predifined OK/Cancel
: row { //define row
: image { //*define image tile
key = "im" ; //*give it a name
height = 1.0 ; //*and a height
width = 1.0 ; //*and now a width
} //*end image
: paragraph { //define paragraph
: text_part { //define text
label = "Designed and Created"; //give it some text
} //end text
: text_part { //define more text
label = "by Kenny Ramage"; //some more text
} //end text
} //end paragraph
} //end row
} //end dialog
Because we haven't given the image tile a fixed height or a fixed width,
(defun C:samp3 () ;define function
(setq dcl_id (load_dialog "samp3.dcl")) ;load dialog
(if (not (new_dialog "samp3" dcl_id) ;test for dialog
);not
(exit) ;exit if no dialog
);if
(setq w (dimx_tile "im") ;*get image tile width
h (dimy_tile "im") ;*get image tile height
);setq
(start_image "im") ;*start the image
(fill_image 0 0 w h 5) ;*fill it with blue
(end_image) ;*end image
(action_tile
"cancel" ;if cancel button pressed
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
" (done_dialog)(setq userclick T))" ;close dialog, set flag
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(princ)
);defun C:samp
(princ)
(setq w (dimx_tile "im") ;*get image tile width
h (dimy_tile "im") ;*get image tile height
This retrieves the width and height of the image tile and allocates them
(start_image "im") ;*start the image (fill_image 0 0 w h 5) ;*fill it with blue (end_image) ;*end image
| Home. | Page II. | Page III. | Page IV. |