Jump to content

clean up a script


 Share

Recommended Posts

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.

Link to comment
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.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
Share on other sites

Cool - learned something new today!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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