Jump to content

Recommended Posts

Posted

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

Screenshot of an output screen:

Posted Image

#include <ByteMe.au3>

Posted

Don't forget about OrganizeIncludes.au3 and #AutoIt3Wrapper_Add_Constants=y

Definitly a winner!

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

sleepydvdr

See script below, works much faster

Before 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+F7

3.3.8.0

SciTEPropertiesau3.properties

command.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)=1

post-56546-0-41185100-1312467950_thumb.g

Include_Helper.7z

Edited by AZJIO
Posted

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>

Posted

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

  • 4 weeks later...
Posted (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 by skin27
Posted

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

Posted

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

Posted (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 by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

  • Developers
Posted (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 :mellow:

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

Posted

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 :mellow:

Yes, as you mention in your question it's only for compiled scripts, but you will well admit that we try our script before ! Posted Image

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Posted

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

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
  • Recently Browsing   0 members

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