Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Rise Over Run Returns 0

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
kpennell
320 Views, 3 Replies

Rise Over Run Returns 0

I'm prompting the user for a string to represent an angle.

 

(setq second_angle (getstring "\nWhat angle is the turned pipe sloping? "))

 

Then, depending on the slash location via:

 

(setq slashloc (vl-string-position (ascii "/") second_angle))

 

Getting the rise:

 

(setq rise (atoi (substr second_angle 1 slashloc)))

 

And the run:

 

(setq run (atoi (substr second_angle (+ 2 slashloc))))

 

Then do the rise/run calculation I get 0.0 returned:

 

(/ rise run)

 

So for a rise/run for 1/48, I should/want to have returned is the exact value that I can assign for later use, 1.193489424.

 

Stumped

 

KP

3 REPLIES 3
Message 2 of 4
Ajilal.Vijayan
in reply to: kpennell

I think you need to Convert the string into a real number

 

use atof instead of atoi.

Message 3 of 4
Kent1Cooper
in reply to: kpennell

When you divide an integer by an integer with the (/) function, you get an integer result.  At least one of them needs to be a real number instead.  Try using (atof) in place of (atoi).

Kent Cooper, AIA
Message 4 of 4
stevor
in reply to: kpennell

To use your code anyway, add the 'real' then try:

  (/ rise run  1.0)

S

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost