;;CADALYST 09/03 Tip1895: ADD-CAD.LSP FEET-INCHES-SIXTEENTHS (c) 2003 Greg Young ; Greg Young ; Structural Designer ; This program uses the FFIISS method for adding, subtracting, multiplying, and dividing ; numbers in feet, inches, and sixteenths without the need to covert these numbers to ; their decimal value manually. The FFIISS system is a simple input format that allows ; you to enter feet, inches, and sixteenths without having to input charaters such as ; "'", "-", and """, thus allowing you to input these numbers using *just* the number pad ; on your keyboard. ; The FF part of the format is the feet. This may be omitted if the number is 0. ; The II part of the format is the inches. This should always come right after the decimal ; point, and should always be input in a 2 digit format. This should never be omitted. ; The SS part of the format is the sixteents. This should always come right after the inches, ; and should always be input in a 2 digit format. This should never be omitted. ; Example: 15'-5 7/16" would be input as 15.0507 ; Example: 0'-5 7/16" would be input as .0507 ; Example: 0'-0 7/16" would be input as .0007 ; Example: 4'-11 3/8" would be input as 4.1106 ; To use the addition program, type '+' then [ENTER] at the command line. Input the first number ; then hit [ENTER], input the second number then hit [ENTER], etc... when you have input all of ; your numbers, hit [ENTER] at a blank prompt. The sum is then output to the screen in FFIISS ; format and decimal format. ; To use the subtraction program, type '+' then [ENTER] at the command line. Input the number to ; be subtracted from, then hit [ENTER]. Then, input the number to subtract from the first number ; with a prefix of "-" then hit [ENTER] twice. ; Example: To subtract 0'-5 7/16" from 13'-9 3/4" you would enter (without the quotes) "13.0912" ; [ENTER] "-.0507" [ENTER] [ENTER]. ; The difference is then output to the screen in FFIISS format and decimal format. ; To use the division program, type 'div' then [ENTER] at the command line. Input the number to be ; divided from, then hit [ENTER]. Input the number to divide by, then hit [ENTER]. ; The result is then output to the screen in FFIISS format and decimal format. ; To use the multiplication program, type 'mul' then [ENTER] at the command line. Input the first ; number, then hit [ENTER]. Input the number to multiply the first number by, then hit [ENTER]. ; The result is then output to the screen in FFIISS format and decimal format. ; The output answer is stored in a variable for use the next time you run the program. You can ; call up the last value by typing ".." at the programs prompt. ; Example: With the above example the answer output is 11.0405 (11'-4 5/16). If you needed to ; divide that last answer by 4, you would do the following: ; Type 'div' at the command line. Hit [ENTER]. Type '..' then '4'. (defun C:+ (/ a) (setq run (list 0)) (while (/= a 0) (setq a (getstring "+ ")) (if (= a "..") (setq a answer) (setq a (atof a)) ) (setq b (fix a)) (setq c (- a b)) (setq d (* c 100)) (setq e (+ b (/ (+ (fix (atof (rtos d 2 2))) (/ (- d (fix (atof (rtos d 2 2)))) 0.16)) 12))) (setq run (cons e run)) ) (setq total (apply '+ run)) (setq i (+ total 0.0026041667)) (setq j (fix i)) (setq k (* (- i j) 12)) (setq l (/ (float (fix k)) 100)) (setq m (* (- k (fix k)) 16)) (setq n (/ (float (fix m)) 10000)) (setq answer (+ j l n)) (princ "FFIISS DECIMAL(ft)") (princ "\n") (princ (strcat (rtos answer 2 4) " " (rtos total 2 4))) (princ) ) (defun C:div (/ a) (setq run (list 0)) (setq x 0) (while (/= x 2) (setq a (getreal "+ ")) (setq b (fix a)) (setq c (- a b)) (setq d (* c 100)) (setq e (+ b (/ (+ (fix (atof (rtos d 2 2))) (/ (- d (fix (atof (rtos d 2 2)))) 0.16)) 12))) (setq run (cons e run)) (setq x (+ x 1)) ) (setq run (subst '1 '0.0 run)) (setq run (reverse run)) (setq run (cdr run)) (setq total (apply '/ run)) (setq i (+ total 0.0026041667)) (setq j (fix i)) (setq k (* (- i j) 12)) (setq l (/ (float (fix k)) 100)) (setq m (* (- k (fix k)) 16)) (setq n (/ (float (fix m)) 10000)) (setq answer (+ j l n)) (princ "FFIISS DECIMAL(ft)") (princ "\n") (princ (strcat (rtos answer 2 4) " " (rtos total 2 4))) (princ) ) (defun C:mul () (setq a nil) (setq run (list 0)) (setq x 0) (while (/= x 2) (setq a (getreal "+ ")) (setq b (fix a)) (setq c (- a b)) (setq d (* c 100)) (setq e (+ b (/ (+ (fix (atof (rtos d 2 2))) (/ (- d (fix (atof (rtos d 2 2)))) 0.16)) 12))) (setq run (cons e run)) (setq x (+ x 1)) ) (setq run (subst '1 '0.0 run)) (setq total (apply '* run)) (setq i (+ total 0.0026041667)) (setq j (fix i)) (setq k (* (- i j) 12)) (setq l (/ (float (fix k)) 100)) (setq m (* (- k (fix k)) 16)) (setq n (/ (float (fix m)) 10000)) (setq answer (+ j l n)) (princ "FFIISS DECIMAL(ft)") (princ "\n") (princ (strcat (rtos answer 2 4) " " (rtos total 2 4))) (princ) )