Jump to content

If and While won't work!


Recommended Posts

Solved

I 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
   EndIF

When 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 by Reeling
Link to comment
Share on other sites

#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 by ApudAngelorum
Link to comment
Share on other sites

While $diff > "0"

You are comparing a number and a string.

how can i fix it? im pretty new.

@ApudAngelorum

The $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 by Reeling
Link to comment
Share on other sites

"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 here
RegExp tutorial: enough to get started
PCRE 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

"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 by Reeling
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...