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 

I wish AHK commands were case-sensitive (ode to OCD)
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> General Chat
View previous topic :: View next topic  
Author Message
Ace_NoOne



Joined: 10 Oct 2005
Posts: 299
Location: Germany

PostPosted: Thu Jan 11, 2007 12:27 pm    Post subject: I wish AHK commands were case-sensitive (ode to OCD) Reply with quote

Warning: Flamebait!

Due to my (pseudo-)OCD, I feel compelled to remain consistent in writing code.
Among other things, that means that I attempt to stick to a certain style of capitalization (e.g. always capitalize the first letter of AHK commands, e.g. "If" instead of "if") - which also happens to improve readability.

However, I sometimes forget which style I'd agreed upon (with myself, natch) in a particular situation - e.g. whether only the first letter of "down" in {LAlt Down} should be capitalized, or whether it should be the whole word ("{LAlt DOWN}").

Unfortunately, AHK is way too forgiving - I wish it would enforce a certain way of capitalization.
I know that's selfish and kinda irrational - but don't blame me, blame my mind!

Anyways, I'm off to scrub the floors, and disinfect window sills, and clean up my desk, and ... *boom*
_________________
Improving my world, one script at a time.
Join the AutoHotkey IRC channel: irc.freenode.net #autohotkey


Last edited by Ace_NoOne on Thu Jan 11, 2007 12:36 pm; edited 1 time in total
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Thu Jan 11, 2007 12:33 pm    Post subject: Reply with quote

Quote:
that means that I attempt to stick to a certain style of capitalization (e.g. always capitalize the first letter of AHK commands, e.g. "If" instead of "if") - which also happens to improve readability.
Yeah! Confirmed. Cool
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6723
Location: France (near Paris)

PostPosted: Thu Jan 11, 2007 12:45 pm    Post subject: Reply with quote

At least you put that in the General Chat section, not the Wish List one! Smile
Obviously, the permissiveness of AHK is ideal for its target audience: beginners.
Sometime I feel lazy and type msgbox for a line that will go away, but indeed I tend to capitalize according to case shown in AHK's manual.
Note that a solution is the one used by Visual Basic's IDE: let the user type any way he wants, but as soon as he types a separator, change the case if needed.
Of course, it needs to be done with your favorite editor. I suppose I could make a Lua script for SciTE to do that...
Another way is to have a simple script processor: for each keyword found, change case. Problem: some keywords are common English words (Right, Cancel, Focus...) and it is very hard to limit changes to keywords and not changing strings or comments...
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Ace_NoOne



Joined: 10 Oct 2005
Posts: 299
Location: Germany

PostPosted: Thu Jan 11, 2007 1:38 pm    Post subject: Reply with quote

BoBo wrote:
Quote:
that means that I attempt to stick to a certain style of capitalization (e.g. always capitalize the first letter of AHK commands, e.g. "If" instead of "if") - which also happens to improve readability.

Yeah! Confirmed.
Surprised Don't agree with me - it's not healthy!

PhiLho wrote:
At least you put that in the General Chat section, not the Wish List one! Smile
Well, since I don't have a blag, I figured this was the place to publish my ramblings...
PhiLho wrote:
Obviously, the permissiveness of AHK is ideal for its target audience: beginners.
Pff - screw the nubs! Wink
PhiLho wrote:
Note that a solution is the one used by Visual Basic's IDE: let the user type any way he wants, but as soon as he types a separator, change the case if needed.
Good idea! Now I just need PSPad to do that... (I only use SciTE as a Notepad replacement, or if I need to quickly edit a tiny bit of code.)
_________________
Improving my world, one script at a time.
Join the AutoHotkey IRC channel: irc.freenode.net #autohotkey
Back to top
View user's profile Send private message
Thalon



Joined: 12 Jul 2005
Posts: 632

PostPosted: Fri Jan 12, 2007 9:36 am    Post subject: Reply with quote

