WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Number Conversion

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

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
File Created: 1999:10:05:10:50:00
Last Updated: 1999:10:05:10:50:00