initget getreal

Discussion in 'AutoCAD' started by johnhatfield, Jul 21, 2004.

  1. johnhatfield

    johnhatfield Guest

    Hello,

    This is part of a big routine and I am trying to have a function within the main function that will allow a user to only enter one of the following at the prompt:

    4 5 6 7 7.5 8 9 10

    The getint would work if the 7.5 was not there. I would also like the function to remember what the user entered because it will be used repeatedly. As the function stands now I get the "fixnump" error. Because of some of the other code in the function I need the number to be a real number. A precision thing. For the life of me I can't figure out how to get this to work correctly.

    Any help would be appreciated.

    Thanks,
    John Hatfield

    (defun THEDIST (/)
    (cond ((= D1 nil) (setq D1 8)))
    (initget 6)
    (setq D2(getreal (strcat "\nENTER DISTANCE <" (itoa D1) ">: ")))
    (if (= D2 nil)
    (setq D2 D1)
    (setq D1 D2)
    );end if
    )
     
    johnhatfield, Jul 21, 2004
    #1
  2. A non-initget using getstring method -

    (if (or (not LDIST) (/= (type LDIST) 'str)) (setq LDIST "4")) ;set inital
    last distance
    (setq DIST nil)
    (while (not (member DIST (list "4" "5" "6" "7" "7.5" "8" "9" "10")))
    (setq DIST (getstring (strcat "\nEnter Distance - <ENTER=" LDIST "> : ")))
    (if (= DIST "") (setq DIST LDIST) (setq LDIST DIST))
    )
    (setq DIST (atof DIST))
     
    Alan Henderson @ A'cad Solutions, Jul 21, 2004
    #2
  3. johnhatfield

    ECCAD Guest

    Change:
    (setq D2(getreal (strcat "\nENTER DISTANCE <" (itoa D1) ">: ")))
    To:
    setq D2(getreal (strcat "\nENTER DISTANCE <" (rtos D1) ">: ")))

    Bob
     
    ECCAD, Jul 21, 2004
    #3
  4. johnhatfield

    Jürg Menzi Guest

    Hi John

    This solution allows the user to use the right click context to select the
    appropriate value:

    (defun THEDIST ( / D2)
    (cond ((= D1 nil) (setq D1 8)))
    (initget "4 5 6 7 7.5 8 9 10")
    (setq D2 (getkword
    (strcat "\nENTER DISTANCE [4/5/6/7/7.5/8/9/10] <" (rtos D1) ">: ")
    )
    D1 (cond (D2 (atof D2)) (D1))
    )
    )

    Cheers
     
    Jürg Menzi, Jul 21, 2004
    #4
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.
Similar Threads
Loading...