Jump to content

Au3Check.exe


tylo
 Share

Recommended Posts

Tylo,

I think this code should not generate an au3check error:

WARNING: $errorlog: possibly used before declaration.

If IsDeclared("errorlog") AND FileExists($errorlog)

If IsDeclared("var") is False, Then the conditions to the right of the AND involving $var are never evaluated, correct?

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

That's a really poor way to write code so a warning of some kind is correct. Besides, if you want to suppress the warning, use Eval("errorlog") instead of $errorlog. In fact, if you use Eval("errorlog"), you can just skip the If IsDeclared() stuff since if errorlog doesn't exist, Eval() will return an empty string.

Link to comment
Share on other sites

some kind of warning is correct

While appreciated, I was not requesting a stylistic critique, rather a clarification of the points as laid out.

An error should not be thrown in that situation, IMO, because the AND operation ensures that if the left side evaluates to false then the right side is not evaluated at runtime. If my belief that the behavior of au3 is as outlined, then it is impossible to have a situation where the variable is used w/o being declared, and, therefore, the warning of a "possible use of variable before declaration" error is misleading at best.

While the method you propose is indeed more elegant, it is no less functional (nor no less syntactically accurate). I believe that the points of logic (if not the style points :o ) are valid.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

A stylistic critique is required since you are mixing two distinctly different styles or variable access which is a bad thing to do. Do you want to use a variable who's existence is unknown until run time or do you want to use a variable that you know at design time? Either do one or the other but don't do both. It's both confusing to the programmer and definitely confusing to a syntax checker which doesn't parse the code for fringe coding styles.

The code is technically correct but that doesn't mean it shouldn't be flagged with a warning for something. There are other examples of correct code but which is deprecated (Keyword Dim) or just bad style (Declaring Global variables inside a function). While this warning doesn't strictly pertain to mixing variable access styles, it does provide a hint that the code needs some review and possible modification.

Keep in mind, "This code works" is not all the criteria necessary for "this code doesn't generate warnings". Also remember that anytime you use IsDeclared() and want to access the variable you are checking, you should always use either Assign() or Eval() to access the contents of the variable.

Link to comment
Share on other sites

So maybe we need a warning that says "Valik wouldn't code it that way" :o

If FileExists(Eval("errorlog"))

I do agree that this is cleaner, I'm just not accustomed to using Eval() or Assign() for anything, and forget that they're even available.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

Also remember that anytime you use IsDeclared() and want to access the variable you are checking, you should always use either Assign() or Eval() to access the contents of the variable.

This should be present in the documentation of IsDeclared(), if it isn't already.

blub

Link to comment
Share on other sites

  • 2 weeks later...

The following code gives me an unwanted error in Au3Check v1.54.

_Test(False)
HotKeySet('^{F12}', '_Test')

Func _Test($Val = True)
EndFunc

Comment the first line and the error disappears.

Well, the error is correct but that's pure luck I think.

If parameters are used in a callback function which is being invoked via some other mechanism than Call() or GUIRegisterMsg(), AutoIt it will error out at run-time. This should probably get a warning from Au3Check. However, SlimShady is correct, the warning, while somewhat correct for the problem in the script, isn't actually generated because of the problem in the script.

By the way, SlimShady, it would be helpful if you actually told us what message you are getting and what your Au3Check options are. That example gives me one error and one warning with my Au3Check options, for example.

Link to comment
Share on other sites

I always run with only the -q option.

In my original script I have Func _Check($Silent = True)

The output from Au3Check:

ERROR: _Check() called with wrong number of args.
            HotKeySet('{F5}', '_Check')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
REF: definition of _Check().
HotKeySet('{F5}', '_Check')
~~~~~~~~~~~~~~~~~~~~~~~~~~^
1 error(s), 0 warning(s)

Basically the same as in the script I posted above.

ERROR: _Test() called with wrong number of args.
HotKeySet('^{F12}', '_Test')
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
REF: definition of _Test().
_Test(False)
~~~~~~~~~~~^
1 error(s), 0 warning(s)

If parameters are used in a callback function which is being invoked via some other mechanism than Call() or GUIRegisterMsg(), AutoIt it will error out at run-time.

But why? I want to run the function when the user presses a hotkey, or a button.

And I want to do different things depending on the action.

Link to comment
Share on other sites

But why? I want to run the function when the user presses a hotkey, or a button.

And I want to do different things depending on the action.

Because that's how AutoIt is currently written.

To do what you want:

HotKeySet("^{F12", "HotKeyWrapper")

While True
WEnd


Func HotKeyWrapper()
    Callback(True)
EndFunc

Func ButtonWrapper()
    CallBack(False)
EndFunc

Func Callback($bHotkey)
    If $bHotkey Then MsgBox(4096, "", "Hotkey invoked")
EndFunc
Link to comment
Share on other sites

