sleepydvdr Posted July 4, 2011 Posted July 4, 2011 Have you ever written a script and tried to run it and got "Error: Variable used without being declared"? Of course, we all have. It can be annoying trying to figure out what you are missing. Thus, I make this simple script & data file that checks your script and shows you what constants it needs. Note that it does not check for functions needed like File.au3 or Array.au3. It only checks for constant includes needed like ButtonConstants.au3, EditConstants.au3, WindowsConstants.au3, etc. I know that Koda has on occasion not included the necessary constants in its output and I have to dig around trying to figure out what is missing. Koda is the best gui creator for AutoIt, but it does miss a #Include on occasion.Anyways, I tried to write the whole thing in arrays, but it was becoming a pain. At least for now, I ditched that idea and used plain old temp files and it works just fine like that.Hope this helps some people! I know I will be using it.Download here: (script not compiled - for your viewing pleasure )http://www.fusionsolid.com/Projects/ConstantsHelper/ConstantsHelper.zipScreenshot of an output screen: #include <ByteMe.au3>
jaberwacky Posted July 5, 2011 Posted July 5, 2011 (edited) Don't forget about OrganizeIncludes.au3 and #AutoIt3Wrapper_Add_Constants=y. Good work though because it works as advertised. Edited July 5, 2011 by LaCastiglione Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
MrCreatoR Posted July 5, 2011 Posted July 5, 2011 Don't forget about OrganizeIncludes.au3 and #AutoIt3Wrapper_Add_Constants=yDefinitly a winner! Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
AZJIO Posted July 5, 2011 Posted July 5, 2011 (edited) sleepydvdrSee script below, works much fasterBefore starting, remove the old file "Include_Helper_Data.txt"Added the Import button. Checks are not only constants, but functions. Analogue of Notepad++shortcuts.xml<Command name="Include_Helper" Ctrl="yes" Alt="no" Shift="no" Key="118">"$(NPP_DIRECTORY)..AutoIt3.exe" "$(NPP_DIRECTORY)Instrument_azjioInclude_Helper.au3" "$(FULL_CURRENT_PATH)"</Command>SciTEPropertiesau3.properties# 39 Include_Helper command.39.*.au3="$(autoit3dir)autoit3.exe" "$(SciteDefaultHome)Instrument_azjioInclude_Helper.au3" "$(FilePath)" command.name.39.*.au3=@AZJIO: Include_Helper command.subsystem.39.$(au3)=2 command.shortcut.39.*.au3=Alt+F73.3.8.0SciTEPropertiesau3.propertiescommand.name.35.$(au3)=Include_Helper command.shortcut.35.$(au3)=Ctrl+F7 command.35.$(au3)="$(SciteDefaultHome)..autoit3.exe" "$(SciteDefaultHome)Instrument_azjioInclude_Helper.au3" "$(FilePath)" command.subsystem.35.$(au3)=2 command.save.before.35.$(au3)=2 command.replace.selection.16.$(au3)=0 command.quiet.35.$(au3)=1Include_Helper.7z Edited January 14, 2012 by AZJIO My other projects or all
sleepydvdr Posted July 6, 2011 Author Posted July 6, 2011 AZJIO, I am impressed. Your script is so much faster. It is nearly instantaneous and all done in arrays and no temp files. Looking over your code, I see some concepts that are new to me and I need to start studying... As they say, there's always a better way. Thanks for posting. #include <ByteMe.au3>
ValeryVal Posted July 6, 2011 Posted July 6, 2011 It would be more helpful to collect missing script constants into particular file (e.g. MissingConstants.au3) and add one line #include "MissingConstants.au3" into virgin script, I think. Thank you The point of world view
skin27 Posted August 3, 2011 Posted August 3, 2011 (edited) AZJIO the script works. Some remarks 1) Why not order the includes list in an alphabetical order 2) Show if the UDF is already included or not. For example with a listview $includesList _GUICtrlListView_Create($gui, "", 2, 2, 100, 100) _GUICtrlListView_InsertColumn($includesList, 0, "UDF", 80) --> the udf .au3 _GUICtrlListView_InsertColumn($includesList, 1, "Included", 20) --> yes or no 3) Add a button to add constants that are not ready included on top of your script 4) The script didn't recognize the ScrollBarConstants.au3 Personally I never experienced a lot of trouble with constants when using Opt('MustDeclareVars', 1) Edited August 3, 2011 by skin27
Chimaera Posted August 4, 2011 Posted August 4, 2011 That's good stuff Azjio, well done, will help no end, shame they cant add that to Scite If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
AZJIO Posted August 5, 2011 Posted August 5, 2011 shame they cant add that to SciteWhat's the problem? I gave an example. My other projects or all
skin27 Posted August 5, 2011 Posted August 5, 2011 What's the problem? I gave an example.I think he means that it's not added to Scite by default (like KODA or other tools). The organize includes tool is also not added by default...The make it clearer for users you may pack your au3 already in the "Instrument_azjio" folder and let users extract it in the scite folder. Then let them open the user properties (Option --> Open User Options File) to add it to the tools. By the way can you change the default shortcut to Ctrl F8 as Ctrl F7 is already used to start the compiler (at least in the latest stable).
Chimaera Posted August 5, 2011 Posted August 5, 2011 I think he means that it's not added to Scite by default (like KODA or other tools).Thats exactly what i meant..Includes is a pain sometimes at least this gives a way to check and resolve.Many thanks If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
AZJIO Posted August 5, 2011 Posted August 5, 2011 For example, if you have added # include <GDIPlus.au3> then #include "GDIPlusConstants.au3" #include "WinAPI.au3" #include "StructureConstants.au3"and WinAPI.au3 #include "StructureConstants.au3" #include "FileConstants.au3" #include "Security.au3" #include "SendMessage.au3" #include "WinAPIError.au3"not added to the result My other projects or all
wakillon Posted August 8, 2011 Posted August 8, 2011 @AZJIOSame problem found as AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
wakillon Posted August 8, 2011 Posted August 8, 2011 (edited) @sleepydvdr ConstantsHelper.au3 return a warning when check >Running AU3Check (1.54.19.0) from:C:\Program Files\AutoIt3 C:\ConstantsHelper.au3(23,58) : WARNING: $array: possibly used before declaration. $compare = StringInStr($line, $array[$innerLoop - 1][0]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\ConstantsHelper.au3 - 0 error(s), 1 warning(s) And an @error when run >Running:(3.3.6.1):C:\Program Files\AutoIt3\autoit3.exe "C:ConstantsHelper.au3" C:\ConstantsHelper.au3 (33) : ==> Array variable subscript badly formatted.: Global $arrayCleanup[$semiFinalStage] Global $arrayCleanup[^ ERROR Edited August 8, 2011 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
Developers Jos Posted August 8, 2011 Developers Posted August 8, 2011 (edited) Can somebody explain what this gives more than the already available option in the Compile_With_Options Menu or manually coded directive? : #AutoIt3Wrapper_Add_Constants=y Jos Edited August 8, 2011 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.
AZJIO Posted August 8, 2011 Posted August 8, 2011 This is true, but often have to test the script not compiling. Old scripts often require "*constants.au3" My other projects or all
wakillon Posted August 9, 2011 Posted August 9, 2011 wakillon fixed a bug Thanks Can somebody explain what this gives more than the already available option in the Compile_With_Options Menu or manually coded directive? : #AutoIt3Wrapper_Add_Constants=y Jos Yes, as you mention in your question it's only for compiled scripts, but you will well admit that we try our script before ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
skin27 Posted August 9, 2011 Posted August 9, 2011 AZJIO three things 1)Adding too much? When running this sample code: Local $oExcel = _ExcelBookNew() ;Create new book, make it visible _ExcelWriteCell($oExcel, "I Wrote to This Cell", 1, 1) ;Write to the Cell MsgBox(0, "Exiting", "Press OK to Save File and Exit") _ExcelBookSaveAs($oExcel, @TempDir & "\Temp.xls", "xls", 0, 1) ; Now we save it into the temp directory; overwrite existing file if necessary _ExcelBookClose($oExcel) ; And finally we close out The tool recommended to add: #include <Excel.au3> #include <ExcelCOM_UDF.au3> Only the Excel.au3 should be enough (otherwise the script will not compile). Can you take a look a this. 2) Duplicates What about when I have a copy of <Excel.au3>, let say <ExcelTest.au3>. Then the function is in two UDF's, but you can only use (and want to use) one of these UDF's. Can you try to handle this situation? 3) What would be nice is to run this tool in the background and when hitting F5 the tool removes the unnecessary includes or add missing ones (prompt or automatically).
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