GeekDude's Tips, Tricks, and Standalones

Put simple Tips and Tricks that are not entire Tutorials in this forum
GeekDude
Posts: 815
Joined: 02 Oct 2013, 22:13

Re: GeekDude's tips and tricks

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.

Code: [Select all] [Download] GeSHi © Codebox Plus

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.

Quotes (or Q): Restores the ability to terminate quoted strings when an expression is used in a continuation section.


Right now, it's treating your expression as if you put this:

Code: [Select all] [Download] GeSHi © Codebox Plus

MyObject := {math: `"fun`",english: `"boring`",coding: `"exciting`"}


You'll need to do this to make it work:

Code: [Select all] [Download] GeSHi © Codebox Plus

MyObject := 
( LTrim Quotes Join
{
math: "fun",
english: "boring",
coding: "exciting"
}
)
User avatar
derz00
Posts: 487
Joined: 02 Feb 2016, 17:54
GitHub: derz00
Location: Middle of the round cube

Re: GeekDude's tips and tricks

23 Oct 2017, 12:57

Sure enough that new option is mentioned on this page: https://autohotkey.com/v2/v2-changes.htm

Thank you for your very helpful (as usual) explanations. You've got a good handle on the language. I didn't know you even do much with v2?!
try it and see
...
User avatar
derz00
Posts: 487
Joined: 02 Feb 2016, 17:54
GitHub: derz00
Location: Middle of the round cube

Re: GeekDude's tips and tricks

23 Oct 2017, 14:12

Uhhh yes RUNIE? :P
try it and see
...
User avatar
RUNIE
Posts: 279
Joined: 03 May 2014, 14:50
GitHub: Run1e

Re: GeekDude's tips and tricks

23 Oct 2017, 14:46

I answered your question but didn't notice there was a page 2 haha smh
HotKeyIt
Posts: 1642
Joined: 29 Sep 2013, 18:35
Contact:

Re: GeekDude's tips and tricks

23 Oct 2017, 15:13

1. because it is a static and not a global variable:

Code: [Select all] [Download] GeSHi © Codebox Plus

MyFunction()
{
Static Dummy := MyFunction()
MsgBox, %Dummy% I see you %A_UserName%
wow:="oops " A_Now
return wow
}
MsgBox % MyFunction()


2.

Code: [Select all] [Download] GeSHi © Codebox Plus

MyObject := {math: "fun"
,english: "boring"
,coding: "exciting"}
User avatar
derz00
Posts: 487
Joined: 02 Feb 2016, 17:54
GitHub: derz00
Location: Middle of the round cube

Re: GeekDude's Tips, Tricks, and Standalones

08 Jun 2018, 19:01

GeekDude wrote:Find, and optionally replace, all matches of regular expression efficiently using a custom enumerator.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Thanks for sharing. I like your object-oriented coding styles :). This is very nicely done, as always
try it and see
...

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 1 guest