Getting Character Input with GETSTRING

16 downloads 28 Views 121KB Size Report
"Gary Indiana Jones". Command: (setq s (getstring T "Enter filename: ")). Enter filename: c:\my documents\vlisp\secrets. "c:\\my documents\\vlisp\\secrets"
Getting Character Input with GETSTRING GETSTRING Returns a string of up to 132 characters from the user. If the optional [cr] argument is nil or is omitted. Spaces are not allowed in the string, and the spacebar acts like an Enter and ends input. The optional [msg] can provide specific instructions for input.

(getstring [cr] [msg]) The user cannot enter another AutoLISP expression as the response to a getstring request.

Arguments cr If supplied and not nil, this argument indicates that users can include blanks in their input string (and must terminate the string by pressing ENTER ). Otherwise, the input string is terminated by space or ENTER. msg A string to be displayed to prompt the user.

Return Values The string entered by the user, or nil, if the user pressed ENTER without typing a string. If the string is longer than 132 characters, getstring returns only the first 132 characters of the string. If the input string contains the backslash character (\), getstring converts it to two backslash characters (\\). This allows you to use returned values containing file name paths in other functions.

Examples Command: (setq s (getstring "What’s your first name? ")) What’s your first name? Gary "Gary" Command: (setq s (getstring T "What’s your full name? ")) What’s your full name? Gary Indiana Jones "Gary Indiana Jones" Command: (setq s (getstring T "Enter filename: ")) Enter filename: c:\my documents\vlisp\secrets "c:\\my documents\\vlisp\\secrets"