AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Here's a couple of example "Thingies" :

;CODING STARTS HERE
;Extract from User Get Functions with Default Prompt
;AfraLisp Thingie Library
;http://www.afralisp.com
;March 2002
;--------------------
;Description : Integer Input Function with prompt
;Syntax : (LISP_getint prompt default_value)
;Arguments : prompt - User defined prompt - String
; default_value - Default Value - Integer
;Returns : val - Integer or Default Value
;Example : (Lisp_getinteger "Please enter Integer" 7)

(defun LISP_getint (prmpt val / x)

(princ (strcat "\n" prmpt " <" (itoa val) ">: "))
(setq x (getint))
(if x
(setq val x)
)
val
)
;-------------
;Description : Real Number Input Function with prompt
;Syntax : (LISP_getreal prompt default_value)
;Arguments : prompt - User defined prompt - String
; default_value - Default Value - Real Number
;Returns : val - Real Number or Default Value
;Example : (Lisp_getreal "Please input Number" 8.5)

(defun LISP_getreal (prmpt val / x)

(princ (strcat "\n" prmpt " <" (rtos val 2 (getvar "LUPREC")) ">: "))
(setq x (getreal))
(if x
(setq val x)
)
val
)
;---------------
;Description : String Input Function with prompt
;Syntax : (LISP_getstring prompt default_value)
;Arguments : prompt - User defined prompt - String
; default_value - Default Value - String
;Returns : val - String or Default Value
;Example : (Lisp_getstring " Please Enter Your Name" "Kenny")

(defun LISP_getstring (prmpt val / tstr)
(princ (strcat "\n" prmpt " <" val ">: "))
(setq tstr (getstring T))
(if (/= tstr "") tstr val)
)
;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