![]() You may be asking why ErrorLevel could even be a string, and it’s because v1 was terrible. Mostly but not completely: thread interrupts would truncate ErrorLevel strings longer than 127 characters. v1 did keep a separate ErrorLevel for each thread so at least it was mostly thread safe. You could never be 100% sure that the ErrorLevel you read came from the command you expected it. Now there’s an obvious problem with this, which is that it was global state changed by everything. If you tried calling SoundPlay but it couldn’t play the sound, AHK would set ErrorLevel to 1. V1 had a global value called ErrorLevel, which roughly mimics return codes from shell programs. Thirteen years later v2 disarmed this footgun once and for all. V1 got a generalized function if in 2009, but beginners would regularly use the command ifs instead of the function if. How do you check if a keypress k isn’t in “aeiou”? IfNotInString k, aeiou. ![]() How do you check if x is equal to 10? IfEquals x, 10. There’s still functions like MouseGetPos that assign output to its arguments but at least you now have to explicitly pass in references, like MouseGetPos &xpos, &ypos. 2 It’s just that functions were added circa 2005, so all of the existing commands stayed commands for backwards compatibility. Yes, StringUpper is implicitly defining a new variable, yes you have to assign the output if you want to do anything with it, yes v1 had regular functions too and the whole distinction is pointless. Name = Jeff StringUpper, name, tmp MsgBox Hello %tmp% !
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |