Getting more than 1 key while in grread

Discussion in 'AutoCAD' started by diemaker, Oct 26, 2004.

  1. diemaker

    diemaker Guest

    While in a grread, is it possible to type more than one key? Like a number larger than 9.
    The following code draws 3 “X’s†from a point list. I want the X’s to be redrawn if there is a zoom, so grread is being used to create a loop. But while in this loop the user is prompted for a number, which could be 1, 2 or more digits. Grread stops with the first keystroke. I can change the prompt to read …“change the number of points Y/N <N>:†…then Y would bring up a prompt for the new number. But I would prefer to make grread capture the keys until a return is hit? Or is there a better approach?
    Thanks.


    (defun C:Z ()
    (setq PL '((0.0 0.0 0.0) (1.0 1.0 0.0) (2.0 2.0 0.0))
    NUM (length PL)
    )
    (prompt (strcat "\nNumber of points = "
    (itoa NUM)
    "\nType new number of points <accept>: "
    )
    )
    ;;;
    (while (/= (car (setq A (grread 't 2 0))) 2)
    (setq SIZ (* 0.02 (getvar "viewsize")))
    (foreach Z PL
    (grdraw (polar Z 0.785 SIZ) (polar Z 3.927 SIZ) 3)
    (grdraw (polar Z 2.356 SIZ) (polar Z 5.498 SIZ) 1)
    )
    )
    ;;;
    (princ A)
    (princ (chr (cadr A)))
    )
     
    diemaker, Oct 26, 2004
    #1
  2. diemaker

    Doug Broad Guest

    To enter more than one keystroke, your while test should check
    for either an <esc> character or the return or space characters.
    Only then should it escape the loop.


    there is a zoom, so grread is being used to create a loop. But while in this loop the user
    is prompted for a number, which could be 1, 2 or more digits. Grread stops with the first
    keystroke. I can change the prompt to read ."change the number of points Y/N <N>:" .then
    Y would bring up a prompt for the new number. But I would prefer to make grread capture
    the keys until a return is hit? Or is there a better approach?
     
    Doug Broad, Oct 26, 2004
    #2
  3. diemaker

    diemaker Guest

    Fantastic, thank you.

    ;;vars used in the next while
    (setq A '(2 111) ;first time while
    NEW ""
    )
    ;;grdraws points till an enter
    (while (and (/= (cadr A) 13) ;return
    (/= (cadr A) 32) ;space
    )
    ;;grdraw X's on the point list, returns grread value
    (setq A (TL_GRDRAWPOINTS PL))
    ;;if not return or space
    (if (and (/= (cadr A) 13) ;return
    (/= (cadr A) 32) ;space
    (= (type (read (chr (cadr A)))) 'INT) ;maker sure it is a number
    )
    ;;build a new number<string> till return is hit
    (progn (setq NEW (strcat NEW (chr (cadr A))))
    (prompt (chr (cadr A)));display number
    )
    )
    ) ;while
    (if (/= NEW "") ;number was changed
    (setq NUM (atoi NEW)) ;make new number
    (set LOOP NIL) ;no new number, stop while
    )
     
    diemaker, Oct 26, 2004
    #3
  4. diemaker

    Doug Broad Guest

    Your welcome. Glad to help.
     
    Doug Broad, Oct 26, 2004
    #4
  5. diemaker

    Doug Broad Guest

    (oops)

    You're
     
    Doug Broad, Oct 26, 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.