Jump to content

Autoit3 Tidy


Jos
 Share

Recommended Posts

  • Developers

Pulled out the Tidy stuff from the Scite Editor thread since they are 2 separate items and made a new version of Tidy available that has the following changes:

1.0.9 - bug fixes

1.0.8 - Added Tidy function for Operators/Delimiters

........- More speed improvements.

1.0.7 - Added optional Startup menu

........- made lots of speed improvements

1.0.6 - Added config menu

For more info have a look at the included tidy_doc.htm.

This is an example what it will do :

Example:

if $test<>1 or $TC=" " then  
for $s=1to10
$t2=$t2-1
next
endIf
if $t=10 then
select
case $x=1
msgbox(0,'test1','x=1')
case $x=2
msgbox(0,'test1','x=2')
case else
msgbox(0,'test1','x is something else')
endselect   
endif
$t=iniread(@scriptdir&"\test.ini","test","test",-1)
func test($tst)
$tst=1
return($tst)
endfunc

will change to:

If $TEST <> 1 Or $TC = " " Then  
   For $S = 1to10
      $T2 = $T2 - 1
   Next
EndIf
If $T = 10 Then
   Select
      Case $X = 1
         MsgBox(0, 'test1', 'x=1')
      Case $X = 2
         MsgBox(0, 'test1', 'x=2')
      Case Else
         MsgBox(0, 'test1', 'x is something else')
   EndSelect   
EndIf
$T = IniRead(@ScriptDir & "\test.ini", "test", "test", -1)
Func test($TST)
   $TST = 1
   return ($TST)
EndFunc  ;==>test
Edited by JdeB

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

Link to comment
Share on other sites

JdeB, just installed it. Looks good here (with large fonts).

A couple of thoughts...

- Tidy startup window, Setup button. Consider renaming this button Settings or Options. These days, Setup usually means Install. A search of my system drive found 21 files named setup.exe in various folders.

- Since doc doesn't yet include installation, I've included some notes to help newbies below. Feel free to use any/all of this in your doc if that would be helpful.

1) How to install tidy as a standalone app., ie. when not using SciTE Editor.

To install it under AutoIt3, like this...

c:\program files\AutoIt3\Tidy

c:\program files\AutoIt3\Tidy\Tidy_doc_files

Extract all files contained in tidy.zip to a subfolder (named Tidy) of the folder you installed AutoIt3 to. In your unzipping program, check the option to "use folder names", this is WinZip terminology. It might be called something else in your unzipping program. If you don't check this option, tidy_doc.htm will not be able to find the graphics (ie screen shots).

2) How to install Tidy when using SciTE Editor.

Extract all files contained in tidy.zip to a subfolder (named Tidy) of the folder that you installed SciTE Editor to. In your unzipping program, check the option to "use folder names", this is WinZip terminology. It might be called something else in your unzipping program. If you don't check this option, tidy_doc.htm will not be able to find the graphics (ie screen shots).

For example, my install looks like this...

c:\program files\SciTE Editor\Tidy

c:\program files\SciTE Editor\Tidy\Tidy_doc_files

Thank you for sharing Tidy for AutoIt with us,

Lilla

Edited by Lilla
Link to comment
Share on other sites

  • Developers

There is some tiny buggs

I had a function named something like  LoadApp1(....)

It renamed it to LoadApp.

Dunno if this happened to anyone else. Overall this is a very nice formatting program, Thanks alot!

your right... there was a bug in it in case of a function ending with a Number.

uploaded version 1.0.10 which fixes that!!

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

Link to comment
Share on other sites

There is a bug around #include <X.au3>

When you put in the spaces around delimiters, it turns

#Include <File.au3>

into

#include < File.au3 >

There should not be any spaces around the < > in #include.

EDIT: Another thing, it does not remove extra spaces. For example, this remains unchanged.

If $FN >=   0   Then  ; Check if file opened

I think it should become

If $FN >= 0 Then  ; Check if file opened

#include-once is not formatted correctly. It becomes #include - once

My 3 cents' (Canadian) worth.

Edited by Nutster

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

  • Developers

There is a bug around #include <X.au3>

When you put in the spaces around delimiters, it turns

#Include <File.au3>

into

#include < File.au3 >

There should not be any spaces around the < > in #include.

... yes your right ... i plan to skip the lines with #Include since there should not be anything to tidy for those lines....

