AutoHotkey Community

It is currently May 27th, 2012, 12:05 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 63 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject:
PostPosted: March 30th, 2008, 7:00 pm 
Offline

Joined: December 29th, 2007, 9:40 pm
Posts: 142
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2008, 5:53 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2008, 6:31 am 
Offline

Joined: December 29th, 2007, 9:40 pm
Posts: 142
Thanks toralf. Fully understood. Have a good one!

-t

_________________
When replying, please feel free to address me as Tod. My AHK.net site...


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Bug report for v12?
PostPosted: July 27th, 2008, 5:09 am 
Offline

Joined: February 26th, 2008, 4:57 am
Posts: 13
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...".


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Bug report for v12?
PostPosted: July 27th, 2008, 2:10 pm 
Offline

Joined: February 5th, 2007, 12:19 pm
Posts: 192
Location: Osnabrück, Germany
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 27th, 2008, 2:29 pm 
Offline

Joined: February 5th, 2007, 12:19 pm
Posts: 192
Location: Osnabrück, Germany
I had a look at the code. Put a clipwait after Send, ^c and Send, ^a^c a few lines before. Then it works.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2008, 12:41 am 
Offline

Joined: February 26th, 2008, 4:57 am
Posts: 13
Quote:
Put a clipwait after Send, ^c and Send, ^a^c a few lines before
Yes, that fixes the F2 issue. Good call. Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 4th, 2009, 11:32 pm 
Offline

Joined: November 10th, 2007, 3:30 am
Posts: 93
Location: Second star to the right.... watching you.
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 15th, 2009, 7:14 am 
Offline

Joined: November 10th, 2007, 3:30 am
Posts: 93
Location: Second star to the right.... watching you.
Whatever you do, don't read the post prior to this one.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Nice
PostPosted: August 6th, 2009, 6:54 pm 
Offline

Joined: January 21st, 2009, 5:49 pm
Posts: 176
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. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Bug report
PostPosted: October 7th, 2009, 8:46 pm 
Offline

Joined: October 19th, 2008, 2:56 am
Posts: 7
Location: Kielce, Poland
I have 2 hotkeys:
Code:
~LButton & MButton:: Send #d
~LButton & !Left:: Send #w

After autoindentation they dissapear.
What's the cause?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 16th, 2009, 11:20 pm 
Offline

Joined: January 21st, 2009, 5:49 pm
Posts: 176
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. :)

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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 1:25 am 
Offline

Joined: January 21st, 2009, 5:49 pm
Posts: 176
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2009, 8:57 am 
Offline

Joined: September 9th, 2008, 11:13 am
Posts: 133
Love this script and use it all the time, thx :D

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
  }


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2010, 1:19 pm 
Offline

Joined: July 31st, 2008, 10:27 pm
Posts: 336
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!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 63 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Google Feedfetcher, Rajat and 55 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group