Avoid declaring Global Variables Inside functions by declaring Static Variables instead

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
V for Vendetta
Posts: 105
Joined: 29 Sep 2016, 11:33

Re: Avoid declaring Global Variables Inside functions by declaring Static Variables instead

30 Nov 2016, 11:21

nnnik wrote:If you would be so kind as to add more text then everyone would be happy.
Nah, everybody is happy here! You are the only one unhappy!
nnnik wrote: As it is now nobody understands that much anyways.
Not everybody has problems in understanding things as you have!

You can't even understand such a simple script as this one is, so my friend, you have a serious problem! (and yet you are an Admin! Haha!)
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Avoid declaring Global Variables Inside functions by declaring Static Variables instead

30 Nov 2016, 14:15

V for Vendetta wrote:
nnnik wrote:If you would be so kind as to add more text then everyone would be happy.
Nah, everybody is happy here! You are the only one unhappy!
People have troubles accepting this as tutorial because compared to other tutorials it doesn't have that much content or doesn't cover a very general use case.
If you compare this tutorial to others within this section ( e.g. take my !42 tutorial) you will see what I mean.
This kinda makes me want to consider if the content provided here is worth the place it takes up in this Section :)
Recommends AHK Studio
guest3456
Posts: 3469
Joined: 09 Oct 2013, 10:31

Re: Avoid declaring Global Variables Inside functions by declaring Static Variables instead

30 Nov 2016, 14:28

nnnik wrote: People have troubles accepting this as tutorial because compared to other tutorials it doesn't have that much content or doesn't cover a very general use case.
If you compare this tutorial to others within this section ( e.g. take my !42 tutorial) you will see what I mean.
This kinda makes me want to consider if the content provided here is worth the place it takes up in this Section :)
this thread was originally in Scripts and Functions, and the OP was infuriated at the suggestion that it didnt belong. it was then moved here

User avatar
V for Vendetta
Posts: 105
Joined: 29 Sep 2016, 11:33

Re: Avoid declaring Global Variables Inside functions by declaring Static Variables instead

30 Nov 2016, 16:04

nnnik wrote:
V for Vendetta wrote:
nnnik wrote:If you would be so kind as to add more text then everyone would be happy.
Nah, everybody is happy here! You are the only one unhappy!
People have troubles accepting this as tutorial because compared to other tutorials it doesn't have that much content or doesn't cover a very general use case.
If you compare this tutorial to others within this section ( e.g. take my !42 tutorial) you will see what I mean.
This kinda makes me want to consider if the content provided here is worth the place it takes up in this Section :)
You can't even understand an easy script example, and yet you write Tutorials? This is really funny!

Believe me, I myself refuse to read any Tutorial of yours! Thanks, but I dismiss them!
User avatar
V for Vendetta
Posts: 105
Joined: 29 Sep 2016, 11:33

Re: Avoid declaring Global Variables Inside functions by declaring Static Variables instead

30 Nov 2016, 16:09

guest3456 wrote:
nnnik wrote: People have troubles accepting this as tutorial because compared to other tutorials it doesn't have that much content or doesn't cover a very general use case.
If you compare this tutorial to others within this section ( e.g. take my !42 tutorial) you will see what I mean.
This kinda makes me want to consider if the content provided here is worth the place it takes up in this Section :)
this thread was originally in Scripts and Functions, and the OP was infuriated at the suggestion that it didnt belong. it was then moved here
Nah, I am very calm my friend!

but I must say that you are the one who seem to be a little bit "infuriated" sometimes:
https://autohotkey.com/boards/viewtopic ... 42#p114742

Calm down my friend! Just relax a little bit!
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Avoid declaring Global Variables Inside functions by declaring Static Variables instead

30 Nov 2016, 16:49

Who would try to get the value of a global variable using a function?

FYI, a simplified version:

Code: Select all

vendetta = rather funny

Test()

