Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3521 closed Bug (No Bug)

Au3Check is not able to recognize Global variables declared inside functions if the variables are used above the function declaration

Reported by: TheDcoder Owned by:
Milestone: Component: Au3Check
Version: 3.3.14.1 Severity: None
Keywords: Cc: Jos

Description

Au3Check is not able to recognise Global variables declared inside functions if the variables are used above the function declaration.

Here is an example script which demonstrates this:

CreateVariable()

ConsoleWrite($sGlobalVariable & @CRLF)

Func CreateVariable()
	Global $sGlobalVariable = "Foobar"
EndFunc

Au3Check throws a nasty warning if you run the code above:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3" /UserParams    
+>16:28:48 Starting AutoIt3Wrapper v.16.306.1237.0 SciTE v.3.6.2.0   Keyboard:00000409  OS:WIN_81/  CPU:X64 OS:X64  Environment(Language:0809)  CodePage:0  utf8.auto.check:4    # detect ascii high characters and if none found set default encoding to UTF8 and do not add BOM
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\TheDcoder\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\TheDcoder\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.1)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(3,31) : warning: $sGlobalVariable: possibly used before declaration.
ConsoleWrite($sGlobalVariable &
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3 - 0 error(s), 1 warning(s)
->16:28:48 AU3Check ended. Press F4 to jump to next error.rc:1
>Running:(3.3.14.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
Foobar
+>16:28:48 AutoIt3.exe ended.rc:0
+>16:28:48 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 0.9746

Change History (5)

comment:1 Changed 9 years ago by BrewManNH

  • Resolution set to No Bug
  • Status changed from new to closed

This isn't a bug but poor programming.
Au3Check reads the script line by line from the first line to the last. It doesn't execute the script. Because you're trying to access a global variable that hasn't been declared yet (at that point in the script read), you get an error.

comment:2 follow-up: Changed 9 years ago by TheDcoder <TheDcoder@…>

I know that it is not unintentional but Au3Check should be able to detect such situations... There are times when you have to declare Global variables inside functions, something like GUI_CreateMainWindow.

comment:3 in reply to: ↑ 2 ; follow-up: Changed 9 years ago by mLipok

Replying to TheDcoder <TheDcoder@…>:

I know that it is not unintentional but Au3Check should be able to detect such situations... There are times when you have to declare Global variables inside functions, something like GUI_CreateMainWindow.

Show example on the forum, and there we can discuss

comment:4 in reply to: ↑ 3 Changed 9 years ago by TheDcoder <TheDcoder@…>

Replying to mLipok:

Replying to TheDcoder <TheDcoder@…>:

I know that it is not unintentional but Au3Check should be able to detect such situations... There are times when you have to declare Global variables inside functions, something like GUI_CreateMainWindow.

Show example on the forum, and there we can discuss

I will create a thread about this on the forum and will post a link in the ticket, Thanks for the suggestion :)

comment:5 Changed 9 years ago by TheDcoder <TheDcoder@…>

I have created a thread on the forum, please use that for discussion :)

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

Author


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

 
Note: See TracTickets for help on using tickets.