;;;********************************************************************
;;; Program Name: Resistance.lsp
;;; Program Purpose: Calculate the voltage drop across two resistors
;;; in a series, as well as the current for the cirrcuit.
;;; Date: 1/13/99
;;; Programmed By: James Kevin Standiford
;;;
;;;********************************************************************
;;;
;;; Main Program
;;;
;;;********************************************************************
(DEFUN C:resistance (/ voltage resistance_1
resistance_2 equivalent value_1
value_2 current name
length_string name_truncated file_name
)
;;;
;;; Obtain Information and Perform Calculations
;;;
(SETQ
file_name (STRCAT (SUBSTR (GETVAR "dwgname")
1
(- (STRLEN (GETVAR "dwgname")) 4)
)
".RLT"
)
file (open file_name "a")
voltage (GETREAL "\nEnter voltage of circuit : ")
resistance_1 (GETREAL "\nEnter resistance of resistor #1 : ")
resistance_2 (GETREAL "\nEnter resistance of resistor #2 : ")
equivalent (+ resistance_1 resistance_2)
current (/ voltage equivalent)
value_1 (* current resistance_1)
value_2 (* current resistance_2)
)
;;;
;;; Print Information to Both a File and Screen
;;;
(PRINC
(PRINC (STRCAT "\nThe current drawn by this circuit is "
(RTOS current)
)
file
)
)
(PRINC
(PRINC (STRCAT "\nThe equivalent resistance for this circuit is "
(RTOS equivalent)
)
file
)
)
(PRINC
(PRINC (STRCAT "\nThe voltage drop across resistor #1 is "
(RTOS value_1)
)
file
)
)
(PRINC
(PRINC (STRCAT "\nThe voltage drop across resistor #2 is "
(RTOS value_2)
)
file
)
)
(close file)
(PRINC)
)
(princ)
(princ "\nEnter Resistance to start program ")
(princ)
No comments:
Post a Comment