 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
TodWulff
Joined: 29 Dec 2007 Posts: 99
|
Posted: Sun Mar 30, 2008 7:00 pm Post subject: |
|
|
| 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 or t. My AHK.net site... |
|
| Back to top |
|
 |
toralf not logged in Guest
|
Posted: Mon Mar 31, 2008 5:53 am Post subject: |
|
|
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: 99
|
Posted: Mon Mar 31, 2008 6:31 am Post subject: |
|
|
Thanks toralf. Fully understood. Have a good one!
-t _________________ When replying, please feel free to address me as Tod or t. My AHK.net site... |
|
| Back to top |
|
 |
Starbuck
Joined: 26 Feb 2008 Posts: 12
|
Posted: Sun Jul 27, 2008 5:09 am Post subject: Bug report for v12? |
|
|
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 |
|
 |
haichen
Joined: 05 Feb 2007 Posts: 107 Location: Osnabrück, Germany
|
Posted: Sun Jul 27, 2008 2:10 pm Post subject: Re: Bug report for v12? |
|
|
| 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 |
|
 |
haichen
Joined: 05 Feb 2007 Posts: 107 Location: Osnabrück, Germany
|
Posted: Sun Jul 27, 2008 2:29 pm Post subject: |
|
|
| 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 |
|
 |
Starbuck
Joined: 26 Feb 2008 Posts: 12
|
Posted: Mon Jul 28, 2008 12:41 am Post subject: |
|
|
| 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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|