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 

Auto-Syntax-Tidy v12
Goto page Previous  1, 2, 3, 4, 5  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
TodWulff



Joined: 29 Dec 2007
Posts: 139

PostPosted: Sun Mar 30, 2008 6:00 pm    Post subject: Reply with quote

urlwolf wrote:
Another feature request:
Could you add an option to covert functions to the K&R format, i.e. function (params) { ? That's OTB for functions...
I concur, ^^this^^ may be beneficial for those that don't employ K&R/ORB coding styles and choose to leverage code written in same...

...

My real reason for posting - I am wondering if the following is a bug, or if I am seeing a trait that was not planned for:

From the Speech Recognition thread, the following code exists:


Code:
CleanUp:
COM_Release(pevent)
COM_Release(pstate)
COM_Release(prulec)
COM_Release(prules)
COM_Release(pgrammar)
COM_Release(pcontext)
COM_Release(plistener)
COM_Term()
ExitApp

OnRecognition(prms, this)
{
   presult := COM_DispGetParam(prms, 3, 9)
   pphrase := COM_Invoke(presult, "PhraseInfo")
   sText   := COM_Invoke(pphrase, "GetText")
   COM_Release(pphrase)
;   Add custom operations from here!
}


and if I use AST on it, with Rajat's style selected, the result is:

Code:
CleanUp:
   COM_Release(pevent)
   COM_Release(pstate)
   COM_Release(prulec)
   COM_Release(prules)
   COM_Release(pgrammar)
   COM_Release(pcontext)
   COM_Release(plistener)
   COM_Term()
   ExitApp

   OnRecognition(prms, this)
   {
      presult := COM_DispGetParam(prms, 3, 9)
      pphrase := COM_Invoke(presult, "PhraseInfo")
      sText   := COM_Invoke(pphrase, "GetText")
      COM_Release(pphrase)
      ;   Add custom operations from here!
   }

Note how the OnRecognition function label is indented.

My question is, Is this by design, or just a quirk that will have to be dealt with on an individual case by case basis?

Not a bid deal, just curious. If it is easily addressed, could you kindly point me to the section of script where I might consider tweaking in order to prevent it from indenting the first function after the ExitApp keyword?

TIA.

-t
_________________
When replying, please feel free to address me as Tod. My AHK.net site...
Back to top
View user's profile Send private message
toralf not logged in
Guest





PostPosted: Mon Mar 31, 2008 4:53 am    Post subject: Reply with quote

Hi,
You might simply add a "Return" after the ExitApp.
The reason is, that each block has to be closed to be recognized by AST. In this case the subroutine with a return.
Back to top
TodWulff



Joined: 29 Dec 2007
Posts: 139

PostPosted: Mon Mar 31, 2008 5:31 am    Post subject: Reply with quote

Thanks toralf. Fully understood. Have a good one!

-t
_________________
When replying, please feel free to address me as Tod. My AHK.net site...
Back to top
View user's profile Send private message
Starbuck



Joined: 26 Feb 2008
Posts: 13

PostPosted: Sun Jul 27, 2008 4:09 am    Post subject: Bug report for v12? Reply with quote

Ref:
Code:
 WinGet, WinHotkeyErrorID, ID, % "Hot keystroke error"
In that text the word "error" gets capitalized to "Error". This occurs in quotes or without. It definitely changes the behavior of code.

I'm using PSPad and when I F2 I get the dialog "Couldn't get anything to indent". This comes from the following tidy code:
Code:
  ;If something is selected, do the indentation and put it back in again
  If ClipboardString is Space
      MsgBox, 0 , %ScriptName%,
    (LTrim
      Couldn't get anything to indent.
      Please try again.
    ), 1
I thought this might be because I code with CRLF End-Of-Line unless I'm uploading code to a *nix server. I copy/pasted my code into Wordpad. On F2 the entire file was selected and reformatted. I was only expecting the selected text, but OK. I pasted the code into Windows Notepad and hit F2. When it strips out the CR and leaves LF-only EOL, Notepad gets ugly. I think there should be an option to turn off the code that manipulates the EOL markers.

Side note: Personally I prefer the BSD/Rajat style, though it seems the first brace on a function gets indented anyway. Bug? Example:
Code:
MyFunction()
  {
    If SomeVar<>
    {
      ; Handle it
    }
  }
;;Next function...
That's a bit inconsistent. No?

Last: As I was looking for scripts in this forum I also came across this link:
http://www.autohotkey.com/forum/viewtopic.php?t=4395
That contains an old version of the formatting code:
ScriptName = Auto-Syntax-Tidy v6.1
; OS=WinXP, AHK=1.0.35.16, Author = Toralf, Co-Author = Hajos
; 2005-06-09, 2005-06-27, 2005-07-10

I highly recommend for the script on that page to be removed and a link inserted to this thread. I know it forward links to 2528 an that links here, but it's not entirely clear as to whether these are both competing scripts or whether the first is obsoleted by the current v12 - and yes, the one here is absolutely better than the other one.

Thanks for the script, guys. I'll add it to my list of "I wonder if I can improve on that when I understand this better...".
Back to top
View user's profile Send private message
haichen



Joined: 05 Feb 2007
Posts: 189
Location: Osnabrück, Germany

PostPosted: Sun Jul 27, 2008 1:10 pm    Post subject: Re: Bug report for v12? Reply with quote

Starbuck wrote:
I'm using PSPad and when I F2 I get the dialog "Couldn't get anything to indent".
If you drag files on v12-Gui it works. So i think it's not from EOL, may be some issue with clipboard. I've this also.
Back to top
View user's profile Send private message
haichen



Joined: 05 Feb 2007
Posts: 189
Location: Osnabrück, Germany

PostPosted: Sun Jul 27, 2008 1:29 pm    Post subject: Reply with quote

I had a look at the code. Put a clipwait after Send, ^c and Send, ^a^c a few lines before. Then it works.
Back to top
View user's profile Send private message
Starbuck



Joined: 26 Feb 2008
Posts: 13

PostPosted: Sun Jul 27, 2008 11:41 pm    Post subject: Reply with quote

Quote:
Put a clipwait after Send, ^c and Send, ^a^c a few lines before
Yes, that fixes the F2 issue. Good call. Thanks.
Back to top
View user's profile Send private message
paxophobe



Joined: 10 Nov 2007
Posts: 93
Location: Second star to the right.... watching you.

PostPosted: Sat Jul 04, 2009 10:32 pm    Post subject: Reply with quote

I just have a small feature request...

Can you please add to this script the ability to make indentation correction optional? I am looking for a script that just renames the commands/functions/etc, IE, what you offer as optional in the bottom half of the GUI.
Back to top
View user's profile Send private message
paxophobe



Joined: 10 Nov 2007
Posts: 93
Location: Second star to the right.... watching you.

PostPosted: Wed Jul 15, 2009 6:14 am    Post subject: Reply with quote

Whatever you do, don't read the post prior to this one.
Back to top
View user's profile Send private message
MilesAhead



Joined: 21 Jan 2009
Posts: 86

PostPosted: Thu Aug 06, 2009 5:54 pm    Post subject: Nice Reply with quote

I'm still pretty new to AHK. I ran across this utility. Very nice. I'm lost without an auto-indenter. Thanks for the program. Smile
Back to top
View user's profile Send private message
FatZgrED



Joined: 19 Oct 2008
Posts: 7
Location: Kielce, Poland

PostPosted: Wed Oct 07, 2009 7:46 pm    Post subject: Bug report Reply with quote

I have 2 hotkeys:
Code:
~LButton & MButton:: Send #d
~LButton & !Left:: Send #w

After autoindentation they dissapear.
What's the cause?
Back to top
View user's profile Send private message
MilesAhead



Joined: 21 Jan 2009
Posts: 86

PostPosted: Mon Nov 16, 2009 10:20 pm    Post subject: UDF left bracket flush style? Reply with quote

It seems to insits on this function style

Code:

  _func()
  {
     return 0
  }


Is there a setting to get it to do

Code:

_func()
{
    return 0
}


flush left?

I prefer brackets line up flush left with the first letter of the line above and flush left to the left margin at function start/end. Using Rajat style seems to work as expected except for functions.

Other than that I like it very much. Thanks for the tool. Smile

edit: I inserted the ClipWaits as suggested above. Now F2 gives me this effect:

Code:

_crap()
  {
    Return 1
  }



I really hate brackets that don't align with the first character of the function name or keyword.
Back to top
View user's profile Send private message
MilesAhead



Joined: 21 Jan 2009
Posts: 86

PostPosted: Fri Nov 20, 2009 12:25 am    Post subject: Reply with quote

Looks like a 2 fold solution will work for me. Use this utility to set keyword caps, then just run Indentation Checker command in Scite 1.73 to put the braces back where expected.
Back to top
View user's profile Send private message
WJW1965



Joined: 09 Sep 2008
Posts: 133

PostPosted: Thu Dec 10, 2009 7:57 am    Post subject: Reply with quote

Love this script and use it all the time, thx Very Happy

This style of ternary operator makes it hard to read the script - request for this to be added, or can I set it to do this currently?

Thanks



Code:


;currently I get -

PartRounder(Num,Total,Small,Big)
  {
  local Part
  If (RoundSmallStyle)
    Part := Small
  Else If (RoundBigStyle)
    Part := Big
  Else
    {
    Part := %Num%RoundTotalTo
    Part := (Part = "Any") ? Small
: (Part = "All") ? Big
: Part
  }
Total := TotalAmount(Total,Part)
Return Total
}

;something like this would be nice -

PartRounder(Num,Total,Small,Big)
  {
  local Part
  If (RoundSmallStyle)
    Part := Small
  Else If (RoundBigStyle)
    Part := Big
  Else
    {
    Part := %Num%RoundTotalTo
    Part := (Part = "Any") ? Small
         : (Part = "All") ? Big
         : Part
    }
  Total := TotalAmount(Total,Part)
  Return Total
  }
Back to top
View user's profile Send private message
Morpheus



Joined: 31 Jul 2008
Posts: 278

PostPosted: Sun Feb 28, 2010 12:19 pm    Post subject: Reply with quote

Toralf - Thanks for this script. I am using V13 that came with your AHK ToolBar. I belive that that AST does not indent WHILE properly (At least it is not the same as LOOP).

Code:
While RowNumber := LV_GetNext(RowNumber, "Checked")
{
 LV_GetText(Key,RowNumber)
 LV_GetText(Value,RowNumber,4)
}


Code:
Loop, Parse, List, `n, `r%A_Space%
 {
   StringReplace, LoopField, A_LoopField, %A_Space%, |
   StringReplace, LoopField, LoopField, [, |
   StringReplace, LoopField, LoopField, ], |
 }


AND

Code:
While RowNumber := LV_GetNext(RowNumber, "Checked")
Read_LV_Info("MAPPROPERTIES")


Code:
Loop, %Available0%
  LV_Add("",Available%A_Index%)


Thanks Again!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5  Next
Page 4 of 5

 
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