Re: GeekDude's tips and tricks
Posted: 23 Oct 2017, 11:48
For the first one, Dummy is static (a type of local where the value isn't erased when the function ends) to the MyFunction function, so you can only access it from inside MyFunction's body. From my tests, the behavior of static which is being used here for auto-run doesn't apply to global, so you'd need to trick it a bit if you want to set a global value in your function.
For the second one, you need to use the new Q/Quotes option on the continuation section, to disable automatic quote escaping.
You'll need to do this to make it work:
Code: Select all
MyFunction()
{
global MyGlobal ; Makes MyGlobal global
static Dummy := MyGlobal := MyFunction() ; Makes Dummy static, and sets both it and MyGlobal to the result of MyFunction
MsgBox, I see you %A_UserName%
wow := "oops " A_Now
return wow
}
MsgBox, % MyGlobal
For the second one, you need to use the new Q/Quotes option on the continuation section, to disable automatic quote escaping.
Right now, it's treating your expression as if you put this:Quotes (or Q): Restores the ability to terminate quoted strings when an expression is used in a continuation section.
Code: Select all
MyObject := {math: `"fun`",english: `"boring`",coding: `"exciting`"}
Code: Select all
MyObject :=
( LTrim Quotes Join
{
math: "fun",
english: "boring",
coding: "exciting"
}
)