Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Variable scope #475676
01/03/19 03:59
01/03/19 03:59
Joined: Jan 2019
Posts: 12
F
First Offline OP
Newbie
First  Offline OP
Newbie
F

Joined: Jan 2019
Posts: 12
If I set variables in the 1st execution of the run() function, will the variables retain their 1st run values on subsequent runs of the run() function or do I need to somehow make them global so they cannot be changed between subsequent runs of the run() function?

Re: Variable scope [Re: First] #475677
01/03/19 04:15
01/03/19 04:15
Joined: Feb 2017
Posts: 1,729
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,729
Chicago
Use static to retain latest value, else it is lost once it goes out of scope.

Re: Variable scope [Re: AndrewAMD] #475679
01/03/19 04:24
01/03/19 04:24
Joined: Jan 2019
Posts: 12
F
First Offline OP
Newbie
First  Offline OP
Newbie
F

Joined: Jan 2019
Posts: 12
I am using static, however, I set the value after its initalization in the 1st run of the the run() function.

On subsquent runs of the run() function as set by the BarPeriod = 30, will Price be zero or the value from priceHigh() set in the first iteration of the run() function?

I need it to be the value from priceHigh() in the first iteration.

In the run() function:

static var Price = 0;

Price = priceHigh();


Last edited by First; 01/04/19 01:12.

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1