Static vs local constant.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Static vs local constant.

01 Dec 2021, 15:11

We have a function that is called via SetTimer with a period of time T.
We have a constant that is used only in that function. Its size is S bytes.
Should we make it local or static?
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
RussF
Posts: 1264
Joined: 05 Aug 2021, 06:36

Re: Static vs local constant.

01 Dec 2021, 15:29

If it is truly a constant and the value will never change, it can be local as long as it is initialized within the function each time the function is called. If the function will change that value AND you wish to retain that value between function calls, make it static.

Russ

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5 and 206 guests