Determine Percentage
Keywords: determine percentage calculate percent
Question:
Num1= "10.5"
Num2 = "12.3"
Being new to Winbatch, how can I code this to calulate the percentage diffences between Num1 and Num2 and also
return an error if the percentage is higher then 1%? Thanks.
Answer:
Num1= 10.5
Num2 = 12.3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Calulate the percentage diffences between Num1 and Num2
;and also return an message if the percentage is higher then 1%?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff= num2 - num1
percentdiff= (diff / num1) * 100
Message("Percent Difference",percentdiff)
if percentdiff > 1.0
Message("Eeek.","Percent Difference more than 1.0%%")
endif
Here's another script that calculates percentage.
;Set Decimal
Decimals(1)
;determine percentage
val1=askline("Determine percentage","Please enter first value","0")
val2=askline("Determine percentage","Please enter second value","0")
;Make floating point
fval1=val1*1.0
fval2=val2*1.0
percent=fval1/fval2 * 100.0
message("Result of percentage","%val1% is %percent% %% of %val2%")
Article ID: W14148
Filename: Determine Percentage.txt