Jump to content

Need help understanding why this fails


Recommended Posts

I must be missing something fundamental to how AutoIt works as I cannot see why the following code does not work:

#include <array.au3>

Global Const $__DP_Version[4] = [ '0.10', 1, 10, '2007/01/03' ]
Global Enum _; indexes into __DP_Version array
        $__DP_VersionString = 0, _
        $__DP_VersionMajor, _
        $__DP_VersionMinor, _
        $__DP_VersionDate

_ArrayDisplay( $__DP_Version, "__DP_Version" )

;;; Both of the following tests should generate message boxes, but neither do

If $__DP_Version[ $__DP_VersionMajor ] <> 3 Then MsgBox ( 0 , "Major", "not 3" )
If $__DP_Version[ $__DP_VersionMinor ] <> 15 Then MsgBox ( 0 , "Minor", "not 15" )

Okay, what really makes this fustrating is that the above code works sometimes meaning I may get the first message box but not the second, or maybe I'll get the second message box but not the first, but most often I get neither. Thinking it was a problem with my development environment I shut everything down, cleaned out the temp folders, rebooted, etc and nope - still have the same problem with inconsistent results, so either I found a bug in AutoIt or I'm missing something in the snippet above.

Compiling against AutoIt 3.2.2.0 and AutoItSciTE4 dated 12/31/2006.

This is driving me bonkers :P

Thanks ~

Link to comment
Share on other sites

Bummer. Even on my home machine its flaky. I thought maybe it could be the mixing of intristic types in the array so I changed:

Global $__DP_Version[4] = [ '0.10', 5, 10, '2007/01/03' ]oÝ÷ Ù:ºÚ"µÍÛØ[    ÌÍ××ÑÕÚ[ÛÍHHÈ ÌÎNÌL    ÌÎNË ÌÎNÍIÌÎNË ÌÎNÌL    ÌÎNË ÌÎNÌ
ËÌKÌÉÌÎNÈ

but that didn't result in any changes for me. How weird.

Link to comment
Share on other sites

What happens if you rewrite your code slightly?

#include <array.au3>

Global Const $__DP_Version[4] = [ '0.10', 1, 10, '2007/01/03' ]
Global Enum _; indexes into __DP_Version array
        $__DP_VersionString = 0, _
        $__DP_VersionMajor, _
        $__DP_VersionMinor, _
        $__DP_VersionDate

;_ArrayDisplay( $__DP_Version, "__DP_Version" )

;;; Both of the following tests should generate message boxes, but neither do
Local $i, $j, $k, $max = 100
For $i = 1 to $max 
   If $__DP_Version[ $__DP_VersionMajor ] <> 3 Then $j += 1 ;ConsoleWrite("+++Major not 3" & @LF);MsgBox ( 0 , "Major", "not 3" )
   If $__DP_Version[ $__DP_VersionMinor ] <> 15 Then $k += 1 ;ConsoleWrite("---Minor not 15" & @LF);MsgBox ( 0 , "Minor", "not 15" )
Next
; No flaky behavior on my machine..:)
Assert($j=$max, "$j:=" & $j & " <> " & $max)
Assert($k=$max, "$k:=" & $j & " <> " & $max)
Exit 
Func Assert($bool, $msg="", $erl=@ScriptLineNumber)
   If not $bool Then 
      ConsoleWrite("(" & $erl & ") := " & $msg & @LF)
   EndIf 
EndFunc

Also note that you can sometimes get "flaky" behavior when you compare a string and a number (even if you think it's a number) But I don't think that is the case here.

Link to comment
Share on other sites

I added the additional logging and it failed in the same way.

This morning I uninstalled all of the AutoIt and SciTE bits from my machine and manually went through to clear out its directories, temp folders, etc again and reinstalled. Now its working as expected and I cannot make it fail. Wish I knew what the problem was but am just glad its gone now and I can move on.

Thanks everyone!

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