Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Auto-Syntax-Tidy v12


  • Please log in to reply
88 replies to this topic
toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
The basic difference is this:

Toralf Style
If x
  {
    y = mad
  }
Else {
    z = cow
  }
Rajat Style
If x
{
  y = mad
}
Else {
  z = cow
}

Due to the lag of a describtive name I named it after the proposers. :)
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Oh right. You could replace the styles bit with a simple checkbox saying 'Double indent IF statements' or something of the sort.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
The text has to be short (by my standards).
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Thats only four words. Any shorter name would still be ambiguous (although better than Toralf/Rajat). You could go for 'Double Indent', 'Indent IFs', 'SmartIndentâ„¢' or any other pseudo name for double indenting IF statements.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

Please advice names for the two different styles.

They have traditionnal names:
K&R (Kernighan & Ritchie, creators of C):
if (foo) {
  F()
}
BSD/Allman: (my choice)
if (foo)
{
  F()
}
GNU:
if (foo)
  {
    F()
  }
Pico:
if (foo)
{ F()
}
Banner: (used by BoBo)
if (foo) {
  F()
  }
etc.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

TheLeO
  • Members
  • 264 posts
  • Last active: Jan 02 2012 01:51 AM
  • Joined: 11 Jun 2005
hey nice,,,

VEry very nice tidy,,
although it didnt make much difference to my code since im pretty much of a " indentation, casing and spacing" fanatic any way.
^.^

but hey, cool stuff. ^.^
::
I Have Spoken
::

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
I like the K&R style for AutoHotkey scripting (becuase it's still easy to understand when compacted) and BSD/Allman for C#. Good findings PhiLho, I have yet to understand that the Wikipedia knows all!

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


robiandi
  • Guests
  • Last active:
  • Joined: --
@toralf: I use your excellent script regularly.
Version = v10
ScriptName = Auto-Syntax-Tidy %Version%
; 2006-02-21
I found 2 bugs:
1. Directives
After
If FirstWord in %ListOfDirectives%         ;line is directive
we have in line 714
String = %String%%Line%`n
2. Hotkeys
After
Else If FirstChar in #,!,^,+,<,>,*,~,$     ;line is Hotkey
we have in line 719
String = %String%%Line%`n
but in both cases the lines will be added again in line 1143
String = %String%%Indent%%Line%`n
To test it, take the following script
#SingleInstance force
^1::msgbox hello
I propose to deactivate line 714 and line 719

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Hi,
Thanks for the bug report. I guess it is related to an Else I forgot to set in line 726(?, i'm already on version 11)
If (FirstChar = "," OR FirstTwoChars = "||" OR FirstTwoChars = "&&"
Please put an "Else" in front of this line, test, and report your findings. I currently have no time to test, sorry. Thanks again. I'll update the code when I find time.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

robiandi
  • Guests
  • Last active:
  • Joined: --
Number of tests: 1
Succes Rate: 100%

I will wait for version 11

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
toralf,
here's a bug report.
i ran it on itself... and the outcome gave error and didn't run. the reason being on line 84 the hotkey section '^d::' comes out twice.

i must say, this script is brilliant work!

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Bobo afficionnado
  • Guests
  • Last active:
  • Joined: --
My prefered notation :
Loop x
	{
	If i = 1
		{
		Do that
		}
	Else
		{
		Do This
		}
	}


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005

i ran it on itself... and the outcome gave error and didn't run. the reason being on line 84 the hotkey section '^d::' comes out twice.

I'll take a look.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005

My prefered notation :

I'll look into the code if I can add a BoBo style. :)
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
New features in v11:
- Command line options
- New style "BoBo"

I updated the code in the first post.

@Rajat: I can't reproduce the bug. Could you please test the latest code to see if is persists? Thanks.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.