Another thing, it does not remove extra spaces.  For example, this remains unchanged.

If $FN >=   0   Then  ; Check if file opened

I think it should become

If $FN >= 0 Then  ; Check if file opened
I didn't include any logic there other than for the spaces in front of a COMMA in a function. Will look at that .... BUT I guess that will also have to be done for ALL Keywords/functions/macros, not just around operators.....right ?

#include-once is not formatted correctly.  Oops, that should be in the scite stream.

My 3 cents' (Canadian) worth.

EDIT: fixed... see other threat Edited by JdeB

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

Link to comment
Share on other sites

  • Developers

Tidy 1.0.11 available with the following changes:

- Fixed the #include issue adding spaces around < >. (tnx Nutster)

- Changed the "Update spaces around delimiters" option to "Update spaces around delimiters/keywords/function" and added logic to get rid of the extra spaces... (tnx Nutster)

- This url points to a new install_tidy.exe which is an install program that will guide you through the installation of Tidy. (tnx Lilla)

Example:

#include-once <File.au3>
func LoadApp1($TST)
$TST=1
return ($TST)
endFunc 
if   $TEST   <>    1    Or     $TC   <     " "    Then    ; comment
if $TEST<>1 Or $TC<" " Then    ; comment
for $S=1to10
$T2=$T2 - 1
next
endIf
if $T=10 Then
select
case $X=1
msgBox(0,'test1','x=1')
case $X=2
msgBox(0,'test1','x=2')
Case Else
msgBox(0,'test1','x is something else')
endSelect   
endIf
endIf
$T=IniRead(@ScriptDir & "\test.ini","test","test",-1)
$X=loadappl('1')
Func test($TST)
$TST=1
return($TST)
EndFunc

After processing:

#include-once <File.au3>
Func LoadApp1($TST)
   $TST = 1
   return ($TST)
EndFunc  ;==>LoadApp1
If $TEST <> 1 Or $TC < " " Then    ; comment
   If $TEST <> 1 Or $TC < " " Then    ; comment
      For $S = 1to10
         $T2 = $T2 - 1
      Next
   EndIf
   If $T = 10 Then
      Select
         Case $X = 1
            MsgBox(0, 'test1', 'x=1')
         Case $X = 2
            MsgBox(0, 'test1', 'x=2')
         Case Else
            MsgBox(0, 'test1', 'x is something else')
      EndSelect   
   EndIf
EndIf
$T = IniRead(@ScriptDir & "\test.ini", "test", "test", -1)
$X = loadappl ('1')
Func test($TST)
   $TST = 1
   return ($TST)
EndFunc  ;==>test

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

Link to comment
Share on other sites

Tidy 1.0.11 available with the following changes:

- This url points to a new install_tidy.exe which is an install program that will guide you through the installation of Tidy.  (tnx Lilla)

Looking good there on the install_tidy.exe, I gave it a try just to check it out.

SUGGESTION: on initial screen, you could use Yes / No / Cancel - so user can cancel if they decide they don't want to continue with the install. I wanted to cancel, but had to answer No to the first question so I could choose cancel on the 2nd screen.

---

I am using 1.0.11 (scite.zip version) of tidy, I found a small problem. Any code below #comments-start is misaligned. It doesn't happen in all situations, so I have included some code below that you can use to see the problem. I've stripped out excess code to make it small enough to post here, so it probably won't run, but it is enough to demo the tidy formatting problem.

;Code: AutoIt v3.0 build 101 pub 11 Mar 2004

;hide cmd.exe window that opens

Run( @ComSpec & ' /c eventvwr.msc', '', @SW_HIDE )

WinWaitActive('Event Viewer')

;Application (the letter a)

Send('a')

Sleep(100)

WinWaitActive('Event Viewer', 'Event Viewer (Local)\Application')

;&View menu (alt+v), F&ilter... (the letter i)

Send('!v')

Sleep(100)

Send('i')

Sleep(100)

WinWaitActive('Application Properties')

;Event I&D field (alt+D), type 1001 (chkdsk/autochk events)

Send('!d')

Sleep(100)

Send('1001')

Sleep(100)

;&From (alt+F), select "Events on" (the letter E)

Send('!fe')

Sleep(100)

;move to date field (tab)

Send('{TAB}')

Sleep(100)

;send starting date (yyyy-mm-dd)

Send($StartDate)

