fopetesl Posted October 12, 2017 Share Posted October 12, 2017 (edited) 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 October 12, 2017 by fopetesl Added info The most powerful number in the Universe. Zero. Link to comment Share on other sites More sharing options...
mikell Posted October 12, 2017 Share Posted October 12, 2017 Strange.. you might try If Number($iCountry) = 44 Then fopetesl 1 Link to comment Share on other sites More sharing options...
fopetesl Posted October 13, 2017 Author Share Posted October 13, 2017 (edited) 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 October 13, 2017 by fopetesl Add code The most powerful number in the Universe. Zero. Link to comment Share on other sites More sharing options...
mikell Posted October 13, 2017 Share Posted October 13, 2017 Hmm it's not a matter of test, because all of the following work for me - reason why I found this strange 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 More sharing options...
fopetesl Posted October 14, 2017 Author Share Posted October 14, 2017 OK, can't argue with that logic. But where? How to debug? Odd thing is it DID work fine for some weeks. The most powerful number in the Universe. Zero. Link to comment Share on other sites More sharing options...
mikell Posted October 14, 2017 Share Posted October 14, 2017 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 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