dealing with "error: misplaced dot on input"

Discussion in 'AutoCAD' started by Joe Burke, Jan 29, 2004.

  1. Joe Burke

    John Uhden Guest

    Absolutely. I think my brain had gone to bed before me. (eval) could do
    anything like call another function!
    Back to reality...
    (defun GetNumber (msg / value result)
    (while (not result)
    (setq value (getstring msg))
    (if (setq result (distof value))
    (if (wcmatch value "*`.*,*[/\]*,*[eE]*")
    result
    (atoi value)
    )
    (prompt "\nMust enter a number or numeric symbol,")
    )
    )
    )
     
    John Uhden, Jan 30, 2004
    #21
  2. This seems to cover them all.

    ;; by Ken Alexander 1/29/2004
    (defun getnum2 (/ a)
    (while (not a)
    (initget 128)
    (setq a (getint "\nEnter a number: "))
    (cond
    ((and a
    (not (numberp a))
    (distof a 4))
    (setq a (distof a 4))
    )
    ((and a
    (not (numberp a))
    (not (distof a)))
    (setq a (eval (read a)))
    )
    ((and a
    (not (numberp a))
    (member (strcase a) '("PI")))
    (setq a (eval (read a)))
    )
    )
    )
    a
    )


    Command: (getnum)
    Enter a number: 23
    23

    Command: (getnum)
    Enter a number: 23.3
    23.3

    Command: (getnum)
    Enter a number: -25
    -25

    Command: (getnum)
    Enter a number: -.025
    -0.025

    Command: (getnum)
    Enter a number: 1/4
    0.25

    Command: (getnum)
    Enter a number: -1/4
    -0.25

    Command: (getnum)
    Enter a number: 1'-3-1/2"
    15.5

    Command: (getnum)
    Enter a number: pi
    3.14159

    Command: (getnum)
    Enter a number: 1.55E+01
    15.5

    Command: (setq b nil)
    nil
    Command: (getnum)
    Enter a number: b
    Enter a number: 23
    23

    Command: (setq b 12.3)
    12.3
    Command: (getnum)
    Enter a number: b
    12.3

    --
    Ken Alexander
    Acad2004
    Windows2000 Prof.

    "We can't solve problems by using the same kind
    of thinking we used when we created them."
    --Albert Einstein

     
    Ken Alexander, Jan 30, 2004
    #22
  3. Joe Burke

    Doug Broad Guest

    Ken,
    Nice function. When I use
    (getnum2)
    Enter a number: b
    "b"

    Everyone,
    Nice discussion. For my contribution, I thought about
    how CAL could actually accept much of what Joe asked
    for and returns the number properly typed. Consider
    either
    (cal)

    or for more slightly more control:
    (arxload "geomcal")
    ;;D. C. Broad, Jr. 1/30/2004
    (defun getnum (prmpt / expr result)
    (while
    (or
    (= (setq expr (getstring prmpt)) "")
    (not (setq result (cal expr)))))
    result)

    With that, you could enter integers, reals,
    scientific expressions, poorly formatted fractions,
    equations, symbols bound to values....

    Is that cheating? <Bwa ha ha>


    <snip>
     
    Doug Broad, Jan 30, 2004
    #23
  4. Joe Burke

    Doug Broad Guest

    So close.....Suspected it was too easy
    Cal has always had a problem with fractions.

    That would need to have been entered
    12'4"+3/4 <----yuck
     
    Doug Broad, Jan 30, 2004
    #24
  5. Joe Burke

    Joe Burke Guest

    This seems to work as well.

    ;; 1/30/2004
    (defun GetNumber ( / result )
    (setq result (getreal "\nEnter numeric value: "))
    (if (= (fix result) result)
    (fix result)
    result
    )
    )

    Joe Burke
     
    Joe Burke, Jan 31, 2004
    #25
  6. Might as well go with (getdist)
     
    Jason Piercey, Jan 31, 2004
    #26
  7. Joe Burke

    Joe Burke Guest

    Duh... junk that. It doesn't work with something like 25.0.
     
    Joe Burke, Jan 31, 2004
    #27
  8. Joe Burke

    Joe Burke Guest

    Hi Jason,

    I believe getdist always returns a real, like getreal. So I don't see where that
    would help. Maybe you have something else in mind?

    Command: (getdist)
    25
    25.0

    BTW, I'm dumbfounded by my penchant for saying stupid things at the end of otherwise
    quality threads. I hope someday I'll learn to avoid that. In the mean time, I'll have
    to rely on forgiving nature of the folks I respect here.

    My thanks to everyone who contributed, especially Ken. I plugged a modified version
    of Ken's idea back into my text increment functions. The code is much cleaner and
    more reliable now. An annoying problem finally put to bed.

    Regards
    Joe
     
    Joe Burke, Jan 31, 2004
    #28
  9. Hi Joe,

    I suggested using (getdist) so you could also obtain
    input in the current unit format (thinking fractions).

    Command: (getdist)
    1/4
    0.25

    But I see that doesn't matter now.

    PS: I've got a bad case of that 'foot-in-mouth' disease
    myself, so you are not alone <g>.
     
    Jason Piercey, Jan 31, 2004
    #29
  10. You're welcome Joe.
    Glad to have been able to contribute.

    --
    Ken Alexander
    Acad2004
    Windows2000 Prof.

    "We can't solve problems by using the same kind
    of thinking we used when we created them."
    --Albert Einstein
     
    Ken Alexander, Feb 1, 2004
    #30
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.