Jump to content

AutoIt3 syntax mania


Recommended Posts

Posted (edited)

So i do a lot of unusual stuff with AutoIt, and find weird syntax as a result...

I'll start off with this:

consolewrite("test"&Chr(65)Chr(65)Chr(65)&&&@CRLF); testAAA

Maybe it is an intentional feature of AutoIt, but i believe it is just a weird glitch in the parser.

Meaning any string concatenation can be moved to the end of string:

$x = 'a'"b"'c'&&
ConsoleWrite($x & @CRLF)

Tested with 3.3.16.1

Edited by genius257
Link to comment
Share on other sites

Posted (edited)
10 minutes ago, Andreik said:

Is this working with the last AutoIt version?

Yes, 3.3.16.1, outputs "AU3" in the console.

10 minutes ago, Andreik said:

What about SciTE? Doesn't throw any compile or runtime error?

SciTE Lite is silent, dont know about full SciTE.

Edited by Werty

Some guy's script + some other guy's script = my script!

Link to comment
Share on other sites

Posted (edited)

The "1-+++-1-+++-1" part has been like that for years, Try various combinations of "---++---------+----+--+" or whatever with some numbers.

The "Chr()Chr()&&" part I didnt know about.

Edited by Werty

Some guy's script + some other guy's script = my script!

Link to comment
Share on other sites

  • 2 weeks later...

Does this count?

I at least haven't seen it listed in the help file anyway. (Maybe missed it)

Local $bTest

$bTest = ConsoleWrite("Hi!" & @CRLF) = 5
ConsoleWrite($bTest & @CRLF)

 

LibreOffice UDF  ; Scite4AutoIt Spell-Checker Using LibreOffice

Spoiler

"Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."

 

Link to comment
Share on other sites

Posted (edited)

Here is another:

$x = 1 ? 1 : 0 : 0 : 0 : 0 : 0

Au3Check complains, but it works at runtime

The ternary expression will still work as expected.

Tested with 3.3.16.1

Edited by genius257
Link to comment
Share on other sites

And here is an undocumented feature i personally love ❤️ 

$t = DllStructCreate("INT a;INT b;INT c[3];")
; DllStruct values can used via dot notation
$t.a = 123
ConsoleWrite($t.a & @CRLF)
; But i recently discovered this also applies to indexed elements:
ConsoleWrite($t.c(2) & @CRLF)
$t.c(2) = 123
ConsoleWrite($t.c(2) & @CRLF)

 

Link to comment
Share on other sites

Posted (edited)

And a silly one:

Keywords like Null and Default MUST be followed with a space, when followed by operators like & and +

$x = Null+1; 
ConsoleWrite($x&@CRLF)

 

test.au3 (76) : ==> Missing separator character after keyword.: 
$x = Null+1 
$x = Null^ ERROR

Au3Check will not detect this error.

Tested with 3.3.16.1

Edited by genius257
Link to comment
Share on other sites

29 minutes ago, genius257 said:

And a silly one

I usually use spaces between operators keywords, etc, for a better reading, yet this one is ridiculous. :lol:

Link to comment
Share on other sites

2 hours ago, genius257 said:

And here is an undocumented feature i personally love ❤️

I could be mis-remembering, but I'm sure this was on the chopping block at some point years ago...

Can't find the thread now, but I think it was along the lines of reserving dot notation for object datatypes.

Link to comment
Share on other sites

3 hours ago, genius257 said:

And here is an undocumented feature i personally love ❤️ 

$t = DllStructCreate("INT a;INT b;INT c[3];")
; DllStruct values can used via dot notation
$t.a = 123
ConsoleWrite($t.a & @CRLF)
; But i recently discovered this also applies to indexed elements:
ConsoleWrite($t.c(2) & @CRLF)
$t.c(2) = 123
ConsoleWrite($t.c(2) & @CRLF)

 

There is also an undocumented bug about this notation that one must be aware of :

$t.c(2) = 123
ConsoleWrite($t.c(2) & @CRLF)
$i = 2
$t.c($i) = 321  ; does not work
ConsoleWrite($t.c(2) & @CRLF)
$t.c(($i)) = 321  ; now works
ConsoleWrite($t.c(2) & @CRLF)

 

Link to comment
Share on other sites

13 hours ago, argumentum said:

Return Value: The amount of data written.

Thanks, I do understand that, but what I meant is I haven't seen any documentation on comparing two items and it returning a Boolean directly to a variable like that, without a If/Ternary. Perhaps it's just coding common-knowledge that I missed somewhere. :)

LibreOffice UDF  ; Scite4AutoIt Spell-Checker Using LibreOffice

Spoiler

"Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...