Jump to content

Au3Check.exe


tylo
 Share

Recommended Posts

And another Au3Check update:

1.21 : added: command line option -d, which checks as Opt("MustDeclareVars", 1).

:idiot:

<{POST_SNAPBACK}>

Awesome. This will be nice.

JdeB, this needs to be run on all the standard library files. I ran it on Date.au3 just to see and I got two results still remaining.

Link to comment
Share on other sites

  • Developers

And another Au3Check update:

1.21 : added: command line option -d, which checks as Opt("MustDeclareVars", 1).

:idiot:

<{POST_SNAPBACK}>

Great .. thats save a lot of time searching for them !!!

I am only wondering how i should implement this is SciTE since lots of people don't predefine their vars and its now either on or off.

Could it be done in a way that au3check only checks if the Opt("MustDeclareVars", 1) is defined in the script ?

JdeB, this needs to be run on all the standard library files.  I ran it on Date.au3 just to see and I got two results still remaining.

<{POST_SNAPBACK}>

Scanned all UDF libs, fixed and submitted to Jon.

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

Link to comment
Share on other sites

Great .. thats save a lot of time searching for them !!!

I am only wondering how i should implement this is SciTE since lots of people don't  predefine their vars and its now either on or off.

Could it be done in a way that au3check only checks if the Opt("MustDeclareVars", 1) is defined in the script ?

Scanned all UDF libs, fixed and submitted to Jon.

<{POST_SNAPBACK}>

I though about that, but there are some small issues with it. It can implemented fairly easy, but:

1. Opt("MustDeclareVars", 1) must be on top of the file, as au3check works lineary through the file (does not follow execution sequence). Incidently, most people does put these statements on top (as is recomended and most practical).

2. Both arguments to Opt() must be literals, i.e. "MustDeclareVars" and 0 or 1. If variables are used, the Opt statement will be ignored by Au3Check.

If I do it, it will do declaration checking by default if it sees an Opt("MustDeclareVars", 1) statement.

blub

Link to comment
Share on other sites

  • Developers

I though about that, but there are some small issues with it. It can implemented fairly easy, but:

1. Opt("MustDeclareVars", 1) must be on top of the file, as au3check works lineary through the file (does not follow execution sequence). Incidently, most people does put these statements on top (as is recomended and most practical).

2. Both arguments to Opt() must be literals, i.e. "MustDeclareVars" and 0 or 1.  If variables are used, the Opt statement will be ignored by Au3Check.

If I do it, it will do declaration checking by default if it sees an Opt("MustDeclareVars", 1) statement.

<{POST_SNAPBACK}>

I would think that both will be commonly used in the way you describe by people using AutoItSetOption("MustDeclareVars", 1) or Opt("MustDeclareVars", 1).

It would really make live alot easier with SciTE Ctrl+F5 but also for the CompileAU3 wrapper!

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

Link to comment
Share on other sites

  • Developers

Au3Check 1.22

- enable/disable variable declaration check on Opt/AutoItSetOption("MustDeclareVars", 1/0).

See notes in previous post on the minor limitations.

Cheers.

<{POST_SNAPBACK}>

Thanks Tylo !!!

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

Link to comment
Share on other sites

For those very fast ones, like JdeB, download 1.22 again. I found that I didn't check loop variables used in the For-Next structure. (should have increased version...).

Edited by tylo

blub

Link to comment
Share on other sites

And, v1.23 ...

- fixed: didn't check declaration of counter var in For-loop. (1.22 did this, but wrongly).

Note that it also issues a warning if a For-loop uses a global counter within a function!

Edited by tylo

blub

Link to comment
Share on other sites

I got a little pb with multiple inclusions...

Note that I use the directive #include-once

Here is a sample to reproduce my pb:

I made a library (in the sample, Test_include2.au3) that includes string resources, declared as Global Const (see Test_Resources.au3).

Then I made a little prog that includes this library AND also uses the already defined resources file (here Test_include.au3).

I know this sample is not the best, but let's imagine you use a large and centralized string resources file or libraries.

Launching the main script (Test_include.au3), I get the following error message:

AutoIt3 Syntax Checker v1.23  Copyright (c) Tylo, 2005

F:\Scripts\QA\.\Test_resources.au3(3,40) : ERROR: $sTEST was previously declared as a Const
Global Const $sTEST = "sTEST included!"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\Scripts\QA\.\Test_resources.au3(4,60) : ERROR: $sANOTHER_STRING was previously declared as a Const
Global Const $sANOTHER_STRING = "sANOTHER_STRING included!"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\Scripts\QA\Test_include.au3 - 2 error(s), 0 warning(s)

Process completed, Exit Code 2.

You can easily notice where the pb is: the inclusion test for AU3Check seems to be related to the litteral path as written in the include directive : .\Test_resources.au3.

And indeed, I wrote in Test_include2.au3:

#include <.\Test_resources.au3>

whereas I wrote in Test_include.au3:

#include <Test_resources.au3>

This is annoying if you work with different projects and directories as (for instance) in the main script it seems natural to write a local path to include file (<mylib.au3>) but in others you'll have to write a relative path (<..\mainscriptdir\mylib.au3>).

Tylo, is there something you can do for this? :idiot:

Thanks a lot for what you've already done: your tool is a great one, so usefull to me! :D

Edit: Forgot to had that if these resources are specified as Global only (not Const), there is no error message, having a behavior I agree with...

Include_Pb.zip

Edited by LazyCoder
A good program computing A into B is mostly one that won't crash in all the other cases...
Link to comment
Share on other sites

