Description of Tidy.exe

What can Tidy do for you:

  1. Clean up the indentation with spaces or Tabs.
  2. Change all Functions/Keywords/Macros to proper case as defined in the files
    1. au3.api
    2. UserFunctions.txt
  3. All user functions from Userfunctions.txt and all FUNC in the script are loaded into the Functions table. This option only works in combination with the previous option.
  4. Change all Variables to Uppercase or Lowercase or "as Dim/Global/Local or First occurrence"
  5. Add spaces around operators and remove extra spaces around operators/keywords/function.
  6. Remove empty lines.
  7. Remove trailing spaces.
  8. Add a comment after EndFunc to easily identity which Func end with this EndFunc
    e.g. "EndFunc  ; ==> FunctionName"
  9. Generate a Documentation file with program logic and Xref reports for Variables and UDF's.
  10. check for coding errors like missing EndIF/Wend or Func inside and IF/DO/FOR loop.
  11. Sort all Func-Endfunc Blocks in sequence and when #Region-#EndRegion is used sort them within that scope.

Example 1:

Before After


Example 2:

When there is a syntax issue, Tidy will insert warning comments as shown in the below example and indicate the number of errors found. In this case the End if is wrong so doesn't close the If before the Func starts. Just fix the coding issue and run Tidy again. All previous inserted Tidy error lines will be removed by Tidy.

 

Before After

 

Running Tidy:

Your can run Tidy in 3 ways:

  1. Run it from within SciTE by pressing Ctrl+T.
  2. Just start the program Tidy.exe and you will be prompted for the filename.
  3. Right Mouse Click on your AU3 script and select Tidy. This is only available when you have used the SciTE4AutoIt3 installer.

When Tidy is run without any parameter you will be prompted for the input file.

 

After you specified the input file Tidy will start the process and show the result in the SciTE Output pane or Command window:

Tidy AutoIt3 v2.0.0.0 Copyright (c) Jos van der Zande August 19, 2006
+> Tidy AutoIt3 finished. Original copied to:"C:\Development\winutil\AutoIt3\programs\test\BackUp\test_old5.au3"
 

Setting Tidy's options (Tidy.ini):

[ProgramSettings]
*** (tabchar)Indent setting: 0=Tabs >0=Number of Space
tabchar=0
*** Update Functions/Keywords/Macros/UDFs to Proper case
proper=1
*** Update Variables to: 1=UpperCase; 2=LowerCase; 3=First Dim/Local/Global or "First_Seen" Case (Only in combination with Proper=1)
vars=3
*** Update Spaces around Delimiters
delim=1
*** Generate Documentation file for the Program With Func and Variable X-ref report
*** and optionally Display it with Notepad at the end of the Tidy run.
Gen_Doc=0
Gen_Doc_Show=0

*** Keep x Version of the File before the Tidy run and store them in SubDirectory "\Backup". 0 means keep all backups.
KeepNVersions=5
*** Target backup directory which defaults to Scriptdir\Backup. Any other directory needs to exist or else it will use the default directory!
backupDir=Directory=

*** Remove Empty lines from Script Source
Remove_Empty_Lines=1
*** 1=Show Tidy Errors in Console 9=Debug Output
ShowConsoleInfo=1
*** Run DIFF program at the end of the Tidy run to show the difference between original and new program.
ShowDiffPgm=C:\Progra~1\WinMerge\winmerge.exe "%new%" "%old%"
*** Add comment to EndFunc statement e.g. "EndFunc ;==>UDF_Name".
Skip_EndFunc_Comment=1
*** Remove comments from EndFunc statement.
Remove_EndFunc_Comment=1
*** Copy the comment from the Region statement and add that to the EndRegion statement.
Skip_EndRegion_Comment=1
*** Remove comments from EndRegion statement.
Remove_EndRegion_Comment=1
*** Copy the comment from the Region statement and add that to the EndRegion statement.
Sort_Funcs=1
*** Sort all Func-Endfunc Blocks in sequence of the Comment at the end of the Func() statement and then FuncName.
    When #Region-#EndRegion is used sort them within that scope.
Sort_Funcs_Comments=1
*** Skip indenting commentblocks: 0=Indent comment blocks (default) 1=Don't Indent comment blocks
Skip_CommentBlock=1

 

These settings can be overridden by specifying the below parameters on the Tidy commandline or  #Tidy_Parameters Directive in the script:

/proper or /pr=0/1
/updatevars or /uv=1/2/3

/tabchar or /tc=0
/gen_doc or /gd
/r_empty_lines or /rel 
/showconsoleinfo=0/1/9 or /sci=0/1/9
/gen_doc_show or /gds
/showdiffpgm=xyz.exe
"%new%" "%old%" or /sdp=xyz.exe"%new%" "%old%"
/noshowdiffpgm or /nsdp
/keepnversions=n or /kv=n
/backupdir=
directory or /bdir=directory
/Skip_commentblock or /scb
/Skip_EndFunc_Comment or /sefc
/Remove_EndFun_comment or /refc
/Skip_EndRegion_Comment or /serc
/remove_endregion_comment or /rerc
/sort_funcs or /sf
/sort_funcs_Comment or /sfc

 

Example this will override the Generate Document-file to generate it, Remove the empty lines from the script and will not start Windif to show the difference at the end of the Tidy process:

#Tidy_Parameters= /gd 1  /rel 1 /nsdp