Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Akow, 1 invisible), 1,423 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Static variables #475674
01/03/19 03:25
01/03/19 03:25
Joined: Jan 2019
Posts: 12
F
First Offline OP
Newbie
First  Offline OP
Newbie
F

Joined: Jan 2019
Posts: 12
I have a static variable declared in the run() function and I initialize it to 0 - static var Price = 0;

From the help menu it implies that the value cannot be set there after - "keeps its content when the function terminates or when another instance of the function is called.".

However, I then issue a set of the static variable - Price = priceHigh();
and the static variable is set to the value returned.

Why? This is not supposed to happen.

Last edited by First; 01/03/19 03:26.
Re: Static variables [Re: First] #475675
01/03/19 03:47
01/03/19 03:47
Joined: Feb 2017
Posts: 1,731
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,731
Chicago
A static variable is more like a global variable, insofar as its existence and value is maintained between function calls. You can still change its value after initialization.

If you do not want a value to change, use const.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1