I guess there is. I need a Win32 function GetAbsolutePath(currentDir, relativePath) or GetCanonicalPath() or something. I don't know whether there is one, but it can be written - I think even I saw someone write such a func in autoit (but I need it in C++).

I suppose the inclusion is done correct in AutoIt, so I could peek the source how the include file is converted to an absolute path there, but I haven't got the time right now. If someone knows how, I could fix it.

Cheers.

Edited by tylo

blub

Link to comment
Share on other sites

Glad to here the solution is alredy near :D

I suppose the inclusion is done correct in AutoIt, so I could peek the source how the include file is converted to an absolute path there, but I haven't got the time right now. If someone knows how, I could fix it.

Yes, indeed, it's correctely done by AutoIt, it uses a GetFullPathName function (from AutoIt v3.0.102 source code).

Hope it helps :idiot:

Edit: I should have given the lib to include : windows.h if I'm correct...

Edited by LazyCoder
A good program computing A into B is mostly one that won't crash in all the other cases...
Link to comment
Share on other sites

  • 1 month later...

I think I discovered a bug.

>"C:\Program Files\AutoIt3\SciTe\au3check\au3check" "C:\scripts\MyUDFs.au3"
AutoIt3 Syntax Checker v1.26  Copyright (c) Tylo 2005

C:\scripts\MyUDFs.au3(1186,43) : ERROR: Opt() called with illegal argument 1: "RunErrorsFatal"
      $PrevSett = Opt ("RunErrorsFatal", 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\scripts\MyUDFs.au3(1199,39) : ERROR: Opt() called with illegal argument 1: "RunErrorsFatal"
      Opt ("RunErrorsFatal", $PrevSett)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\scripts\MyUDFs.au3 - 2 error(s), 0 warning(s)
>Exit code: 2   Time: 0.211

I have tested this function several times and AutoIt never reported an error.

Func _Execute($LineofCode, $rUsername = "", $rDomain = "", $rPassword = "", $rOpts = 1)
   Local $PrevSett, $RetVal, $RunAs = 0
   $LineofCode = StringReplace($LineofCode, '"', '""')
   If @NumParams > 1 Then
      If @OSVersion = "WIN_XP" Or @OSVersion = "WIN_2000" Then $RunAs = 1
   EndIf
   If $RunAs Then
      If $rUsername = "" Then $rUsername = @UserName
      If $rDomain = "" Then $rDomain = @ComputerName
      If $rPassword = "" Then
         $rPassword = InputBox('_Execute', 'Enter the password for username "' & $rUsername & '"')
         If @error Then Return 1
      EndIf
      $PrevSett = Opt ("RunErrorsFatal", 0)
      RunAsSet($rUsername, $rDomain, $rPassword, $rOpts)
   EndIf
   If StringLeft($LineofCode, 2) = "If" And StringInStr($LineofCode, "Then") Then
      $RetVal = RunWait(@AutoItExe & ' /c "' & $LineofCode & '"', @WorkingDir)
   Else
      $RetVal = RunWait(@AutoItExe & ' /c "Exit(' & $LineofCode & ')"', @WorkingDir)
   EndIf
   If @error Then
      MsgBox(16, "_Execute Error", "Error: Incorrect password or unknown username.")
      Return 1
   ElseIf $RunAs Then
      RunAsSet()
      Opt ("RunErrorsFatal", $PrevSett)
   EndIf
   Return $RetVal
EndFunc  ;==>_Execute
Link to comment
Share on other sites

This happens in Scite only. More than a month ago I put the contents of the ZIP in another folder. I just ran it from there and it said 0 errors, 0 warnings.

What I discovered: JdeB's installation package has 2 Au3Check.dat files.

One is for the official AutoIt release and the other one is for beta releases.

The latter one is missing a line: %AutoItSetOption 1 RunErrorsFatal

After I added the line, I still get those errors.

So the problem probably lies in the DAT file.

Edit:

I just started WinMerge to check differences.

I get this strange message that says something about line endings.

I answered No and copied the RunErrorsFatal line to the Scite DAT file and after saving it worked.

Edited by SlimShady
Link to comment
Share on other sites

  • Developers

The issue is that the definition files are automatically build and there is an issue with file : AutoItSetOption.txt

It is missing the red text...

@JPM, could you pls fix this for me in your version ?

Will publish an update soon.

ProvideRunStderr

<a name="ProvideRunStderr"></a>Sets whether AutoIt provides any child processes with a handle redirecting its standard console error output, which can then be read by the StderrRead() function.

0 = Do not redirect the STDERR streams of child processes (default)

1 = Provide a redirection of STDERR

ProvideRunStdin

<a name="ProvideRunStdin"></a>Sets whether AutoIt provides any child processes with a handle redirecting its standard console input, which can then be written to by the StdinWrite() function.

0 = Do not redirect the STDIN streams of child processes (default)

1 = Provide a redirection of STDIN

ProvideRunStdout

<a name="ProvideRunStdout"></a>Sets whether AutoIt provides any child processes with a handle redirecting its standard console output, which can then be read by the StdoutRead() function.

0 = Do not redirect the STDOUT streams of child processes (default)

1 = Provide a redirection of STDOUT

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

Link to comment
Share on other sites

I've attached a new version of Au3Check from tylo.

New in 1.27:

  • Supports COM syntax.
  • Supports With...EndWith.
  • Supports For...In...Next.
  • Supports Enum
The included DAT file is current up to JPM's 3.1.0.15-O release.

Edit: Removed attachment. Newer releases have been made by tylo.

Edited by Valik
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...