AfraLISP - Learn AutoLISP for AutoCAD productivity

The AutoLISP Input Box

by Kenny Ramage

Input Box

This routine is very similar to the Visual Basic Input Box Function. To use this routine you feed the function 3 arguments, the Input Box Prompt, the Title of the Input Box, and the Default Value of the Edit Box.

The syntax is straightforward:

	(inputbox "prompt" "title" "default")

For example, the Input Box above was called by using the following command:

	(inputbox "Enter Number" "AfraLisp Inputbox" "342.34")

The Input Box returns a variable "inputvalue" containing the value of the Edit Box.

Source Coding

First the DCL Coding :

inputbox : dialog {
	key = "title";
	: text {
	key = "prompt";
	: edit_box {
	key = "eb1";

And next the AutoLisp Coding :

(defun inputbox (prompt title default)
  (setq dcl_id (load_dialog "inputbox.dcl"))
  (if (not (new_dialog "inputbox" dcl_id))
  (set_tile "prompt" prompt)
  (set_tile "title" title)
  (set_tile "eb1" default)
  (mode_tile "eb1" 2)
     (setq result nil)"
    "(setq inputvalue (get_tile \"eb1\"))
     (setq result T)"
  (unload_dialog dcl_id)

If you would like the source coding for the the Input Box routine, just place your mouse here and click… Enjoy.