BrainSurgery Posted February 22, 2007 Posted February 22, 2007 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
Shevilie Posted February 22, 2007 Posted February 22, 2007 $SetRuns = $Runs I would use == Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
BrainSurgery Posted February 22, 2007 Author Posted February 22, 2007 $SetRuns == $Runs Did not think of that because I was not comparing strings but still it does not work. Thanks for the reply
Shevilie Posted February 22, 2007 Posted February 22, 2007 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
Shevilie Posted February 22, 2007 Posted February 22, 2007 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
Shevilie Posted February 22, 2007 Posted February 22, 2007 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
BrainSurgery Posted February 22, 2007 Author Posted February 22, 2007 Yep that solved the problem!!! Thanks!! I did not know that reading from the ini file the values were treated as "strings"...... Thanks again!!
Shevilie Posted February 22, 2007 Posted February 22, 2007 Np (Neither did I ) Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now