Sign in to follow this  
Followers 0

Organize Includes in SciTE4Autoit3

77 posts in this topic

Posted (edited)

Hello everybody,

many languages like Java have got a little helper tool in their IDE, which cares for the right import/include statements.
The helper tool adds the necessary lines for including the needed libraries(or UDFs).
This script organizes the includes for AutoIt and it can be added to SciTE4Autoit3 very easily.

Getting started?
1) Extract the zip here (ProgramsDIR) ..AutoIt3SciTE
2) Open SciteUser.properties
You'll find the file here : @DocumentsDirUSER
or via SciTE menu --> [ Options --> Open User Option File ]

Add these lines to add OrganizeIncludes to the SciTE menu.
 

# 36 OrganizeIncludes
#command.36.*.au3="$(autoit3dir)\beta\autoit3.exe" "$(SciteDefaultHome)\OrganizeIncludes\OI_1.0.0.50.au3" "$(FilePath)"
command.36.*.au3="$(SciteDefaultHome)\..\autoit3.exe" "$(SciteDefaultHome)\OrganizeIncludes\OI_1.0.0.50.au3" "$(FilePath)"
command.name.36.*.au3=OrganizeIncludes
command.save.before.36.*.au3=1
command.is.filter.36.*.au3=1
command.shortcut.36.*.au3=Ctrl+Shift+Alt+I

If the Autoit3 exe is not found then replace this variable $(autoit3dir) by the correct path.
command.36.*.au3="$(autoit3dir)autoit3.exe" "$(SciteDefaultHome)OrganizeIncludesOI_1.0.0.50.au3" "$(FilePath)"
command.36.*.au3="c:ProgrammeAutoit3autoit3.exe" "$(SciteDefaultHome)OrganizeIncludesOI_1.0.0.50.au3" "$(FilePath)"



3) DONE

Starting the script by hitting CTRL+SHIFT+ALT+I in Scite, it shows you what include files you need and which you do not need.
There is also a helpfile in the zip-file which shows all settings.

br86-3.jpg

Old version download ~ 3000!!! THANKS!!! Old versions thread

cat_misc.jpg

Thanks for every comment/idea!

Mega :mellow:

OrganizeIncludes.zip

Edited by Xenobiologist
jaberwacky and mLipok like this

Share this post


Link to post
Share on other sites



Posted

Didn't see this first time around, very usefull thanks alot :mellow:

Share this post


Link to post
Share on other sites

Posted

I really like the new GUI. Great job! This tool has been very useful to me.

Share this post


Link to post
Share on other sites

Posted

Thank you both! :mellow:

Share this post


Link to post
Share on other sites

Posted

Mega, you should get this included as a tool for the standard SciTE4AutoIt3 distribution. It's certainly more useful (to me anyway) than AU3Record, MacroGenerator, CodeWizard, or Koda.

Share this post


Link to post
Share on other sites

Posted

Mega, you should get this included as a tool for the standard SciTE4AutoIt3 distribution. It's certainly more useful (to me anyway) than AU3Record, MacroGenerator, CodeWizard, or Koda.

Thanks for that comment. Let's see what other people say. I guess, when there are some more people using and liking this script, then Jos will also have a look too.

Share this post


Link to post
Share on other sites

Posted

Ofcourse it should go into the official distribution. This is great! I have always been using the old version. I'm happy to see a timely upgrade.

Share this post


Link to post
Share on other sites

Posted (edited)

whatever Edited by MvGulik

Share this post


Link to post
Share on other sites

Posted

I've been using this since I started with AutoIT it's revived a LOT of old code that I would have given up on without it. BIG thanks for the update.

