Jump to content

Recommended Posts

Posted

Hi,

i was playing around au3check and was asking myself if its posible to ignore these lots of "$i already declared" warinings, but still checking if global variables are declared twice.

Its normal to have a few functions with Local $i declarations, so its not useful to show these warnings

Btw: -w3 is a parameter

  Quote
give a warning if variables are already declared
Expand  

Iam using

#AutoIt3Wrapper_Au3Check_Parameters=-q -w 1 -w 2 -w 3 -w 4 -w 6 -w 7

Posted (edited)
Usage: Au3Check [-q] [-d] [-u file] [-w[-] n].. [-v[-] n].. [-I dir].. file.au3
            -q      : quiet (only error/warn output)
            -d      : as Opt("MustDeclareVars", 1)
            -I dir  : additional directories for searching include files
            -U -|file : output unreferenced UDFs and global variables
            -w 1      : already included file (on)
            -w 2      : missing #comments-end (on)
            -w 3      : already declared var (off)
            -w 4      : local var used in global scope (off)
            -w 5      : local var declared but not used (off)
            -w 6      : warn when using Dim (off)
            -v 1      : show include paths/files (off)
            -v 2      : show lexer tokens (off)

 

Edited by Trong

Regards,
 

Posted

Do use Au3Check and don't skip the warnings, they are there for a reason.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

My english skills have to be really bad, when i get those answers -.-

Second try:

Au3check gives me  17 "$i already declared" warinings and every $i is declared as local. How can i ignore these warnings of local variables, but still get warnings when a global variable is declared twice.

Short version: No Local declared warnings but global declared warnings

 

Edited by Trolleule
  • Moderators
Posted

Trolleule,

If the $i variables are simple loop counters then there is no need to declare them - any For...To...Next counter is automatically Local.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)

Pls.

-w3 parameter doesn't differ between local and global variables. Its senseless to warn if local variables are declared twice cause you will have these every time in every script.

Its a general problem. See it as Au3Check request ...

Edited by Trolleule
Posted

If you don't post a reproducer, it's very difficult to understand what you are going on about. Au3Check may have some (trivial) limitations, but it sounds to me that your code is a mess. Having said that, we will never know if you don't post it. 

Posted (edited)

I mean there are local variables which have the same name and this is normal respectively its not wrong and shouldn't be reported by au3check.

Func 1
    Local $iCounter = 0
    For $i=0 to 10
        $iCounter+=1
    Next
EndFunc

Func 2
    Local $iCounter = 0
    For $i=0 to 10
        $iCounter+=1
    Next
EndFunc

How to ignore local variables reported.

Edited by Trolleule
Posted (edited)

That is incorrect AutoIt syntax. You cannot begin a function name with a digit and you were also missing the brackets. Now run this code through AU3Check.

; call each function in turn
_1()
_2()

Func _1()
    Local $iCounter = 0
    For $i=0 to 10
        $iCounter+=1
    Next
EndFunc

Func _2()
    Local $iCounter = 0
    For $i=0 to 10
        $iCounter+=1
    Next
EndFunc

 

Edited by czardas
Posted (edited)

But the code is only an example. Only want to know how to ignore  "$iCounter already declared" warinings?

Edited by Trolleule
Posted
  On 6/5/2016 at 11:20 PM, Trolleule said:

Its senseless to warn if local variables are declared twice cause you will have these every time in every script.

Expand  

I do not See any of this message in my UDF.

  On 6/6/2016 at 1:03 AM, Trolleule said:

But the code is only an example. Only want to know how to ignore  "$iCounter already declared" warinings?

Expand  

Did you try Czardas code ?

Do you saw this warnings in Czardas code ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Fix your code instead of insisting that the fix belongs to Au3Check.

Local variables declared more than once in the same scope are at least pointless and at worst pending or blatant bugs.

  Reveal hidden contents

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)

Posted

I never had troubles with Au3check so i wondered about your thread and tested the script from @czardas no errors, no warnings:

#AutoIt3Wrapper_Au3Check_Parameters=-q -w 1 -w 2 -w 3 -w 4 -w 6 -w 7

; call each function in turn
_1()
_2()

Func _1()
    Local $iCounter = 0
    For $i=0 to 10
        $iCounter+=1
        ConsoleWrite('_1 Counter: ' &$iCounter&@CRLF)
    Next
EndFunc

Func _2()
    Local $iCounter = 0
    For $i=0 to 10
        $iCounter+=1
        ConsoleWrite('_2 Counter: ' &$iCounter&@CRLF)
    Next
EndFunc

=> Console output:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Bert\AutoIt3.My\Temp\test2#.au3" /UserParams    
+>11:09:14 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0   Keyboard:00000407  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0407)
+>         SciTEDir => C:\Program Files\AutoIt3\SciTE   UserDir => C:\Users\Bert\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Bert\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.2)  params:-q -w 1 -w 2 -w 3 -w 4 -w 6 -w 7  from:C:\Program Files\AutoIt3  input:C:\Users\Bert\AutoIt3.My\Temp\test2#.au3
+>11:09:14 AU3Check ended.rc:0
>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "C:\Users\Bert\AutoIt3.My\Temp\test2#.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
_1 Counter: 1
_1 Counter: 2
_1 Counter: 3
_1 Counter: 4
_1 Counter: 5
_1 Counter: 6
_1 Counter: 7
_1 Counter: 8
_1 Counter: 9
_1 Counter: 10
_1 Counter: 11
_2 Counter: 1
_2 Counter: 2
_2 Counter: 3
_2 Counter: 4
_2 Counter: 5
_2 Counter: 6
_2 Counter: 7
_2 Counter: 8
_2 Counter: 9
_2 Counter: 10
_2 Counter: 11
+>11:09:15 AutoIt3.exe ended.rc:0
+>11:09:15 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.414

 

Posted

@Trolleule The problem here boils down to miscomprehension of variable scope, and how it is implemented in AutoIt. I suspect that all your local declarations are actually global variables because of where you declare them. In example code, you will often find global variables declared using the keyword Local. Don't be confused by this: these snippets are generally intended to be placed inside functions later, during further development. Firstly you need to make sure that the functions you write are using the correct syntax. Then most of the the errors you see will go away.

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
×
×
  • Create New...