BrewManNH Posted January 26, 2012 Share Posted January 26, 2012 I copied a script from one of the help requests in the general forum and inadvertantly must have hit the space bar while looking at it. Au3Check gives me the following errors: >Running AU3Check (1.54.22.0) from:F:PortableAutoIt3.3.8App F:AutoItScriptstest.au3(13,10) : ERROR: syntax error GUICtrl CreateLabel ~~~~~~~~^ F:AutoItScriptstest.au3(7,22) : ERROR: Timer(): undefined function. AdlibRegister("Timer") ~~~~~~~~~~~~~~~~~~~~~^ F:AutoItScriptstest.au3 - 2 error(s), 0 warning(s) !>13:12:32 AU3Check ended.rc:2 >Exit code: 0 Time: 2.956 The first error is actually the error, the Timer() function error shouldn't be listed as an error because there is a function named "Timer" further down in the script. I'm not sure if it's because the parser stopped at the syntax error that it doesn't see the function or what, but it could make debugging a script harder if you're trying to fix phantom errors. BTW, here's the script that caused the errors: ; *** Demo to show a timer window #include <GUIConstantsEx.au3> #include <Date.au3> Opt("TrayIconDebug", 1) Opt("MustDeclareVars", 1) Global $timer, $Secs, $Mins, $Hour, $Time AdlibRegister("Timer") _Main() Func _Main() ;Create GUI GUICreate("Timer", 120, 50) GUICtrl CreateLabel("00:00:00", 10, 10) GUISetState() ;Start timer $timer = TimerInit() ; While 1 ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> before") Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> after") WEnd EndFunc ;==>_Main ; Func Timer() _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs) Local $sTime = $Time ; save current time to be able to test and avoid flicker.. $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime <> $Time Then ControlSetText("Timer", "", "Static1", $Time) EndFunc ;==>Timer If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2012 Developers Share Posted January 26, 2012 (edited) The lexer stops on the syntax error and then processes the found Func name references. Since the Lexer stopped, au3check hasn't found all FUNCs yet, reporting this one as an error. This has to do with the single pass design of au3check. Edited January 26, 2012 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. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 26, 2012 Moderators Share Posted January 26, 2012 BrewManNH,I have noticed this before - there is a similar "feature" in Tidy. In both cases the parser runs out of ideas following the first "real" error and brings up a lot of subsequent "errors" because it is confused. I now make sure I skim through the notified errors to see which is the first obvious idiocy I have committed and then immediately rerun Au3Check/Tidy to see if the others still exist. In the case where you know the script was good before you made an amendment it is relatively easy to understand why the AdlibRegister might throw an error - it is more difficult if you are running the script through these checks for the first time. But I stil think both these utilties are worth their weight in gold and would not wish to criticize the authors - after all if I did not make mistakes in the first place they would not have to cope with my syntactic stupidities! M23 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: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Valik Posted January 26, 2012 Share Posted January 26, 2012 Always fix the first error encountered and then re-run the error checking tool. Always. I don't care if it's AutoIt, C++, Python or any other language. Fix the first error, re-run the tool. Repeat until all errors are fixed. Link to comment Share on other sites More sharing options...
BrewManNH Posted January 26, 2012 Author Share Posted January 26, 2012 As long as I know WHY it reported the error, I can work with it. It just confused me, and I figured it's better to ask than assume it's a bug rather than "that's how it is supposed to work". I can deal with the latter easier than the former. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now