Sign in to follow this  
Followers 0
funkey

Bug in 'Static' (Not!)

9 posts in this topic

#1 ·  Posted (edited)

#include <GUIConstantsEx.au3>

Global $hGui = GUICreate("Test Bug 'Static'", 200, 60)

_Update()
_Update()
AdlibRegister("_Update", 1000)
GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Func _Update()
    Local Static $fBackup
    If $fBackup = "" Then
        ConsoleWrite("First call of '_Update()'" & @LF)
    Else
        ConsoleWrite($fBackup & @LF)
    EndIf
    Local $fValue = Random(1, 10, 1)
    $fBackup = $fValue
EndFunc

Edited by Melba23
Amended title

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites



What is the bug?


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)

Share this post


Link to post
Share on other sites

The bug is the variable loses it's static assigned value when you run that code.

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>

Global $hGui = GUICreate("Test Bug 'Static'", 200, 60)

_Update()
_Update()
AdlibRegister("_Update", 1000)
GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Func _Update()
    Local Static $fBackup = 0
    Local $fValue = 0
    If $fBackup = 0 Then
        ConsoleWrite("First call of '_Update()'" & @LF)
        $fValue = Random(1, 10, 1)
    Else
        ConsoleWrite($fBackup & @LF)
    EndIf
    $fValue = Random(1, 10, 1)
    $fBackup = $fValue
EndFunc

Bug present in 3.3.8.1

Bug not present in latest beta.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

 

Bug present in 3.3.8.1

Bug not present in latest beta.

 

Then I should really look forward to 3.3.10.2. But I'm afraid of false positives in company. Never had problems with 3.3.8.1


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

I don't get that! Release:

Running:(3.3.10.2):C:Program Files (x86)AutoIt3autoit3.exe

First call of '_Update()'
3
10
7
3

...

First call of '_Update()'
4
10
3

...

Ran dozen times and no bug appears here.

Same with beta:

Running:(3.3.11.4):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe


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)

Share this post


Link to post
Share on other sites

@jchd: It's already fixed in latest stable.

Sorry for not searching enough before posting. >_<


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Ah, I was experimenting with x64 vs x86, various delays, Sleep between inline invokations, etc but to no avail. Latest release and latest beta indeed seem to work as intended. No harm done, glad it's a false alarm.


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)

Share this post


Link to post
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
Sign in to follow this  
Followers 0