Since there is no SciTe config for Au3Check, what line in CompileAU3.au3 do I need to change to use these switches everytime I run SciTe's SyntaxCheck Beta? Is it this one (line 821):

$RC = Run(FileGetShortName($Au3checkpgm) & ' -q "' & $ScriptFile_In & '"', '', @SW_HIDE, 2)

Do I just add the options I want to use after the '-q' above?

Link to comment
Share on other sites

  • Developers

Since there is no SciTe config for Au3Check, what line in CompileAU3.au3 do I need to change to use these switches everytime I run SciTe's SyntaxCheck Beta? Is it this one (line 821):

$RC = Run(FileGetShortName($Au3checkpgm) & ' -q "' & $ScriptFile_In & '"', '', @SW_HIDE, 2)

Do I just add the options I want to use after the '-q' above?

Just add your defaults in CompileAU3.INI:

[Other]

Run_AU3Check=

AU3Check_Stop_OnWarning=

AU3Check_Parameter=-d -w 1 - w 2

Run_Before=

Run_After=

Check CompileAU3.INI.examples for all possible defaults you can set.

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

I tried putting those lines into 'C:\Program Files\AutoIt3\SciTe\CompileAU3\CompileAU3.ini' but it didn't seem to do anything for me JdeB :o

Was this the correct file?

Looking at the script-line you posted I am pretty sure you aren't running the latest version of CompileAU3 which is part of the SciTE4AutoIt3 installer posted Jan 19, 2006.

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

...Example of include statement the produces ERROR: can't open include file...

I select continue anyway, and the program compiles and runs as it should.

This code:
#include <IE.au3>
generates this in the Au3Check box:

C:\Temp\short-path-include.au3(1,10) : ERROR: can't open include file <IE.au3>

#include <IE.au3>

~~~~~~~~~^

and subsequent "undefined function" errors.

This code:

#include "C:\Program Files\AutoIt3\beta\Include\IE.au3"
works just fine with Au3Check.

I run beta code from within SciTE and I had one system that worked with the short path just fine... and one system that needed the full path. So naturally I decided to break the system that worked by installing the latest SciTE4AutoIt and Defs. Now both systems require the full path.

Ditto on the "I select continue anyway, and the program compiles and runs as it should."

Thanks tylo for this great tool that has saved me hours of hunting down typos. (Who knew that I would need to know how to type?) Anyway, I just thought that I would mentioned this. Au3Check used to find beta includes just fine and now it has trouble with at least this one. I can use the full path or just copy IE.au3 into the production include folder and Au3Check will find it just fine.

Thanks again....

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

  • Developers

This code:

#include <IE.au3>
generates this in the Au3Check box:and subsequent "undefined function" errors.

This code:

#include "C:\Program Files\AutoIt3\beta\Include\IE.au3"
works just fine with Au3Check.

I run beta code from within SciTE and I had one system that worked with the short path just fine... and one system that needed the full path. So naturally I decided to break the system that worked by installing the latest SciTE4AutoIt and Defs. Now both systems require the full path.

Ditto on the "I select continue anyway, and the program compiles and runs as it should."

Thanks tylo for this great tool that has saved me hours of hunting down typos. (Who knew that I would need to know how to type?) Anyway, I just thought that I would mentioned this. Au3Check used to find beta includes just fine and now it has trouble with at least this one. I can use the full path or just copy IE.au3 into the production include folder and Au3Check will find it just fine.

Thanks again....

The latest Beta version of AutoIt and AUT2EXE will look for the include directory as a subdirectory of the Program directory. thus c:\program files\autoit3\autoit3.exe will look in c:\program files\autoit3\include

and c:\program files\autoit3\beta\autoit3.exe will look in c:\program files\autoit3\beta\include.

The current AU3Check uses the registry entry to find the Include directory and thus only looks in :

c:\program files\autoit3\include whatever version you use.

I have made a temporary fix for this in the au3check program to use the same logic as AutoIt3 and this will be rolled out with the next SciTE4AutoIt3 installer since you also need other modifications to programs like CompileAU3 ...

Planning to make that available tomorrow if tests keep on going well.

If you are interested in a test version then sent me a PM...

Edited by JdeB

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

Thanks for the quick reply. I'm in no rush... I just thought I would mention it.

BTW, when I said, "Au3Check used to find beta includes just fine and now it has trouble with at least this one." I could have had IE.au3 in both include folders on that other system. So perhaps nothing has changed/regressed with Au3Check. (I can't check as I uninstalled AutoIt and SciTE as part of my testing.)

Thanks for all that you do for the AutoIt community!

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

  • 2 years later...

I would like to retrieve the error message on warning or compile failed... I am calling au3check using runwait()

How can I do this?

I tried to redirect the result to a text file ">>test.txt" however I think perhaps runwait cannot be used with redirecting output... this works from the command prompt

Is there perhaps an environment variable that contains the error message? or a switch to enable writing output to a text file?

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