One little problem though (isn't there always).

I use "Kips'" TCP.au3 library for one of the programs I am working. It just happened to be the one I tried your code on and OI told me to remove TCP.AU3.

The OI is telling me the sample code doesn't need to include TCP.AU3, of course it does.

http://www.autoitscript.com/forum/index.php?showtopic=74325

Thanks again for the great utility!

John Morrison

AKA

Storm-E

Share this post


Link to post
Share on other sites

Posted

Bummer, I have a lot of include commands inside a other included file, instead of in the main/root source file.

But. Do I read your TODO's correct that this might be supported in a future version?

PS: When I try to use a build executable instead of the au3 file. The GUI is not showing in my case. (normal au3 case works fine)

Using exe like this:

- au3.properties: command.37.$(au3)="<myPath>\AutoIt3\SciTE\OrganizeIncludes\OrganizeIncludes.exe" "$(FilePath)"

---

Forgot: Win.Xp.Pro.Sp3.x86.?

OI lists all needed includes. If you included a file which internally includes a few others till now, this has no effect on OI. I decided to list all needed includes instead of checking the dependencies. From my point of view, this is better and leads to no problems, cause if you compile your script, you can use Obfuscator from Jos to strip all unneeded lines.

>>> But, I'll have a look whether I can find a good logic to add the option to check includes in includes.

Yes, when you compile OI it doesn't show a GUI. It is in line 385 : If Not @Compiled Then GUISetState(@SW_SHOW)

This is because, using the script as an executable should be used from the commandline. This way, you can use it even without SciTE!

I've been using this since I started with AutoIT it's revived a LOT of old code that I would have given up on without it. BIG thanks for the update.

One little problem though (isn't there always).

I use "Kips'" TCP.au3 library for one of the programs I am working. It just happened to be the one I tried your code on and OI told me to remove TCP.AU3.

The OI is telling me the sample code doesn't need to include TCP.AU3, of course it does.

http://www.autoitscript.com/forum/index.php?showtopic=74325

Thanks again for the great utility!

John Morrison

AKA

Storm-E

Thanks too!

If you are using a function from that UDF, then OI will show you. BUT, you need to tell Oi where to look for that UDF.

You can add the path to your UDF via SciTE GUI

Posted Image

Or put the UDF into the ScriptDir an check the ScriptDir in the OI GUI

Mega

Share this post


Link to post
Share on other sites

Posted (edited)

Thanks too!

If you are using a function from that UDF, then OI will show you. BUT, you need to tell Oi where to look for that UDF.

You can add the path to your UDF via SciTE GUI

Or put the UDF into the ScriptDir an check the ScriptDir in the OI GUI

Mega

Sorry I ASS-u-ME-d that it read the Include commands and read the UDF's from there. :mellow:

I ticked the "read udfs from script folder" and it didn't even click then...sigh :(

Thanks and keep up the great work.

Edited by storme

Share this post


Link to post
Share on other sites

Posted

.... then Jos will also have a look too.

I seem to remember we already had a background discussion on this last year? :mellow:

AutoIt3Wrapper currently does something similar for just the Constants include files when you add the directive:

#AutoIt3Wrapper_Add_Constants=                  ;Add the needed standard constant include files. Will only run one time.

I would have no issue adding this Script to the standard tools but believe it would also be nice if we could run it with a directive "each time"/"one time" when you Press Run or Compile. We also need to consider how much time is added running this tool.

I had a quick look at the source of your script and it looks like most of the components for this are in place.

At first glance: things that would be required are support for these parameters on the commandline to be able to run it in batch from AutoIt3Wrapper:

  • /AutoIt3dir
  • /Beta or /Prod

Jos :(

Share this post


Link to post
Share on other sites

Posted (edited)

whatever Edited by MvGulik

Share this post


Link to post
Share on other sites

Posted

@storme

Does that mean, it doesn't work for you? If so, can you send me your constellation, that I can test it myself. Thanks!

@Jos

Thanks, I will add the commandline options soon.

Although, I think, there is no need for an automated start cia Wrapper.

Checking the includes is FMPOV a task which can be done manually by CTRL+ALT+SHIFT+I when needed.

But let's see what the people say.

Besides, there also some other features which I need to add for the next version.(see ToDo list in Source code) :mellow:

Share this post


Link to post
Share on other sites

Posted

+1 on the automated start via Wrapper as it would save me time tracking down which includes I've forgotten or which includes I no longer need when compiling my scripts after making minor changes. While AU3Check always lets me know I've left an include out, it doesn't tell me what the include is, nor will it tell me that I no longer need an include (which is very useful in reducing the size of my compiled scripts). I know I could run OI manually every time but I'm so damn lazy :mellow:

P.S. used it yesterday on several scripts I thought were OK (and finished) and it's already proven valuable in reducing the size of my compiled scripts. :( Mega.

Share this post


Link to post
Share on other sites

Posted (edited)

whatever Edited by MvGulik

Share this post


Link to post
Share on other sites

Posted (edited)

PS: Xenobiologist are you deliberately stripping the input source code of linebreaks?

(I though I got a better & faster alternative RegExp for _getDeclaredIncludes(), but because of the unexpected missing linebreaks it back fired on me the moment I put in in your code for final testing. :( )

I'm using two variables to handle the source code. One which holds the original code and one which is stripped by every unneeded stuff like emtpy lines, comments and so on. The stripped code is used to get all the stuff done like getting used functions, used variables, declared includes ...

That is why the source in that function looks the way it looks. (it is just to make the script faster!)

Edited by Xenobiologist

Share this post


Link to post
Share on other sites

Posted (edited)

nice one man, i always use this ^^

i had a older version floating around, which came with a installer, so i made some adjustments to it, so it works with your version too, thought i would

post it so maybe others can use it too.

its in the attachment.

Damian666

*edited for spelling >.<

*edit2 - btw, you need to put the whole folder next to the script, it looks for it in that folder, and i forgot to add the scite useroptions file xD , just put that in your folder.

Installer.au3

SciTEUser.rar

Edited by damian666

Share this post


Link to post
Share on other sites

Posted (edited)

whatever Edited by MvGulik

Share this post


Link to post
Share on other sites

Posted

Hi,

how do you get that result? There is no problem on my side.

#include <ComboConstants.au3>
;~ #include <Date.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

#include <GuiButton.au3> ;...
#include <GUIConstantsEx.au3> ;...
#include <GuiImageList.au3> ;...

#include <GuiButton.au3>;...
#include <GUIConstantsEx.au3>;...
#include <GuiImageList.au3>;...
;~ #include "c:\Autoit\ForumTests\Monitor\2nd_Monitor.au3"
GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered
Global $cmb_item = GUICtrlCreateCombo("", 10, 10, 90, 120, $CBS_DROPDOWNLIST); create first item
GUICtrlSetData(-1, "Autoit|SciTE|OrganizeIncludes", "Autoit"); add other item snd set a new default
Global $label = GUICtrlCreateLabel(_NowDate(), 150, 10, 90, 20, $SS_SUNKEN)
GUISetState()

;~ 		_TaskBarItemCreate(
; Run the GUI until the dialog is closed
Local $msg
While 1
	$msg = GUIGetMsg()
	Select
 	Case $msg = $GUI_EVENT_CLOSE
 	ExitLoop
 	Case $msg = $cmb_item
 	GUICtrlSetData($label, GUICtrlRead($cmb_item))
	EndSelect
WEnd

;~ _toggleMonitor()

;~ _TCP_Server_Stop()

Leads to

#include <ComboConstants.au3>
#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
;~ #include <Date.au3>



;~ #include "c:\Autoit\ForumTests\Monitor\2nd_Monitor.au3"
GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered
Global $cmb_item = GUICtrlCreateCombo("", 10, 10, 90, 120, $CBS_DROPDOWNLIST); create first item
GUICtrlSetData(-1, "Autoit|SciTE|OrganizeIncludes", "Autoit"); add other item snd set a new default
Global $label = GUICtrlCreateLabel(_NowDate(), 150, 10, 90, 20, $SS_SUNKEN)
GUISetState()

;~ 		_TaskBarItemCreate(
; Run the GUI until the dialog is closed
Local $msg
While 1
	$msg = GUIGetMsg()
	Select
 	Case $msg = $GUI_EVENT_CLOSE
 	ExitLoop
 	Case $msg = $cmb_item
 	GUICtrlSetData($label, GUICtrlRead($cmb_item))
	EndSelect
WEnd

;~ _toggleMonitor()

;~ _TCP_Server_Stop()

which seems to be correct.

Mega

Share this post


Link to post
Share on other sites

Posted (edited)

whatever Edited by MvGulik

Share this post


Link to post
Share on other sites

Posted

Bummer. I seems to have lost Xenobiologist interest on the subject. No point. Dropping subject.

Certainly not! I' working on a new version which has got some bugfixes and new featues.

To answer your question. The problem you discuss is not really a problem, because the source held in that variable is really only for getting the needed info from it. And do get all the needed info.

Besides, the line break stuff dosen't come from the Regex pattern - it belongs to StringStripWS.

Func _stripSourceCode(ByRef $source)
	Local $noComment_source = $source
	_stripComments($noComment_source)
	$noComment_source = StringStripWS($noComment_source, 7) ; doppelte Leerzeichen/Umbrüche entfernen
	Return $noComment_source
EndFunc ;==>_stripSourceCode

This line $noComment_source = StringStripWS($noComment_source, 7) ; doppelte Leerzeichen/Umbrüche entfernen

leads to the linebreak stuff you mentioned. But as I said before, it is no problem for me, because my following functions in the source code can work with that.

Thanks for your effort!

Mega

Share this post


Link to post
Share on other sites

Posted (edited)

whatever Edited by MvGulik

Share this post


Link to post
Share on other sites

Posted

Just something to think about but you may like to include a readme.txt with the zip indicating how to install OI. I recently upgraded to Win 7 and had to log back into the forums to remember how to install it. Nothing major but a PITA when you are trying to reinstall all your programs quickly :-)

Share this post


Link to post
Share on other sites

Posted

A simple little improvement would be to insert the includes after the directives. Autoit directives are always supposed to be at the top. Great tool. I use this countless times every day.

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

  • Recently Browsing   0 members

    No registered users viewing this page.