Calculating Ratios

stokefc22

Member
Hi can someone help with a query I have please...

I'm want to calculate a ratio but not sure if there is a function or method to do it??

e.g. I have a set up time of 30 minutes and run time of 10 minutes.

This would be 30:10... that's no problem.

But ideally I want it to read 3:1.

Finally i also need to handle the eventuality of odd numbers etc...

Thanks in advance
 

stokefc22

Member
OK maybe I was a bit hasty posting this...

I've come up with this, maybe a bit crude so if anyone has a better idea it would be much appreciated.

define variable intSetup as integer no-undo initial 9.
define variable intRun as integer no-undo initial 24.
define variable intDivBy as integer no-undo.
define variable chrRatio as character no-undo.

assign intDivBy = intStrt.

ratioLoop:
repeat:
if intStrt modulo intDivBy > 0 or
intEnd modulo intDivBy > 0 then
assign intDivBy = intDivBy - 1.
else
do:
assign chrRatio = string(intStrt / intDivBy) + ":":u + string(intEnd / intDivBy).
leave ratioLoop.
end.
end.
 
Top