Sign in to follow this  
Followers 0
frankito

clean up a script

7 posts in this topic

Hi,

I've just get a script from a friend which i want to clean up.

This script is 10K lines long and there is a couple of useless function or variable.

A soft or an editor could help me to do that ?

Cheers

Share this post


Link to post
Share on other sites



Hi,

I've just get a script from a friend which i want to clean up.

This script is 10K lines long and there is a couple of useless function or variable.

A soft or an editor could help me to do that ?

Cheers

Download and install Autoit, it comes with an editor for its code.

Share this post


Link to post
Share on other sites

Download and install Autoit, it comes with an editor for its code.

yes i know :)

but i want an editor with a function to identify and delete useless variable and function...and i don't think auoit editor do it ...

Share this post


Link to post
Share on other sites

so i guess it doesn't exists .. :) ?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If you install the full AutoIt version you get a lot of useful tools:

SciTE: The editor

Tidy: To clean the source code in SciTE (makes indention etc. but does not delete unused code)

Au3Check: Can inform you about declarded but not used variables

obfuscator: strips unused functions, unused variables etc.

obfuscator is - with some limitations - what you need.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

If you install the full AutoIt version you get a lot of useful tools:

SciTE: The editor

Tidy: To clean the source code in SciTE (makes indention etc. but does not delete unused code)

Au3Check: Can inform you about declarded but not used variables

obfuscator: strips unused functions, unused variables etc.

obfuscator is - with some limitations - what you need.

Tidy.exe when used with the /gd /gds options also produces a very useful cross reference report, listing which functions and variables are used and where. This I think will meet the OPs original request.

Example of Tidy generated documentation and cross reference report.

========================================================================================================
===  Tidy report for :C:\AutoItData\Projects\temp\test.au3
========================================================================================================

00001    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
00002    #AutoIt3Wrapper_Run_Tidy=y
00003    #Tidy_Parameters=/gd /gds
00004    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
00005    $Pid = 0
00006    $unsedvar
00007  +-While 1
00008  |    Sleep("5000")
00009  |  +-If Not ProcessExists($Pid) Then
00010  |  |    $Pid = ProcessExists("notepad.exe")
00011  |  |  +-If Not $Pid Then
00012  |  |  |    ShellExecute("notepad.exe")
00013  |  |  +-EndIf
00014  |  +-EndIf
00015  +-WEnd
00016    
00017  +-Func _unused()
00018    EndFunc   ;==>_unused

======================
=== xref reports =====
======================

== User functions =================================================================================================
                          Func
Function name             Row     Referenced at Row(s)
========================= ====== ==================================================================================
_unused                   00017 

#### indicates that this specific variable only occurs one time in the script.
---- indicates that this specific variable isn't declared with Dim/Local/Global/Const.

== Variables ======================================================================================================
Variable name             Dim   Used in Row(s)
========================= ===== ===================================================================================
$Pid                      ----- 00005 00009 00010 00011
$unsedvar                 ----- 00006

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

Cool - learned something new today!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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