Jump to content

Recommended Posts

Posted

Hi,

a question about Au3Check-warnings:

I've enabled " -w 5" (local var declared but not used) and during compilation I get two warnings:

 

>Running AU3Check (3.3.15.1)  params:-w 3 -w 4 -w 5  from:C:\Program Files (x86)\AutoIt3  input:E:\AutoIT_src\webSiteUpdater_stripped.au3
"E:\AutoIT_src\webSiteUpdater_stripped.au3"(4684,56) : warning: $ex: declared, but not used in func.
Local $intFileIndex, $strFileIndex, $bEnabled, $ec, $ex,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"E:\AutoIT_src\webSiteUpdater_stripped.au3"(5470,13) : warning: $arrIn: declared, but not used in func.
Local $arrIn,
~~~~~~~~~~~~^
E:\AutoIT_src\webSiteUpdater_stripped.au3 - 0 error(s), 2 warning(s)
->19:12:06 AU3Check ended. Press F4 to jump to next error.rc:1

The referenced funcions are:

Func _processSection($strSection, $bForce = False)
    ...
    Local $intFileIndex, $strFileIndex, $bEnabled, $ec, $ex, $hInetGet, $arrInetInfo, $intPercent, $bDwnlOK, $strUrlPattern, $intUrlIndex
    ...
        $ec = 0
        $ex = 0

        $ret = StringRegExp($strOutFile, $strUpdatePattern, $intRegExpType)
        $ec = @error
        $ex = @extended
    ...
EndFunc

Func _sortSections()
    Local $arrIn, $strTemp, $arrSorted, $arrOut[1], $i, $j, $arrCurSect, $intRet, $strColSep
    ...
    $arrIn = FileReadToArray($strIniFile)
    ...
EndFunc

Is this a problem of AU3check or a problem in coding? It doesn't affect the compiling, the exe is running, but the warning is a litte bit confusing - I think, both vars are used in the code!?

Thank you very much

kara

 

  • Developers
Posted (edited)

$ex it's value is nowhere used in the func, but you only set it's value, so the variable is unused....right?
To use a variable, you need to have it on the right side of the = in a formula ($x = $ex)  or in any function  ($x=func($ex)).

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)

Hmm, in your code snippet the local variable $ex is declared and a value is assigned to it. The warning: $ex: declared, but not used in func. should not show up.

My fault. The warning is correct, because assigning a value is not the same as 'in use' of course. I guess I was a little unfocused :mad2:

 

Local ..., $ex, ...
    $ex = 0
    
    ; USE IT :
    ConsoleWrite($ex & @CRLF)
45 minutes ago, kara2004 said:

It doesn't affect the compiling, the exe is running

That's why it's called a warning, not an error ;).

Edited by Musashi
Posted

That's it: a variable is only used when it's part of a RHS (Right Hand Side) of an assignment or of a function invokation.

It's like you write down a phone number and then discard that note.  The number was not used.  On the contrary, if you pass the note to a friend, you can regard that as a use: you've passed that information outside your environment.

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

Just a misunderstanding of "using variables": $ex was set, but instead of using it, I used @extended a few lines later and $arrIn was just used for counting the lines (via @extended - same as _FileCountLines)

Correctded the code and the warnings are gone...

Thanks to all for your responses

 

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