Sign in to follow this  
Followers 0
ZebrasInBlankets

Number to Percent?

9 posts in this topic

Basically I want to make a number equal 100% and if that number lets say drops 20% then do something..

So,

$num = 1234

If $num < 80% Then Call("bob")

SOmething in that manner.. Is it possible and how would I do it?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It's a pretty basic math formula... (x / y ) * 100 = %

Edited by Ejoc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

$num = 345

$pct = 80

$oldnum = $num

; Do some stuff that changes the value of $num

If $num < $oldnum*$pct/100 Then

; Do something else

EndIf

Something like that?

EDIT: added the phrase "that changes the value of $num"

Edited by Smed

601DisengageEnd Program

Share this post


Link to post
Share on other sites

nope... test value is always the same as present value. If you need to know that its changed you must preserve the old value. The test you presented will always fail.


601DisengageEnd Program

Share this post


Link to post
Share on other sites

MsgBox will fire when $x is exactly 80, but I think you have the right idea now.


601DisengageEnd Program

Share this post


Link to post
Share on other sites

$baseline = 100; 100%
$threshold = ($baseline * .80); set threshold at 80%
if $baseline <= $threshold Then
; your code goes here   
EndIf


[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites

$baseline = 100; 100%
$threshold = ($baseline * .80); set threshold at 80%
if $baseline <= $threshold Then
; your code goes here    
EndIf

<{POST_SNAPBACK}>

I was going to tell you were correct, but you deleted your last post before i could.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I would:

;$x is the starting number
$x / .8 = $y

If $x < $y Then
;......
EndIf

At least something like that.

Edit: Nvm, thats a variable, lol...

Edited by gamerman2360

Share this post


Link to post
Share on other sites

I was going to tell you were correct, but you deleted your last post before i could.

<{POST_SNAPBACK}>

I had trouble following it that way...so i put it in terms I'm familiar with...

[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0