Modify

Opened 3 weeks ago

Closed 3 weeks ago

#4066 closed Bug (Fixed)

OnAutoItStartRegister Example fails

Reported by: donnyh13 Owned by: Jpm
Milestone: 3.3.19.0 Component: AutoIt
Version: 3.3.18.0 Severity: None
Keywords: Cc:

Description

The help file for OnAutoItStartRegister states:

As the function runs before any of the main script code is executed, the function cannot reference any variables defined in an #include nor any variables defined as Global within the script. All variables within the function are treated as Local.

Yet the example for OnAutoItStartRegister does this very thing,

#include <MsgBoxConstants.au3>

; Register Example() and SomeFunc() to be called when AutoIt starts.

#OnAutoItStartRegister "Example"
#OnAutoItStartRegister "SomeFunc"

Sleep(1000)

Func Example()
        MsgBox($MB_SYSTEMMODAL, "", "Function 'Example' is called first.")
EndFunc   ;==>Example

Func SomeFunc()
        MsgBox($MB_SYSTEMMODAL, "", "Function 'SomeFunc' is called second.")
EndFunc   ;==>SomeFunc

MsgBox($MB_SYSTEMMODAL,

Of course the example fails with:

"C:\Program Files (x86)\AutoIt3\Examples\Helpfile\OnAutoItStartRegister.au3" (11) : ==> Variable used without being declared.:
MsgBox($MB_SYSTEMMODAL, "", "Function 'Example' is called first.")
MsgBox( ERROR

Attachments (0)

Change History (3)

comment:1 Changed 3 weeks ago by pixelsearch

Nice catch donnyh13 . For the record, it worked fine a few years ago, this is what happened :

  • AutoIt version 3.3.14.2 (released in 2015)

Everything was correct because examples for OnAutoItStartRegister and OnAutoItExitRegister were different :
OnAutoItStartRegister => MsgBox(4096, ...)
OnAutoItExitRegister => MsgBox($MB_SYSTEMMODAL, ...)

  • AutoIt version 3.3.14.3 (released in 2018)

An incorrect change was made in the help file (maybe to get rid of magic numbers ?) resulting in :
OnAutoItStartRegister => MsgBox($MB_SYSTEMMODAL, ...)
OnAutoItExitRegister => MsgBox($MB_SYSTEMMODAL, ...)

comment:2 Changed 3 weeks ago by donnyh13

Interesting, thanks for the research pixelsearch! Yes, before I posted I actually hit a bug report that reported the same function for having magic numbers (12 years ago), but jpm caught it that it couldn't have #Includes, so it was changed to documentation changes only.

comment:3 Changed 3 weeks ago by Jpm

  • Milestone set to 3.3.19.0
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [13261] in version: 3.3.19.0

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.