Message 1 of 12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I'm looking to turn TOTAL inches into FT-IN. My code is posted below. I'm almost positive there is a better way to do this, we can get to that later. I would like to finish this code out first as I'm still green to LISP. I know enough to be dangerous LOL.
What I'm am looking for is in my answer to show up in the command line nice and pretty. Right now if 25 is the number I type in, "2'-1''" is my answer in the command line. I would like the answer to appear 2'-1" in command line. I know this won't cut it for fractions, but that is the later part.
Any and all help would be much appreciated.
Derek
(defun c:in ()
(setvar "cmdecho" 0)
;---Get User Input------------------------------------------------------------------------
(setq in2 (getreal "\nInches (in decimal): ")) ;gets Total Number of Inches (real number)
;---Isolate FT----------------------------------------------------------------------------
(setq in-a (fix in2)) ;in2 real to Integer (DOES NOT ROUND UP)
(setq ft-a (/ in-a 12)) ;gets feet for solution
(setq ft-b (itoa ft-a)) ;turn solution into STRING
;---Isolate INCHES------------------------------------------------------------------------
(setq in-b (* (- (/ in2 12) ft-a) 12)) ;gets inches for solution
(setq in-c (fix in-b)) ;in2 real to Integer (DOES NOT ROUND UP)
(setq in-d (itoa in-c)) ;turn solution into STRING
;---Solution------------------------------------------------------------------------------
(strcat ft-b "'-" in-d "''") ;answer
)
Solved! Go to Solution.