Sleep(100)

#comments-start

Send('{TAB}')

Sleep(100)

Send($StartTime12)

Sleep(100)

#comments-end

;&Apply button (alt+A)

Send('!a')

Sleep(100)

;OK button (Enter key)

Send('{ENTER}')

Sleep(100)

WinWaitClose('Application Properties')

WinWaitActive('Event Viewer')

Exit

Link to comment
Share on other sites

  • Developers

Looking good there on the install_tidy.exe, I gave it a try just to check it out.

SUGGESTION:  on initial screen, you could use Yes / No / Cancel  - so user can cancel if they decide they don't want to continue with the install. I wanted to cancel, but had to answer No to the first question so I could choose cancel on the 2nd screen.

---

I am using 1.0.11 (scite.zip version)  of tidy, I found a small problem. Any code below #comments-start is misaligned. It doesn't happen in all situations, so I have included some code below that you can use to see the problem. I've stripped out excess code to make it small enough to post here, so it probably won't run, but it is enough to demo the tidy formatting problem.

Lilla, will have a look at your install suggestions..

Could you tell me what goes wrong with the below example or sent me the version with indentation stuff in it ?

I copied it into a test file and run Tidy but nothing changed...

Edited by JdeB

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

Link to comment
Share on other sites

  • Developers

Tidy ver 1.0.12 available...

It has a fix for Block comments #CS, #CE that where indented wrong. (tnx Lilla..)

It now indents to the correct level and the lines between #CS and #CE are indented one level more...

Example code:

#include-once <file.au3>
func loadapp1($tst)
#cs
test function
commented lines
#ce
$tst=1
return ($tst)
endfunc 
if   $test   <>    1    or     $tc   <     " "    then   ; comment
if $test<>1 or $tc<" " then   ; comment
for $s=1to10
$t2=$t2 - 1
next
endif
if $t=10 then
select
case $x=1
msgbox(0,'test1','x=1')
case $x=2
msgbox(0,'test1','x=2')
Case else
msgbox(0,'test1','x is something else')
endselect   
endif
endif

After Tidy process:

#include-once <File.au3>
Func LoadApp1($TST)
   #CS
      test function
      commented lines
   #CE
   $TST = 1
   return ($TST)
EndFunc  ;==>LoadApp1
If $TEST <> 1 Or $TC < " " Then  ; comment
   If $TEST <> 1 Or $TC < " " Then  ; comment
      For $S = 1to10
         $T2 = $T2 - 1
      Next
   EndIf
   If $T = 10 Then
      Select
         Case $X = 1
            MsgBox(0, 'test1', 'x=1')
         Case $X = 2
            MsgBox(0, 'test1', 'x=2')
         Case Else
            MsgBox(0, 'test1', 'x is something else')
      EndSelect   
   EndIf
EndIf
Edited by JdeB

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

Link to comment
Share on other sites

Sorry, found more bugs

1) When I tell tidy to manage the spaces around delimiters,

Return -1

gets turned into

Return - 1

2) IsInt() does not get capitalized properly. I am thinking that it does not appear to be in the list of functions.

Edited by Nutster

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

  • Developers

Sorry, found more bugs

1) When I tell tidy to manage the spaces around delimiters,

Return -1

gets turned into

Return - 1

2) IsInt() does not get capitalized properly.  I am thinking that it does not appear to be in the list of functions.

1) Is fixed in the Tidy 1.0.13 release...

2) The program uses the files supplied by Jon in the Doc sources. the IsInt() is in there and was already in the 1.0.12 version. Tested a bit with it but couldn't get it wrong.... pls give a sample code if its stil wrong for you.

Also fixed the logic for spaces around brackets. it sometimes had no and sometimes 1 space after an opening bracket and the same before a closing bracket.

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

Link to comment
Share on other sites

  • Developers

Do you make program ALREADY indented and tidy?

If you don't understand the use of the program and when you run it, it doesn't make any changes to your scriptsource then you must be that programmer they always talk about that creates this proper cased and proper indented programs.... :huh2:

But when you see some posts you could imagine its use i would think. :D

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

Link to comment
Share on other sites

Having in Scite already Tidy inside I tried it... Ok... I was already very tidy, but I have to say that I was wrong. it is quite useful. Thanks again!

Just a question... Can I avoid the making of useless backup and the tidy.txt file?

Or... Can I understand why are they made?

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