Function Definitions

4  -  User Input

initget ..... Establishes limitations on the user responses allowed by the next get- function

(initget 1)  null input not allowed ("null input" means 'Enter' by itself)
(initget 2)  0 input not allowed
(initget 3)  null input and 0 input not allowed  (3 = 1 + 2)
(initget 4)  negative values not allowed
(initget 5)  null input and negative values not allowed  (5 = 1 + 4)
(initget 6)  0 input and negative values not allowed  (6 = 2 + 4)
(initget 7)  null input, 0 input, and negative values not allowed  (7 = 1 + 2 + 4)
(initget 8)  cancels limits check
(initget 16)  (not used)
(initget 32)  causes get- functions that include a base point to display a rubber band cursor or window that is highlighted rather than solid
(initget 64)  Z coordinate not allowed in next getdist function
(initget 128)  allows arbitrary input (accepts any "key word")

(initget "A B C")  allows the user to enter "A" "B" "C" "a" "b" or "c" in response to the next get- function (in addition, of course, to the possibility of entering an integer if the next get- function is getint, a real if it is getreal, etc.) Subsequent programming must be set up to handle these strings.


getint ..... Pauses to get an integer from the user and returns that integer.

(getint)  waits for user to enter an integer
(getint "Enter an Integer: ")  displays prompt and waits for user to enter integer.

This function would typically be nested in a setq expression as follows:
(setq int1 (getint "Enter the first Integer: "))


getreal ..... Pauses to get a real number from the user and returns that number

(getreal)  waits for user to enter a number
(getreal "Enter number: ")  displays prompt and waits for user to enter a number

getreal would typically be nested in a setq expression as follows:
(setq n1 (getreal "Enter first number: "))


getpoint ..... Pauses to get a point from the user (in current AutoCAD format if entered from the keyboard) and returns the point

(getpoint)  waits for user to enter the coordinates of a point or pick the location of a point with the mouse
(getpoint "Enter a point: ")  same as above but also displays the prompt
(getpoint '(1 1) "Enter a point: ")  attaches a rubber-band cursor to the given point and waits for user to enter a different point, using the mouse or possibly using relative coordinates

getpoint would typically be nested in a setq expression as follows:
(setq p1 (getpoint "Enter the first point: "))


osnap ..... Returns a point snapped to some feature of existing geometry, based on the osnap mode used.  The current 3D view affects this function.  Several osnap modes can be identified at once, separated by commas.

(osnap '(4 3) "mid")  returns midpoint of existing geometry (line, arc, etc.) passing through 4,3
After (setq p1 '(2 6))
(osnap p1 "cen")  returns center of the circle or arc passing through point p1
(osnap (getpoint "Select line. ") "end")  returns the nearest endpoint on the selected line.

The current setting of APERTURE governs how close the cross hair must be to the object being selected.


getcorner ..... Pauses to get a point that is the opposite corner of a rectangular window As the point is being located, a window is drawn from the base point to the current mouse location. The point is normally in the current X-Y construction plane.

(getcorner p1 "Locate other corner: ")  waits for user to locate the corner of the window opposite point p1


getdist ..... Pauses to get a distance from the user (in current AutoCAD format, if entered from the keyboard) and returns the distance as a real.

(getdist)  waits for user to enter a distance from the keyboard or by locating two points with mouse. Prompts automatically for "Second point:
(getdist "Enter distance: ")  same as above but also displays the prompt
(getdist '(1 1) "Show distance. ")  attaches a rubber-band cursor to the given point and waits for user to enter the second point

getdist would typically be nested in a setq expression as follows:
(setq d1 (getdist "Enter the first distance: "))


getangle ..... Pauses to get an angle from the user (in current AutoCAD format if entered from the keyboard) and returns the angle in radians.  The angle is always measured in the current X-Y construction plane

(getangle)  waits for user to enter an angle from the keyboard or by locating two points with the mouse. Prompts automatically for "Second point:
(getangle "Enter an angle: ")  same as above but also displays the prompt
(getangle '(1 1) "Show angle: ")  attaches a rubber-band cursor to the given point and waits for user to enter the second point

getangle would typically be nested in a setq expression as follows:
(setq a1 (getangle "Enter the first angle: "))


getorient ..... Similar to getangle, except that getorient is insensitive to the 0-angle orientation set by the UNITS command

getstring ..... Pauses to get an alpha-numeric string (text string) from the user and returns that string

(getstring) waits for user to enter a string from the keyboard
(getstring "Enter a word: ") same as above but also displays the prompt. The string can be terminated by either a space or 'Enter'.

(getstring 1 "Enter a sentence: ") same as above, except that spaces are allowed within the string and the string must be terminated by 'Enter'  (The first argument can be anything that is non-nil.  Many books recommend using T, but T can be reset and 1 cannot.  So 1 is preferred.)

getstring would typically be nested in a setq expression as follows:
(setq pname (getstring 1 "Enter part name: "))


getkword ..... Similar to getstring, but getkword limits the allowable input to those responses designated by the previous initget function.  Converts the case of the responses to the case indicated by initget.

(initget 1 "L R")
(setq hand (getkword "Left or Right? (L/R) "))  returns "L" or "R" depending on user response.  If anything other that "L" "R" "l" or "r" is entered, user is prompted to try again.  If user enters lower case, upper case is returned because the letter are in upper case in the initget function.  Null response (just hitting 'Enter') is disallowed by the 1 in the initget expression.

(initget 1 "Yes No")
(setq answer (getkword "Placement O.K.? (Y/N) "))  returns "Yes" or "No" depending on user response.  The user may enter any of the following in any combination of upper or lower case letters:  "y" "ye" "yes" "n" "no".  Since the first letter of each keyword is capitalized in the initget expression, the user must enter at least that first letter (upper or lower case).  Entering any additional letters is optional, and they can be entered as upper or lower case, but they must match the letters indicated in the initget expression.


HOME


Copyright © 1988, 1998 Ronald W. Leigh