Reeling Posted April 27, 2012 Share Posted April 27, 2012 (edited) SolvedI have a script i'm trying to make. Problem is this one If and While statement won't work and for the life of me I can't figure out why. Maybe you guys can see something I'm not.Here it is:#include <Date.au3> $test1 = "10" $test2 = "6" $diff = "10" Global $seconds = @SEC Global $minutes = @MIN Global $hours = @HOUR Global $day = @MDAY Global $month = @MON Global $year = @YEAR Assign( "start", $year&"/"&$month&"/"&$day&" "&$hours&":"&$minutes&":"&$seconds&"") Assign( "end", $year&"/"&$month&"/"&$day&" "&$hours + 3&":"&$minutes&":"&$seconds&"") Global $diff = _DateDiff('n', $start, $end) If $test1 > $test2 Then While $diff > "0" Tooltip($diff & ":" & $seconds, 1400, 500) sleep(1000) MsgBox(0, "t", $diff) WEnd EndIFWhen I run this nothing pops up, no msg box no nothing. I tried putting a msg box before the "if" statement to make sure the $diff variable was working, and it is. Edited April 27, 2012 by Reeling Link to comment Share on other sites More sharing options...
Skitty Posted April 27, 2012 Share Posted April 27, 2012 (edited) #include <Date.au3> $test1 = 10 $test2 = 6 $diff = 10 Global $seconds = @SEC Global $minutes = @MIN Global $hours = @HOUR Global $day = @MDAY Global $month = @MON Global $year = @YEAR Global $start = $year&"/"&$month&"/"&$day&" "&$hours&":"&$minutes&":"&$seconds Global $end = $year&"/"&$month&"/"&$day&" "&$hours + 3&":"&$minutes&":"&$seconds Global $diff = _DateDiff('n', $start, $end) If $test1 > $test2 Then While $diff > 0 Tooltip($diff & ":" & $seconds, 1400, 500) sleep(1000) MsgBox(0, "t", $diff) WEnd EndIF Try to avoid making comparisons of numbers in string format for one. Edited April 27, 2012 by ApudAngelorum Link to comment Share on other sites More sharing options...
tsolrm Posted April 27, 2012 Share Posted April 27, 2012 (edited) While $diff > "0" You are comparing a number and a string. Edited April 27, 2012 by tsolrm Link to comment Share on other sites More sharing options...
Reeling Posted April 27, 2012 Author Share Posted April 27, 2012 (edited) While $diff > "0"You are comparing a number and a string.how can i fix it? im pretty new.@ApudAngelorumThe $test1 and $test2 variables aren't always going to be static, they will be variables that are changing so is there a different way I can compare them, considering that fact? Edited April 27, 2012 by Reeling Link to comment Share on other sites More sharing options...
jchd Posted April 27, 2012 Share Posted April 27, 2012 "0" is a string, 0 is a number. There's a pretty strong difference. Being new means you should spend reasonable time reading the help file. Datatypes, Variables, and such are fundamental basics. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Reeling Posted April 27, 2012 Author Share Posted April 27, 2012 (edited) "0" is a string, 0 is a number. There's a pretty strong difference. Being new means you should spend reasonable time reading the help file. Datatypes, Variables, and such are fundamental basics. That's what I thought but low and behold, this still doesn't work. #include <Date.au3> $test1 = "10" $test2 = "6" $diff = "10" $var0 = 0 Global $seconds = @SEC Global $minutes = @MIN Global $hours = @HOUR Global $day = @MDAY Global $month = @MON Global $year = @YEAR Assign( "start", $year&"/"&$month&"/"&$day&" "&$hours&":"&$minutes&":"&$seconds&"") Assign( "end", $year&"/"&$month&"/"&$day&" "&$hours + 3&":"&$minutes&":"&$seconds&"") Global $diff = _DateDiff('n', $start, $end) If 10 > 6 Then While $diff > 0 Tooltip($diff & ":" & $seconds, 1400, 500) sleep(1000) MsgBox(0, "t", $diff) WEnd EndIF Ideas? Edit: +3 hours takes me in to the next day so it bugs out and sets $diff to 0, anyway to fix this? Edit 2: solved, thanks for help Edited April 27, 2012 by Reeling Link to comment Share on other sites More sharing options...
Skitty Posted April 27, 2012 Share Posted April 27, 2012 Pff, Ignore my previous stupidity, what's wrong is that you're doing the date diff function wrong, also we just told you not to make comparisons with strings and numbers! Link to comment Share on other sites More sharing options...
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