Sign in to follow this  
Followers 0
aGorilla

Au3Check - getting false reports of 'undefined function'

17 posts in this topic

#1 ·  Posted (edited)

I have a project that I have split into multiple files, with a master file that has all of my options, globals, and includes. When I run Au3Check against the master file, it seems to find all of the includes, and processes them, but I'm getting 8 errors about 'undefined functions', where the functions do exist.

It seems I can reduce the errors (and possibly eliminate them), by changing the order of the includes - ie: put the file with the function before the file where it's called.

Is this normal, or a known issue, or should it be reported as a bug (I looked, and I don't see an existing ticket for it)?

Edited by aGorilla

Share this post


Link to post
Share on other sites



I would guess that this is a normal condition. If the include file where the function resides is not included before the use of that function, I would expect Au3Check to fail and not be able to find the function.


Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

I would guess that this is a normal condition. If the include file where the function resides is not included before the use of that function, I would expect Au3Check to fail and not be able to find the function.

Most includes should be at the top of the script. Functions are usually declared after the point where they are called (collected at the bottom of a script), so that's not really the functional problem. The real problem is that most UDFs also declare a bunch of Global and Const variables that MUST be declared before they are used.

Although it might be possible to go off on your own method and make it work, you'll save yourself a lot of trouble by sticking with the convention and putting all the #include's at the very top.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Most includes should be at the top of the script. Functions are usually declared after the point where they are called (collected at the bottom of a script), so that's not really the functional problem. The real problem is that most UDFs also declare a bunch of Global and Const variables that MUST be declared before they are used.

Although it might be possible to go off on your own method and make it work, you'll save yourself a lot of trouble by sticking with the convention and putting all the #include's at the very top.

:)

I am doing that... a bunch of Opt declarations, followed by globals, followed by 15 #includes. To solve the problem, I had to rearrange the includes.

It seems that Au3Check is checking the files as it comes across them, instead of doing 1 pass to find all of the functions, then another pass to see when they're used. I could be wrong, but it sure looks like that right now.

Share this post


Link to post
Share on other sites

I am doing that... a bunch of Opt declarations, followed by globals, followed by 15 #includes. To solve the problem, I had to rearrange the includes.

It seems that Au3Check is checking the files as it comes across them, instead of doing 1 pass to find all of the functions, then another pass to see when they're used. I could be wrong, but it sure looks like that right now.

Au3check is a single pass operation but still should find all defined Funcs.

Would like to see an example of a snippet that shows the issue you had.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Au3check is a single pass operation but still should find all defined Funcs.

Would like to see an example of a snippet that shows the issue you had.

Jos

I can't seem to duplicate it outside of my app, and I can't post the code.

It seems to be tied to the ticket I submitted earlier. When I switch that variable to a global, the false reports go away. They kept showing up right below the syntax error, so I figured I'd try fixing it, and strangely enough, that worked.

Hope that helps.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I can't seem to duplicate it outside of my app, and I can't post the code.

It seems to be tied to the ticket I submitted earlier. When I switch that variable to a global, the false reports go away. They kept showing up right below the syntax error, so I figured I'd try fixing it, and strangely enough, that worked.

Hope that helps.

Nah, that doesn't help really and I am not good at the guessing game.

In the initial post you talk about Func missing error. That one I do not understand and am curious to know the detains about.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Nah, that doesn't help really and I am not good at the guessing game.

In the initial post you talk about Func missing error. That one I do not understand and am curious to know the detains about.

Jos

Ok, I managed to duplicate it...

main.au3

Global $App = ObjCreate("Scripting.Dictionary")
If @error Then Exit
$App.Add('App_Retries', 0)

#include <IE.au3>
#include 'web.au3'
#include 'test.au3'

web.au3

Test()

