Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Clean Up Code


  • Please log in to reply
58 replies to this topic
PressingOnAlways
  • Guests
  • Last active:
  • Joined: --
Hello,

I find it very hard to code in AutoHotKey.... You don't know whether to use if with commas or () or if, then, or if {}... I think if you standardize your code some, it'd be much easier to write code in AHK...

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Thanks. The requirement for parentheses around an if-statement's condition will probably be removed in v2.

xXJa50nXx
  • Members
  • 32 posts
  • Last active: Jul 19 2007 03:29 AM
  • Joined: 19 Oct 2006
will be removed or not required.
I personaly like it being a c programmer.

Jason

.AHK
  • Members
  • 657 posts
  • Last active: Nov 27 2008 04:10 AM
  • Joined: 26 Apr 2006

Thanks. The requirement for parentheses around an if-statement's condition will probably be removed in v2.

Is this what you are talking about?
If var = 1 OR var = 10
; Instead of
If (var = 1 OR var = 10)
; ?


PressingOnAlways
  • Members
  • 17 posts
  • Last active: Mar 14 2007 05:35 PM
  • Joined: 27 Oct 2006
isn't it like if you have parenthesis, you have to put "" around strings? The examples in the help files were very inconsistant and not thoroughly defined....

.AHK
  • Members
  • 657 posts
  • Last active: Nov 27 2008 04:10 AM
  • Joined: 26 Apr 2006

isn't it like if you have parenthesis, you have to put "" around strings? The examples in the help files were very inconsistant and not thoroughly defined....

Yes, if the string is not purely numeric it requires double quotes. This is because the parenthesis sets the If statement to an expression.

Read the posts of this link it should help you understand.
http://www.autohotke...pic.php?t=13651

foom
  • Members
  • 386 posts
  • Last active: Jul 04 2007 04:53 PM
  • Joined: 19 Apr 2006

Thanks. The requirement for parentheses around an if-statement's condition will probably be removed in v2.


OMG. I'd rather have it forced to have parentheses around the condition. Its just more readable. Now if you make it optional this could again irritate newbies. I know you want not to break compatibility, but seriously that could be fixed easy in existing ahk scripts. In my humble opinion backwardcompatibility should be discarded at all for v2 since ahk scripts aren't rocketscience and can be fixed easily to suit the new syntax.

There are many more things i don't like in ahk syntax, like escaping " in strings with another ". Generally speaking that characters in special cases cant be escaped with the escape char is ambiguous.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

OMG. I'd rather have it forced to have parentheses around the condition. Its just more readable.

Because you are used to it, but since no instruction can follow the If on the same line, they are just unecessary. And as long as they are legal, you can stick to the policy to always put them. Of course, you will read lot of script omitting them...

There are many more things i don't like in ahk syntax, like escaping " in strings with another ". Generally speaking that characters in special cases cant be escaped with the escape char is ambiguous.

Well, this syntax comes from Basic (VB?), IIRC. But indeed, the lack of consistency with backquote escape is annoying.
Designing a language is difficult... :-)
Many people want to break compatibility and make major overhauls to the language. But if Chris wanted to have a C-like language, he would have just sticked to AutoIt3...

I rekon that double syntax (a = b vs. a := "b" / If a = b vs. If (a = "b")), coming from the welcome introduction of the expressions in the language, while keeping the old syntax for compatibility and simplicity is a major source of trouble for newbies.
But it seems that lot of people would protest if they are forced to enclose their strings between quotes...
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

.AHK
  • Members
  • 657 posts
  • Last active: Nov 27 2008 04:10 AM
  • Joined: 26 Apr 2006

But it seems that lot of people would protest if they are forced to enclose their strings between quotes...

So why not just leave it how it currently is? In my opinion, I think it is setup good, and easy to follow.

There are many more things i don't like in ahk syntax, like escaping " in strings with another ". Generally speaking that characters in special cases cant be escaped with the escape char is ambiguous.

What your saying is that instead of...
var := "this string has a "" double quote."
Have it like this...
var := "this string has a `" double quote."
?
I think thats a good idea, although it would break existing scripts, so probably best for v2.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

will be removed or not required.

You would still use parentheses if you wish. In other words, both of the following would be okay in v2:
if x = 5 and y = 6  ; Only allowed in #v2.
if (x = 5 and y = 6)  ; Allowed in either v1 or v2.

isn't it like if you have parenthesis, you have to put "" around strings? The examples in the help files were very inconsistant and not thoroughly defined....

The bottom line is the following info from the expressions section: An if-statement that contains an expression is differentiated from a traditional if-statement such as If FoundColor <> Blue by making the character after the word "if" an open-parenthesis. Although this is usually accomplished by enclosing the entire expression in parentheses, it can also be done with something like if (x > 0) and (y > 0). In addition, the open-parenthesis may be omitted entirely if the first item after the word "if" is a function call or an operator such as "not" or "!".

In any case, this confusion will all be gone for scripts that opt to use the #v2 directive because there won't be any such thing as traditional IF-statements anymore; they'll all be expressions.

backwardcompatibility should be discarded at all for v2 since ahk scripts aren't rocketscience and can be fixed easily to suit the new syntax.

That's exactly the reason for having v2: to improve the language at the expense of sacrificing some backward compatibility. There will probably be a conversion utility that makes it easy to upgrade old scripts to the new syntax (the new syntax won't be much different anyway).