Is there any need for this change?
I don't see any unreadable in the difference between IF, If or if or WINWAITACTIVE against WinWaitActive or winwaitactive. Or course they look a bit different at the first look and I prefer the second one, but the really unreadable scripts are those with one-capital variables, sometimes completely others with only one capital more.
There are also some other things that make things hardly readable without further investigation or comments (you'll find some good examples after Goyyah's sry SKAN's pointer-explanation Wink )

I'm afraid of using "If" against "if", it doesn't fit my eye and I have to use 50% more keys for this often used word!
I'm using the style in help most of the time, but for quick and dirty programs I don't want to spend one thought at capitalization (and I'm writing such scripts very often Very Happy )

(means: "Against it")

Thalon
_________________
AHK-Icon-Changer
AHK-IRC
deutsches Forum
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Fri Jan 12, 2007 10:09 am    Post subject: Reply with quote

Quote:
I don't see any unreadable in the difference between IF, If or if or WINWAITACTIVE against WinWaitActive or winwaitactive.
Yeah, because you know that the above if means If and not if, if it not means if or If or if, If if is meant! What makes it complicated to create an AutoCommandCapser (command or common word identification), is exactly what your brain has to accomplish. Fortunately in most of the cases you'd be able to make it, unfortunately that won't change the issue. Even if you deny it, it's tougher for you (means your brain) to a read/decrypt mixed mode text.

Wenn fliegen hinter fliegen fliegen, fliegen fliegen fliegen nach.

If it really doesn't matter you'd take this:
Wenn grillen grillen grillen, grillen grillen grillen
I'd take that:
Wenn Grillen Grillen grillen, grillen Grillen Grillen Wink

Quote:
Is there any need for this change?
IMHO, no. BTBH, Germans are used to cap Substantives and therefore it's less anoying.
Back to top
Thalon



Joined: 12 Jul 2005
Posts: 632

PostPosted: Fri Jan 12, 2007 2:46 pm    Post subject: Reply with quote

Quote:
Even if you deny it, it's tougher for you (means your brain) to a read/decrypt mixed mode text.
Yes, but not a lot. Compared with reading code in general it is a very little part.
This problem also only occures when reading foreign code, because you should be able to read your style very well!

I see more disadvantages than advantages (of course I see the little advantages for the power-user in forum). That's simply my opinion.
I'll close this discussion for me, because I don't think any reasons could change my mind here...

Thalon
_________________
AHK-Icon-Changer
AHK-IRC
deutsches Forum
Back to top
View user's profile Send private message
Darla
Guest





PostPosted: Fri Jan 12, 2007 11:25 pm    Post subject: Re: I wish AHK commands were case-sensitive (ode to OCD) Reply with quote

Ace_NoOne wrote:
Warning: Flamebait!

I know that's selfish and kinda irrational - but don't blame me, blame my mind!



Illegal syntax!!!

S/B
I know that's selfish and kind of irrational, but don't blame me, blame my mind!


Laughing
Back to top
Ace_NoOne



Joined: 10 Oct 2005
Posts: 299
Location: Germany

PostPosted: Sat Jan 13, 2007 1:51 pm    Post subject: Reply with quote

BoBo hat's mal wieder auf den Punkt gebracht! Go, BoBo!
Thalon's got a point though; if you've trained your pattern recognition to your very own style, it probably won't make a huge difference anymore.
However, that only applies to your very own self, which is kinda selfish. A style conforming to certain standards of capitalization, however, would make your code more readable for everyone (screw individuality; go universality).
But it'd be naive trying to force a certain style upon anyone - that's why I really like the way brought up PhiLho.

Either way, I'm suprised this actually turned into a serious discussion - my original posting was more of a rant than anything else...


Darla wrote:
Illegal syntax!!!
Oh, you'd better not be dissing my pathetic attempts at employing colloquialisms...
... wait, I'd better not be messin' with a Vampire, and a hot one at that... Wink

PS: I'd prefer "syntax error" over "illegal syntax"... Razz Although, if you were referring to "kinda" (instead of "kind of"), it's not really a syntax error, strictly speaking.
_________________
Improving my world, one script at a time.
Join the AutoHotkey IRC channel: irc.freenode.net #autohotkey
Back to top
View user's profile Send private message
tonne



Joined: 06 Jun 2006
Posts: 1482
Location: Denmark

PostPosted: Sat Jan 13, 2007 2:05 pm    Post subject: Reply with quote

Pattern recognition?

Quote:
Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteer be at the rghit pclae. The rset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe.

http://www.mrc-cbu.cam.ac.uk/~mattd/Cmabrigde/
_________________
there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face

- Kashmir
Back to top
View user's profile Send private message
tonne



Joined: 06 Jun 2006
Posts: 1482
Location: Denmark

PostPosted: Sat Jan 13, 2007 4:18 pm    Post subject: Reply with quote

I you ever plan to go to Cambridge...
Code:

pos = 1
loop {
  pos := RegExMatch("According to a research at Cambridge University, it","\w+",word,pos)
  if pos = 0
    break
  pos += strlen(word)
  newstr .= theCambridgeWay(word) . " "
}
msgbox %newstr%
return

theCambridgeWay(word)
{
  ret := word
  len := strlen(ret)

  if (len == 4)
  {
    t := *(&ret+1)
    DllCall("RtlFillMemory", "UInt", &ret + 1, "UInt", 1, "UChar", *(&ret+2))
    DllCall("RtlFillMemory", "UInt", &ret + 2, "UInt", 1, "UChar", t)
  }
  else
  {
    if (len > 4)
    {
      len -= 3
      mid := &ret+1
      loop
      {
        t := *mid
        Random, r, 1, %len%
        n := *(mid+r)
;       msgbox swap %a_index% %t% %r% (%n%)
        if (1 or r <> a_index)
        {

          DllCall("RtlFillMemory", "UInt", mid, "UInt", 1, "UChar", n)
          DllCall("RtlFillMemory", "UInt", mid+r, "UInt", 1, "UChar", t)
          ; msgbox %mid%
        }
        len--
        mid++
        if (len = 0)
          break
      }
    }
  }
  return ret
}

_________________
there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face

- Kashmir
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6723
Location: France (near Paris)

PostPosted: Sun Jan 14, 2007 9:13 am    Post subject: Reply with quote

tonne, this topic of scrambled letters has been raised already, it seems the text you gave has been cleverly made, not all scramblings are equally readable. Scripts to test have been given already.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
tonne



Joined: 06 Jun 2006
Posts: 1482
Location: Denmark

PostPosted: Sun Jan 14, 2007 10:55 am    Post subject: Reply with quote

Well, didn't bother to search for it (being in the General Chat - whoever this guy is - forum).
It recently popped up in my mailbox in a danish version. I will spare you for the danish text; scrambled or unscrambled it probably looks the same for most...
_________________
there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face

- Kashmir
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5042
Location: /b/

PostPosted: Sun Jan 14, 2007 11:46 am    Post subject: Reply with quote

I adopted the style Chris uses in the documentation:
  • Single tab for indentation (old format)
  • Labels unindented
  • Functions, Ifs and Loops indented
  • Capitalised command names (e.g. StringGetPos)
  • If-expressions with no parenthesis where possible (not, !, :=, fx())
Of course I have my own traits like short and easy to remember variable names, K&R style and premature optimizations.

What's yours?
_________________
Chat (IRC)PlusNetScriptsIronAHK Contact by email not private message.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
toralf



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

PostPosted: Sun Jan 14, 2007 12:04 pm    Post subject: Reply with quote

I haven't read the whole topic, but Auto-Syntax-Tidy offers the possibility to do case correction for most of AHK words.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> General Chat All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
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