Jump to content

Equality test fails


 Share

Recommended Posts

I need to check country to obtain correct date format to check file date

Local $tImeStamp = FileGetTime("baseline.dta",0,0)
             Local $NowDate = StringSplit(_NowDate(),"/")
             Local $iCountry = RegRead("HKEY_CURRENT_USER\Control Panel\International", "iCountry")
             MsgBox("","Country ", $iCountry)
;             MsgBox($MB_SYSTEMMODAL, "Dates Check"," Baseline: " & $tImeStamp[2] & "/" & $tImeStamp[1] & "/" & $tImeStamp[0] & @CRLF _
;                                                  & "       Now: " & $NowDate[1] & "/" & $NowDate[2]   & "/" & $NowDate[3])
; Exit ;<<<<<<<<<<<<<<<<< !!!!!!!!!! <<<<<<<<<<<
             Local $DateCheck = True
             If( $iCountry = 44) Then
               If( $tImeStamp[2] <> $NowDate[1] Or $tImeStamp[1] <> $NowDate[2] Or $tImeStamp[0] <> $NowDate[3]) Then
                 $DateCheck = False
             MsgBox($MB_SYSTEMMODAL, "Dates 44 Check"," Baseline: " & $tImeStamp[2] & "/" & $tImeStamp[1] & "/" & $tImeStamp[0] & @CRLF _
                                                  & "       Now: " & $NowDate[1] & "/" & $NowDate[2]   & "/" & $NowDate[3] & " > " & $iCountry)
 Exit ;<<<<<<<<<<<< //////////// <<<<<<<<<<<<
               ElseIf( $tImeStamp[2] <> $NowDate[2] Or $tImeStamp[1] <> $NowDate[1] Or $tImeStamp[0] <> $NowDate[3]) Then
                 $DateCheck = False
             MsgBox($MB_SYSTEMMODAL, "Dates !44 Check"," Baseline: " & $tImeStamp[2] & "/" & $tImeStamp[1] & "/" & $tImeStamp[0] & @CRLF _
                                                  & "       Now: " & $NowDate[2] & "/" & $NowDate[2]   & "/" & $NowDate[3] & " > " & $iCountry)
 Exit ;<<<<<<<<<<<< //////////// <<<<<<<<<<<<
               EndIf
             EndIf

At one point the code worked as expected now it always fails even though REG_SZ $iCountry does equal 44.  I've tried '==' though it shouldn't be significant in this case.

I should have said the date/time comparisons do work as expected it's the "If( $iCountry = 44)" test which fails.

Edited by fopetesl
Added info

The most powerful number in the Universe.  Zero.

Link to comment
Share on other sites

AH! That works! Something else learned that variables assume not a number unless cast?

Thanks, mikell

Oh NO!! Now it fails! It worked but only once so I'm back where I started. And it fails repeatedly.

Even if I force cast to number:

Local $Country = Number( RegRead("HKEY_CURRENT_USER\Control Panel\International", "iCountry"))
 ;            MsgBox("","Country ", $Country)
;             MsgBox($MB_SYSTEMMODAL, "Dates Check"," Baseline: " & $tImeStamp[2] & "/" & $tImeStamp[1] & "/" & $tImeStamp[0] & @CRLF _
;                                                  & "       Now: " & $NowDate[1] & "/" & $NowDate[2]   & "/" & $NowDate[3])
; Exit ;<<<<<<<<<<<<<<<<< !!!!!!!!!! <<<<<<<<<<<
             Local $DateCheck = True
             If Number( $Country) = 44 Then

the test still fails.

Edited by fopetesl
Add code

The most powerful number in the Universe.  Zero.

Link to comment
Share on other sites

Hmm it's not a matter of test, because all of the following work for me - reason why I found this strange  :blink:
The issue should come from somewhere else...

Local $iCountry = RegRead("HKEY_CURRENT_USER\Control Panel\International", "iCountry")
; MsgBox("","Country ", $iCountry)
; all these work !
;If( $iCountry = 33) Then
;If Number($iCountry) = 33 Then
;If $iCountry == "33" Then
If $iCountry = 33 Then
   MsgBox("","Country ", $iCountry)
EndIf

 

Link to comment
Share on other sites

If it fails when you run it repeatedly, the first thing to try could be this

For $i = 1 to 50
  Local $iCountry
  $iCountry = RegRead("HKEY_CURRENT_USER\Control Panel\International", "iCountry")
  ConsoleWrite("try #" & $i & " : $iCountry = " & $iCountry )
  If $iCountry = 44 Then
      ConsoleWrite(" : success"& @crlf)
  Else
      ConsoleWrite(" : failed"& @crlf)
  EndIf
Next

 

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...