Conditional Statement Error?

Discussion in 'AutoCAD' started by Ryan-Walker, Aug 20, 2003.

  1. Ryan-Walker

    Ryan-Walker Guest

    Please forgive my experience level, but when I try to run the following
    code, I get this error "; error: bad argument type: FILE 24.0". The
    "24.0" is the correct answer to the input I give. I have never seen
    this error in this format before. The idea behind this code is to
    formulate the "Power" when one variable is unknown. Any help is
    appreciated.


    (defun c:power ()
    (setq E (GETREAL "Voltage?:"))
    (setq I (GETREAL "Amps?:"))
    (setq R (GETREAL "Resisitance?:"))

    (COND ((= E NIL) (PRINC (RTOS E1 2 3) (SETQ E1 (* (EXPT I 2) R)))) ;;IF
    NO VOLTAGE USE THIS FORMULA
    ((= I NIL) (PRINC (RTOS I1 2 3) (SETQ I1 (/ (EXPT E 2) R))))
    ;;IF NO AMPERAGE USE THIS FORMULA
    ((= R NIL) (PRINC (RTOS R1 2 3) (SETQ R1 (* E I)))))
    ;;IF NO RESISTANCE USE THIS FORMULA
    (princ))
     
    Ryan-Walker, Aug 20, 2003
    #1
  2. Ryan-Walker

    Ryan Walker Guest

    (SETQ E1 (* (EXPT I 2) R)))) ??? (TYP)

     
    Ryan Walker, Aug 20, 2003
    #2
  3. Ryan-Walker

    Paul Turvill Guest

    Like Mark says: set your variables before trying to (princ) them. I think
    this does what you're trying to do:

    (defun c:power (/ e i r e1 i1 r1)
    (setq E (GETREAL "Voltage?:"))
    (setq I (GETREAL "Amps?:"))
    (setq R (GETREAL "Resisitance?:"))
    (COND
    ((not E)
    (SETQ E1 (* (EXPT I 2) R))
    (PRINC (RTOS E1 2 3))
    )
    ((not I)
    (SETQ I1 (/ (EXPT E 2) R))
    (PRINC (RTOS I1 2 3))
    )
    ((not R)
    (SETQ R1 (* E I))
    (PRINC (RTOS R1 2 3))
    )
    )
    (princ)
    )

    However, you may want to include some instructions about leaving the unknown
    value blank ... the casual user may fill in all three values and, will then
    get nothing but a blank Command: prompt in response.
    ___
     
    Paul Turvill, Aug 20, 2003
    #3
  4. Ryan-Walker

    Ryan Walker Guest

    Thank you very much!

     
    Ryan Walker, Aug 20, 2003
    #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.