Jump to content
Sign in to follow this  
BrainSurgery

Operator help

Recommended Posts

So here I am with my first post and I know its something so simple I am going to regret asking :">

Starting off with $Runs at 0 and $SetRuns at 10 everything works fine until $Runs hits 2. At this point the second case is always selected and it does not matter what number between 2 and 10 is used.

I have the feeling I might be using the Operators incorrectly but to my eyes it looks ok...

Thank you in advance!

CODE

Func RunCheck()

$Runs = IniRead(@SCRIPTDIR & "\Config.ini", "MAIN", "Runs", "")

Sleep(1000)

$SetRuns = IniRead(@SCRIPTDIR & "\Config.ini", "MAIN", "SetRuns", "")

Sleep(1000)

Select

Case $SetRuns > $Runs

$Runs += 1

IniWrite(@SCRIPTDIR & "\Config.ini", "MAIN", "Runs", $Runs )

LogEvent(1, "Not yet time")

Sleep(1000)

Exit

Case $SetRuns = $Runs Or $Runs > $SetRuns

$Runs = 0

IniWrite(@SCRIPTDIR & "\Config.ini", "MAIN", "Runs", $Runs )

LogEvent(1, "Starting up!")

Sleep(1000)

Case Else

LogEvent(1, "Runs or SetRuns not specified!! Setting both to default!!")

IniWrite(@SCRIPTDIR & "\Config.ini", "MAIN", "Runs", 0 )

IniWrite(@SCRIPTDIR & "\Config.ini", "MAIN", "SetRuns", 10 )

EndSelect

EndFunc

Share this post


Link to post
Share on other sites

Well your ini must be wrong somehow

$Runs = 2
$SetRuns = 10

Select
    Case $SetRuns > $Runs
        MsgBox(0,0,"1 case")
        Exit
    Case $SetRuns = $Runs Or $Runs > $SetRuns
        MsgBox(0,0,"2 case")
    Case Else
        MsgBox(0,0,"3 case")
EndSelect

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

I think i got it.. When you read from an INI the var is treatet like a string not a number and "2" > "10" but 2 < 10

So you have to convert the string to a number


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

And the solution is

Func RunCheck()

$Runs = IniRead(@SCRIPTDIR & "\Config.ini", "MAIN", "Runs", "")
$Runs = Int($Runs)
Sleep(1000)
$SetRuns = IniRead(@SCRIPTDIR & "\Config.ini", "MAIN", "SetRuns", "")
$SetRuns = Int($SetRuns)
Sleep(1000)

Select
Case $SetRuns > $Runs
$Runs += 1
IniWrite(@SCRIPTDIR & "\Config.ini", "MAIN", "Runs", $Runs )
LogEvent(1, "Not yet time")
Sleep(1000)
Exit
Case $SetRuns = $Runs Or $Runs > $SetRuns
$Runs = 0
IniWrite(@SCRIPTDIR & "\Config.ini", "MAIN", "Runs", $Runs )
LogEvent(1, "Starting up!")
Sleep(1000)
Case Else
LogEvent(1, "Runs or SetRuns not specified!! Setting both to default!!")
IniWrite(@SCRIPTDIR & "\Config.ini", "MAIN", "Runs", 0 )
IniWrite(@SCRIPTDIR & "\Config.ini", "MAIN", "SetRuns", 10 )
EndSelect
EndFunc

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...