Jump to content
Sign in to follow this  
Generator

_Mod Problem

Recommended Posts

Generator

I came across this and i thought this would work, but it didn't =O. :)

Any idea what's wrong

Global $Number=5
If _Mod() Then
    MsgBox(64,"","Success")
Else
    MsgBox(64,"","Failed")
EndIf
Func _Mod()
    Local $Round
    If IsInt(Round($Round=$Number/2)) Then
        Return True
    Else
        Return False
    EndIf
EndFunc

Edit: A simple math question, thanks in advance.

Edited by Generator

Share this post


Link to post
Share on other sites
JustinReno

it looks like the math function shouldnt have been in a func:endfunc sorta thing, and the func wasnt on ( _mod() ). not sure if i made sense...lol

Share this post


Link to post
Share on other sites
Generator

Well i was looking for if a number is divisible by another number, but now i found the udf and problem solved.

Share this post


Link to post
Share on other sites
enaiman

I wonder if you clicked my link ... because that is NOT an UDF but a function already implemented in AutoIt and it does the same thing you're looking for.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Generator

I wonder if you clicked my link ... because that is NOT an UDF but a function already implemented in AutoIt and it does the same thing you're looking for.

I did look at your link but then round wouldn't work. It rounds up not round to decimal.

Share this post


Link to post
Share on other sites
enaiman

I'm confused why would you need Round?

If the result of Mod is 0 then the first number is divisible by the second.

Global $Number=5
If Mod($Number, 2) = 0 Then
    MsgBox(64,"","Success")
Else
    MsgBox(64,"","Failed")
EndIf

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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  

×