- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am writing a program to calculate the weight of materials. I want to prompt for Lineal Footage under certain conditions, but I want to end the program with "Size Not Available" under all other conditions. For instance, if I answer STL to the "Material Type" prompt, 1/8 to the "U-Edge Clear Open" prompt, and 12 to the "Gauge" prompt, then I will be prompted for "Lineal Footage". This works great, but if I were to answer AL for "Material Type", and 1/2 for "U-edge Clear Open", I want the program to end with "Size Not Available", but it ends with "Size Not Availablenil". I have tried everything and can't seem to get rid of the nil at the end. Does anyone have a clue how to fix this? (Keep in mind that I haven't added anything for SS yet)
(defun c:UE (/ mt op ga lf wt)
(initget "STL AL SS")
(setq mt (getkword "\nMaterial Type: Steel<STL> Aluminum<AL> Stainless Steel<SS>:"))
(initget "1/8 1/4 3/8 1/2")
(setq op (getkword "\nU-Edge Clear Open: <1/8> <1/4> <3/8> <1/2>:"))
(cond ((= mt "STL")
(initget "12 14 18")
(setq ga (getkword "\nGauge: <12> <14> <18>:")))
((= mt "AL")
(setq ga (= 0.063))
);end argument
);end condition
(cond
((= mt "STL")
(setq lf (getdist "\nLineal Feet:")))
((and (= mt "AL") (= op "1/8"))
(setq lf (getdist "\nLineal Feet:")))
((and (= mt "AL") (= op "1/4"))
(setq lf (getdist "\nLineal Feet:")))
(T
(princ "Size Not Available")
(princ)))
(cond
((and (= mt "STL") (= op "1/8") (= ga "12"))
(setq wt (* lf 0.7990))
(princ "\nWeight lbs:")
(princ wt)
(princ))
((and (= mt "STL") (= op "1/8") (= ga "14"))
(setq wt (* lf 0.5615))
(princ "\nWeight lbs:")
(princ wt)
(princ))
((and (= mt "STL") (= op "1/8") (= ga "18"))
(setq wt (* lf 0.3542))
(princ "\nWeight lbs:")
(princ wt)
(princ))
;end 1/8" open Steel variations
((and (= mt "STL") (= op "1/4") (= ga "12"))
(setq wt (* lf 0.8246))
(princ "\nWeight lbs:")
(princ wt)
(princ))
((and (= mt "STL") (= op "1/4") (= ga "14"))
(setq wt (* lf 0.5798))
(princ "\nWeight lbs:")
(princ wt)
(princ))
((and (= mt "STL") (= op "1/4") (= ga "18"))
(setq wt (* lf 0.3665))
(princ "\nWeight lbs:")
(princ wt)
(princ))
;end 1/4" open Steel variations
((and (= mt "STL") (= op "3/8") (= ga "12"))
(setq wt (* lf 0.8502))
(princ "\nWeight lbs:")
(princ wt)
(princ))
((and (= mt "STL") (= op "3/8") (= ga "14"))
(setq wt (* lf 0.5592))
(princ "\nWeight lbs:")
(princ wt)
(princ))
((and (= mt "STL") (= op "3/8") (= ga "18"))
(setq wt (* lf 0.3783))
(princ "\nWeight lbs:")
(princ wt)
(princ))
;end 3/8" open Steel variations
((and (= mt "STL") (= op "1/2") (= ga "12"))
(setq wt (* lf 0.8773))
(princ "\nWeight lbs:")
(princ wt)
(princ))
((and (= mt "STL") (= op "1/2") (= ga "14"))
(setq wt (* lf 0.6175))
(princ "\nWeight lbs:")
(princ wt)
(princ))
((and (= mt "STL") (= op "1/2") (= ga "18"))
(setq wt (* lf 0.3900))
(princ "\nWeight lbs:")
(princ wt)
(princ))
;end 1/2" open Steel variations
((and (= mt "AL") (= op "1/8"))
(setq wt (* lf 0.1573))
(princ "\nWeight lbs:")
(princ wt)
(princ))
;end 1/8" open Aluminum
((and (= mt "AL") (= op "1/4"))
(setq wt (* lf 0.2187))
(princ "\nWeight lbs:")
(princ wt)
(princ))
);end condition
);end function
Solved! Go to Solution.