There are many more things i don't like in ahk syntax, like escaping " in strings with another ". Generally speaking that characters in special cases cant be escaped with the escape char is ambiguous.

I'll take a look at allowing `" to stand for a quote in v2. Thanks for the idea.

But it seems that lot of people would protest if they are forced to enclose their strings between quotes...

Having two types of IF-statements and two types of assignments (= and :=) are probably the biggest source of confusion and bugs in scripts (other than misspelled variable names). So getting rid of the old versions seems like the lesser of two evils.

Thanks for the ideas.

foom
  • Members
  • 386 posts
  • Last active: Jul 04 2007 04:53 PM
  • Joined: 19 Apr 2006

OMG. I'd rather have it forced to have parentheses around the condition. Its just more readable.

Because you are used to it, but since no instruction can follow the If on the same line, they are just unecessary. And as long as they are legal, you can stick to the policy to always put them. Of course, you will read lot of script omitting them...

I doubt that the majority prefers to omit the parentheses. But thats just my opinion and since it will be treated as expression anyway i wont argue about it anymore since it will be only a matter of gusto and you can't argue about that.

However the inconsistentcy in the syntax of ahk is errorprone for ahknewbies. And i have this info from an fellow who i told about ahk a few days ago. I wanted to enthuse him about ahk and started to introduce him to variable assignment first but very soon i realised how confusing this, for a ahknewbie like him, is.

Having two types of IF-statements and two types of assignments (= and :=) are probably the biggest source of confusion and bugs in scripts (other than misspelled variable names). So getting rid of the old versions seems like the lesser of two evils.

Will the assignment-operator be = with the functionality of :=?

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

Will the assignment-operator be = with the functionality of :=?

That's the current plan.

JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004

Having two types of IF-statements and two types of assignments (= and :=) are probably the biggest source of confusion... So getting rid of the old versions seems like the lesser of two evils.

...I'm not sure "having" both is confusing but the docs are confusing ("documenting" both)...when you added expressions you added some "side-notes" talking about the new expression syntax, leaving the examples mostly unmodified or one example shows one way (the old way) & another shows the new way, without clearly explaining all the differences...or telling the new user which they should focus on learning...users like me pick which way they wanna do it, but some newbies can't decide & just get confused when 2 different ways exist...or are mentioned in the docs...for example...IfEqual syntax is an old left-over pile of dung (sorry) from AutoIt 2...I've never used it cuz when I joined AHK you already had non-expression if...the docs on if say...

IfEqual, var, value (same: if var = value)
...while this is compact, it's not very clear (not to mention the title of that page is confusing)...adding "same:" doesn't explain why both work or anything about it...people might decide to use IfEqual cuz it's listed 1st or looks like the more suggested way to code...(since normal if syntax is just a sidebar in parens)...then they come to the forum & see good code & it fries their brain...seeing if with & without parens...mixing the 2 & getting that "dynamic variable is blank" message (nice helpful message, but not for a newbie that was just trying to "if" & don't know what a "dynamic variable" is {hehe...perhaps you should revise that error message..."dynamic variable is blank...or you fscked up your expression-if...REMOVE THE PERCENT SIGNS %var% -> var..."})...I'm not really dogging on you or the docs...just compiling the confusion I've seen newbies express...I understand all of AHK (I think) but I just am that way with comps...I sit down for 5 mins with a new prog & I know how it works. I really wanna try to redo the docs someday, but I don't know if I wanna start with a blank page & add my thoughts or start editing & reformatting the existing docs...I'm certainly getting rid of that yellow bar...if favor of some other color...BTW...is there any reason the docs all end with .htm & not .html?

Will the assignment-operator be = with the functionality of :=?

That's the current plan.

...YIKES!...expressions & continuation sections are enemies...when I needed to write a replacement msgbox function I had to settle on this calling convention to turn off expressions for the function call...I would like most of := to be = (I think) but I need a way to turn off expressions for continuation sections...perhaps NoExp in the options (like LTrim)...
Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?

PressingOnAlways
  • Members
  • 17 posts
  • Last active: Mar 14 2007 05:35 PM
  • Joined: 27 Oct 2006
I noticed AutoHotkey is based off AutoIt... correct? Is there any plans to backport the v3 version of AutoIt to AutoHotkey? v3 of Autoit has grown to a very consistant language instead of a confusion of commas and {} and ()... Also, I noticed there are some new features in AutoIt like the ability to connect to OCX to control other applications and such... Is there any plans for this or is this like impossible?

JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004

...v3 of Autoit has grown to a very consistant language...

...no...it's just too picky of a language...I like a language that makes sense, but doesn't require the programmer to do unnecessary things...like in C...EVERY ****ing line ends with semi-colon...no!...overkill...in JavaScript you can use them for a purpose...more commands on one line, but they aren't required...so there are things I wish AHK would do, but there are more things I hope AHK never does...being very rigid in syntax for one...

Wish AHK would...
[*:ggbvis6b]use semi-colon for more things on one line (& change comment char)

wow=1;wee="wee"         //comment
[*:ggbvis6b]require parens on expression-if to allow for commands on same line...

if (wow="wee") msgbox, hi!
[*:ggbvis6b]use == instead of = in if (& as a result allow assignments in if)

if (wow=[color=blue]=[/color]"wee") msgbox, hi!
Hope AHK never...[*:ggbvis6b]gets too rigid & annoying in syntax...my wishes add some rigidity to the syntax, but they each have a purpose...adding something in exchange for rigidity...
Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?