AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

I am trying to automate some of my lisp files here in the office. I would like to be able to use a dialog box to choose which LISP file to run. How do I make a call to run another lisp file from a radio button? Do I make the call to the lisp In the "action_tile"? ex: (action_tile "rb1" "(setq door \"single\")") where "single" is the name of the lisp file I want to execute.

Copy this coding into Notepad and save it as Startlisp.dcl :

//dcl coding starts here
startlisp : dialog {
label = "StartLisp" ;

: radio_button {
key = "rb1" ;
label = "Lisp Routine No &1" ;
value = "1" ;
}

: radio_button {
key = "rb2" ;
label = "Lisp Routine No &2" ;
}

ok_cancel ;

}
//dcl coding ends here

Now copy this coding into Notepad and save it as Startlisp.lsp :

;autolisp coding starts here
(defun C:startlisp ()
;define function

(setq choice "No1")
;store default choice

(setq dcl_id (load_dialog "startlisp.dcl"))
;load dialog

(if (not (new_dialog "startlisp" dcl_id)
;test for dialog

);not

(exit)
;exit if no dialog

);if

(action_tile "rb1" "(setq choice \"No1\")")
;*store choice

(action_tile "rb2" "(setq choice \"No2\")")
;*store choice

(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog

);action tile

(action_tile
"cancel"
;if cancel button pressed

"(done_dialog) (setq userclick nil)"
;close dialog

);action_tile

(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload

(if userclick
;check O.K. was selected

(progn
;do the following

(if (= choice "No1")

(progn
(cond

((null C:Lisp1) (prompt "Please Wait...")
;if not loaded

(load "Lisp1")))
;load it

(C:Lisp1)
;then run it

);progn

);if

(if (= choice "No2")

(progn
(cond

((null C:Lisp2) (prompt "Please Wait...")
;if not loaded

(load "Lisp2")))
;load it

(C:Lisp2)
;then run it

);progn

);if

);progn

);if userclick

(princ)

);defun

(princ)
;autolisp coding ends here

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