;these variables from the main script are all blank except 'vendetta'
msgbox, 0, Global scope, % Addition "`n`n" Test "`n`n" Auto "`n`n" Code "`n`n" Lol	"`n`n" vendetta
;these variables retrieve values defined within the function???
msgbox, 0, Function, % Test("Addition") "`n`n" Test("Test") "`n`n" Test("Auto") "`n`n" Test("Code") "`n`n" Test("Lol") "`n`n" Test("vendetta")

Test(GetStaticVarValue := "")	;___________ Test (Function) ____________
{
   static Addition, Test, Auto, Code, Lol
	if GetStaticVarValue !=		;if "GetStaticVarValue" is not blank
	{
   	return, (%GetStaticVarValue%)
	}
   Addition++
   Test = Alot of test
   Auto = no manual
   Code = Script
   Lol = not funny
}
User avatar
V for Vendetta
Posts: 105
Joined: 29 Sep 2016, 11:33

Re: Avoid declaring Global Variables Inside functions by declaring Static Variables instead

30 Nov 2016, 17:00

Correction (you are the funny Guy here! Remember?):

Code: Select all

just_me = rather funny! LolLolLolLolLolLolLolLolLolLolLolLol...! 

Test()

;these variables from the main script are all blank except 'just_me'
msgbox, 0, Global scope, % Addition "`n`n" Test "`n`n" Auto "`n`n" Code "`n`n" Lol	"`n`n" just_me
;these variables retrieve values defined within the function???
msgbox, 0, Function, % Test("Addition") "`n`n" Test("Test") "`n`n" Test("Auto") "`n`n" Test("Code") "`n`n" Test("Lol") "`n`n" Test("just_me")

Test(GetStaticVarValue := "")	;___________ Test (Function) ____________
{
   static Addition, Test, Auto, Code, Lol
	if GetStaticVarValue !=		;if "GetStaticVarValue" is not blank
	{
   	return, (%GetStaticVarValue%)
	}
   Addition++
   Test = Alot of test
   Auto = no manual
   Code = Script
   Lol = not funny
}
Flix
Posts: 7
Joined: 02 Oct 2016, 12:04

Re: Avoid declaring Global Variables Inside functions by declaring Static Variables instead

01 Dec 2016, 11:39

nnnik wrote:Topic moved.
Dear "nnnik" Great Admin, I'm really sorry that you are having difficulties in understanding this very simple thread subject at all,

but

could you please move this thread back to the proper forum section?

and by way, "nnnik" Great Admin, why are you moderating my posts now? Because I said you shouldn't write Tutorials? Haha! You are really funny, "nnnik" Tha Great Admin!

Thanks!

(You should ask somebody to draw for you in order to make you understand this simple thread subject, even if for just a little bit!)
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Avoid declaring Global Variables Inside functions by declaring Static Variables instead

01 Dec 2016, 11:42

So you want to go in the Scripts section?
As it stands this topics main post does not contain enough explinations to make it a tutorial.
Recommends AHK Studio
Flix
Posts: 7
Joined: 02 Oct 2016, 12:04

Re: Avoid declaring Global Variables Inside functions by declaring Static Variables instead

01 Dec 2016, 11:52

nnnik wrote:So you want to go in the Scripts section?
As it stands this topics main post does not contain enough explinations to make it a tutorial.
Haha! It was original posted in "Scripts" section, but I suspect that the great "just me" moderator moved it to "Tutorial" section!

Please, don't be mad with me, "nnnik" Tha Great Admin, you don't have to moderate my posts just because I told you that you shouldn't write Tutorials, the truth is that you really shouldn't in my opinion!
Flix
Posts: 7
Joined: 02 Oct 2016, 12:04

Re: Avoid declaring Global Variables Inside functions by declaring Static Variables instead

01 Dec 2016, 16:00

nnnik wrote:Thank you for your opinion.
I gave you a very wise advice, Mister Great Admin! Please don't be mad at me anymore!

Please don't moderate my posts anymore, ok?

We were having great conversations all these days, and just because I gave you a great wise advice you decide to behave like this? Are you trying to prove yourself as a tough guy? Haha!

Are you that tough in the real life too?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], mikeyww, Spawnova and 340 guests