AutoHotkey Community

It is currently May 27th, 2012, 9:58 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: January 11th, 2007, 12:27 pm 
Offline

Joined: October 10th, 2005, 10:44 am
Posts: 299
Location: Germany
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 January 11th, 2007, 12:36 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2007, 12:33 pm 
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. 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2007, 12:45 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
At least you put that in the General Chat section, not the Wish List one! :-)
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...

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2007, 1:38 pm 
Offline

Joined: October 10th, 2005, 10:44 am
Posts: 299
Location: Germany
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.
:o 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! :-)
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! ;)
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2007, 9:36 am 
Offline

Joined: July 12th, 2005, 1:21 pm
Posts: 633
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 ;) )

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 :D )

Image (means: "Against it")

Thalon

_________________
AHK-Icon-Changer
AHK-IRC
deutsches Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2007, 10:09 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2007, 2:46 pm 
Offline

Joined: July 12th, 2005, 1:21 pm
Posts: 633
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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 12th, 2007, 11:25 pm 
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!


:lol:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2007, 1:51 pm 
Offline

Joined: October 10th, 2005, 10:44 am
Posts: 299
Location: Germany
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... ;)

PS: I'd prefer "syntax error" over "illegal syntax"... :P 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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2007, 2:05 pm 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
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/

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2007, 4:18 pm 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
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
}

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2007, 9:13 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2007, 10:55 am 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
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...

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2007, 11:46 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
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?

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2007, 12:04 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
I haven't read the whole topic, but Auto-Syntax-Tidyoffers the possibility to do case correction for most of AHK words.

_________________
Ciao
toralf
Image


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: sumon and 13 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