AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Syntax-Tidy for scripts (indentation and case correction)
Goto page Previous  1, 2, 3, 4
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Tekl



Joined: 24 Sep 2004
Posts: 814
Location: Germany

PostPosted: Sun Mar 13, 2005 3:19 pm    Post subject: Reply with quote

Hi Toralf,

it nearly works perfect. Maybe it would be useful to let automatically process a file if it is specified via command-line. So it's easy to intregrate a compiled version your favourite editor.

In very big scripts I like indented subroutines so that the section-browser of MED will ident them also. Maybe some others use this way to get more structure. What about (optional) preserving indention of Subroutines and Hotkeys?

Code:
Hotkey::
   if enable_functionA = yes
      gosub, main_functionA
Return

main_functionA:
   gosub, sub_fA_subroutine
Return

   sub_fA_subroutine:
      ; indented subroutine
   Return

nextHotkey::
   ; bla bla
Return


Tekl
Back to top
View user's profile Send private message Visit poster's website
toralf



Joined: 31 Jan 2005
Posts: 3910
Location: Bremen, Germany

PostPosted: Sun Mar 13, 2005 11:24 pm    Post subject: Reply with quote

Dear Tekl,

Thank you for the suggestions. But I do not think I will gonna do them.
1) To extend the script to accept command line parameters would take some effort, even so it is feasible. But I think only very few users would benefit. And the command line would have many parameters.

2) To preserve indentations is not the objective of the script. It was always ment to re-astablish a indentation that reflects the syntax. Especially if there is none or wrong indentation. How should the script know that some indentations are correct while others need to be modified?
If you want to do this for your scripts you could use the column edit function of UltraEdit. It is very useful in these cases.

Feel free to make a mod that fits you needs.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Hajos



Joined: 04 Jun 2005
Posts: 17
Location: Göttingen

PostPosted: Sun Jun 05, 2005 12:50 pm    Post subject: Reply with quote

Hello Toralf
great work! I use it for all my scripts, myself being very untidy in writing.
Added a few lines for function recognition, as I need them.

Edit by moderator: Toralf has applied these revisions to the first post of this topic.
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3910
Location: Bremen, Germany

PostPosted: Mon Jun 06, 2005 8:32 am    Post subject: Reply with quote

Hajos wrote:
Hello Toralf
great work! I use it for all my scripts, myself being very untidy in writing.
Added a few lines for function recognition, as I need them.


Thank you Hajos for the new feature and the spelling correction you did.
I didn't test, but have updated the script in the first post.
I like the line
Code:
FirstWordIsFunction := ( FunctionBracketPos > 0 )
This is beautiful, I wasn't aware that it's feasible.

I wonder if the case correction would work in all cases? I think the script has to check at least the second and third word as well. So, it captures all of the following lines
Code:
Add(x,y)
result=Add(1,2)
result= Add(1,2)
result =Add(1,2)
result = Add(1,2)
And maybe even each line of the script has to be searched for text infront of a "(" to find function names. Because function names may appear inside other commands.
Code:
MsgBox % "The answer is: " . Add(3, 2)
Do you think this is feasible? I fear that it will be very difficult to recognize.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
toralf



Joined: 31 Jan 2005
Posts: 3910
Location: Bremen, Germany

PostPosted: Mon Jun 06, 2005 8:43 am    Post subject: Reply with quote

And next thing that has to be checked is correct indentation for line continuation
Quote:
A line that starts with "and", "or", ||, &&, or a comma is automatically merged with the line directly above it.
Everyone is welcome to do it. [If I find time, I will do it.] Please post your findings or solutions. Thanks
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Hajos



Joined: 04 Jun 2005
Posts: 17
Location: Göttingen

PostPosted: Wed Jun 08, 2005 10:00 pm    Post subject: Reply with quote

Hello Toralf,
thx for integrating my lines into your script - makes me proud.
And here´s my try at an extension concerning line continuation.
As to the other questions (case correction of function names), I´ve to think about it.
Code:
;  - added 2005-06-08: indentation of implicit continuation lines, by HJS (Hajos)
;      (i.e. lines that start with "and", "or", ||, &&, or a comma)

Greetings
Hajos

Edit by moderator: Long script removed because Toralf has applied these revisions to the first post of this topic.
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3910
Location: Bremen, Germany

PostPosted: Thu Jun 09, 2005 11:28 am    Post subject: Reply with quote

Hi Hajos,
Thank you for the improvements. I have included them into the first post and added choice for tabs/spaces.

Assuming your approval I have made you co-author of this script.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Hajos



Joined: 04 Jun 2005
Posts: 17
Location: Göttingen

PostPosted: Wed Jun 22, 2005 8:33 am    Post subject: Reply with quote

Hi Toralf,
Quote:
Do you think this is feasible?
Couldn´t resist the challenge.
So here´s a further instalment
Modifications:
- Spell checking of self defined functions and subroutines (Upper/Lower case) uses names in function/subroutine definition
- The present indentation inside block comments and continuation blocks may be preserved
- a change in line 893 (fix of "else" indentation after a one line if command which is itself an if or loop command; works for my scripts)Hajos

Coment from moderator: For the latest version, see http://www.autohotkey.com/forum/viewtopic.php?t=7810
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3910
Location: Bremen, Germany

PostPosted: Thu Jun 23, 2005 7:45 am    Post subject: Reply with quote

Dear Hajos,

I got your email, thanks, but I've problems to keep up with the changes. It is difficult for me to compare your and my script to find differences and maintain this post.
I suggest you start a new post with your script in the first post. Then you can take over the maintainance and development. I will from time to time stop by and take a look.

Good luck, and thank you very much for the cooperation
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Maelgwyn



Joined: 13 Jan 2006
Posts: 36
Location: Brisbane, Australia

PostPosted: Mon Jan 16, 2006 12:26 am    Post subject: Reply with quote

This is great!

I like to use lots of spaces in my scripts, it not only makes them seem longer but helps me to block certain parts. This complements that nicely and works on everything I have done.
_________________
The rapidity of particle flow alone determines power: LRH
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group