Func _GetPage($url)
  Local $text, $oIE
  _IEErrorHandlerRegister()
  $oIE = _IECreate($url, 0, 0, 1)
  _IELoadWait($oIE)
  if @error Then 
    $App('App_Retries') += 1
    If $App('App_Retries') < 3 Then
      Return _GetPage($url)
    Else
      $App('App_Retries') = 0
      Return False
    EndIf   
  EndIf
  $text = StringStripWS(_IEBodyReadHTML($oIE), 3)
  _IEQuit ($oIE)
  return $text
EndFunc

test.au3

Func Test()
  _GetPage('http://www.google.com')
EndFunc

Results:

C:\Work\active\apps\Au3Check>au3check -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 main.au3
AutoIt3 Syntax Checker v1.54.8  Copyright (c) Tylo 2007

C:\Work\active\apps\Au3Check\web.au3(9,25) : ERROR: syntax error
    $App('App_Retries') +=
~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Work\active\apps\Au3Check\web.au3(1,6) : ERROR: Test(): undefined function.
Test()
~~~~~^
main.au3 - 2 error(s), 0 warning(s)

If I replace $App('App_Retries') with a global named $Retries, both of those errors go away.

Also, if I move the call to Test() (in web.au3), below the _GetPage() function, I don't get the undefined function error, but I still get the syntax error (edit: when using the dictionary object, obviously).

Edited by aGorilla

Share this post


Link to post
Share on other sites

Ok, understand now. Its correct that when the first error is cleared the rest will be ok.

Will have to investigate to see if we can fix that reported bug... might take a bit before I have time to do some detailed debugging.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

For those not following the issue tracker:

http://svn.autoitscript.com/trac/ticket/278#comment:4

There's no bug to see here. AutoIt doesn't support the += syntax when the lvalue is a COM object. AutoIt appears to silently ignore it. Au3Check is correct in flagging a syntax error. It's not entirely unexpected that a syntax error will cause other false errors since the syntax has been violated.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

For those not following the issue tracker:

http://svn.autoitscript.com/trac/ticket/278#comment:4

There's no bug to see here. AutoIt doesn't support the += syntax when the lvalue is a COM object. AutoIt appears to silently ignore it. Au3Check is correct in flagging a syntax error. It's not entirely unexpected that a syntax error will cause other false errors since the syntax has been violated.

That makes it much easier for me on the au3check front. Au3check is pretty nice tool but a pain to maintain for me since my braincells refuse to twist anymore. :) Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Jos, we really should re-write it in C++ using regular expressions or something. We're lucky we haven't introduced any new syntax lately but the moment we decide to mix things up a bit we're boned because none of us can or want to update it. It would be nice to have something written in a language we all (pretend to) know. So, who's going to start the project (and do more than just make the folder and VS solution :) ).

Share this post


Link to post
Share on other sites

AutoIt doesn't support the += syntax when the lvalue is a COM object.

Ahh, I never would have guessed that, and it seemed to be working fine (well, of course it would, it had infinite retries).

I'd vote for adding that capability, but I leave it to you to decide if it's worth the trouble. Thanks for clearing that up for me, and spotting a bug in my own code.

Share this post


Link to post
Share on other sites

Jos, we really should re-write it in C++ using regular expressions or something. We're lucky we haven't introduced any new syntax lately but the moment we decide to mix things up a bit we're boned because none of us can or want to update it. It would be nice to have something written in a language we all (pretend to) know. So, who's going to start the project (and do more than just make the folder and VS solution :) ).

I vaguely remember somebody, that has the same first 2 letters in his name as me, said something about an internal checker but it could also be that I zipped too must of a certain "poison" :(

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Relying on Jon to have sustained motivation is about like relying on me to have sustained motivation. Probably better off having a child, raising it to program and putting it on the task.

Share this post


Link to post
Share on other sites

Relying on Jon to have sustained motivation is about like relying on me to have sustained motivation. Probably better off having a child, raising it to program and putting it on the task.

What if we raise multitudes of human slaves to power a massive organic super computer, which in turn simulates reality in order to maintain brain activity (required to sustain life)?

Share this post


Link to post
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
Sign in to follow this  
Followers 0