getkword....

Discussion in 'AutoCAD' started by C Witt, Oct 5, 2004.

  1. C Witt

    C Witt Guest

    using ..
    (initget 1 "y n")
    (getkword "blah: ")


    the only correct responses are "y" or "n".. that part i have.. works
    fine. but how can i change this so the user does not "need" to hit
    enter (return) after the "y" or "n" for the lisp to continue...?

    TIA.
     
    C Witt, Oct 5, 2004
    #1
  2. C Witt

    David Bethel Guest

    You could go about it like this:

    (setq in nil)
    (while (or (not in)
    (not (member in '(78 89 110 121))))
    (princ "\nY / N: ")
    (setq in (cadr (grread))))
    (setq in (strcase (chr in)))
    (prin1 in)

    -David
     
    David Bethel, Oct 5, 2004
    #2
  3. C Witt

    C Witt Guest

    uuuhhh.. ok. I'll have to look at that.

    thanks.
     
    C Witt, Oct 5, 2004
    #3
  4. C Witt

    Tom Smith Guest

    uuuhhh.. ok. I'll have to look at that.

    I agree w/ David, as far as I know, grread the only way to get keyboard
    input that isn't terminated by a return. He's allowing upper or lowercase y
    or n and ignoring anything else.
     
    Tom Smith, Oct 5, 2004
    #4
  5. C Witt

    David Bethel Guest

    You could make it into a modular call

    (defun getsltr (al / in cl)
    (foreach a al
    (setq cl (cons (ascii (strcase a t)) cl)
    cl (cons (ascii (strcase a)) cl)))
    (while (not (member in cl))
    (princ "\n")
    (prin1 al)
    (princ ": ")
    (setq in (cadr (grread))))
    (strcase (chr in)))


    (prin1 (getsltr '("Y" "N")))

    -David
     
    David Bethel, Oct 5, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.