confusion about the behaviour of the variables - page 2

 
wlad:

wrong - there is no initialisation

Here is a proof from the help

Global variables are initialized only once right after the program is loaded into the client terminal memory.

it's not initialization at all, it's a variable change

please read the code carefully

Also print the reason for deinitialisation in init() in the log. Then you will understand why initialization happens.
 
valenok2003:

You always have StringVal condition != backup and firsttime will always be true, because it (init) is started only once EVERY time the EA is started, and a new start is made when you change the tf window or when you change the set when the terminal starts.

That's not what you mean.

because you didn't read the posts carefully.

The problem occurs when extern string Value

the second variable also changes when the first one changes

all the time

it should be changed only once

 
artmedia70:
And write the reason for deinitialization in init() in the log. Then you will understand why the initialization happens.

what are you talking about?

forget about the initialization

Take the last example without init() and test

Why are you talking nonsense if you do not understand what I mean?

 
wlad:

what are you talking about?

forget about the initialization

take the last example without init() and test it

Why are you talking nonsense if you don't understand what we're talking about?



Either break your neck further or read why variables are initialized when input parameters are changed.

"... Global variables are initialised only once after the program is loaded into the client terminal's memory... "

What you've highlighted in red and the thickness of the font - it doesn't give you a guarantee that after changing the value of an external variable, it won't initialize again as it did at first startup. You can even change the font size in messages. But initialization will still happen, even if you remove init() from the program.

 
wlad:

that's not what you mean

because you didn't read the post carefully.

The problem occurs when extern string Value is changed

and the second variable also changes when the first one is changed

all the time

and should only be changed once




once EVERY time you start the EA, and it starts every time you change this variable and press OK

what do you mean by "load the program into the client terminal memory..."??? when did you compile the code?

 
artmedia70:

Either break your spears further, or read why variables are initialised when input parameters are changed.

"... The global variables are initialised once, immediately after the program is loaded into the client terminal memory... "

What you highlighted in red and the thickness of the font - it does not give you a guarantee that after changing the value of an external variable it won't initialize again as it did at first startup.

why reply if you don't read your posts carefully?

2. The variable is not initialized, it takes the value of 1.

If you are too lazy to test it, don't waste your time.

If you want to help, I'd be grateful!

Read your posts carefully and test it.


where did you get this from?

it doesn't guarantee that after you change the value of an external variable, it won't re-initialize like the first run.

I haven't seen any re-initialisation of global variables yet

 
wlad:

Why answer if you don't read the posts carefully?

2. the variable is not initialized but takes value 1.

If you're too lazy to test it, don't waste your time.

If you want to help, I'd be grateful!

Read your posts carefully and test it.


where did you get this from?

it doesn't guarantee that after you change the value of an external variable, it won't re-initialize like the first run.

I haven't seen any re-initialisation of global variables yet


When an external variable is changed, the EA is restarted. I suggested that you display the reasons for deinitialisation in the log. You chose not to do this.
 
valenok2003:

what do you mean by "loading the program into the client terminal memory..." ?"??? is that when you compiled the code?

in this case too

you mean when the program is first attached to the chart

but I'll say it again.

it's not about initialization

read above.

 
artmedia70:
When you change an external variable, the EA is restarted. I suggested that you display the reasons for deinitialisation in the log. You chose not to do this.

why?

what will it do for me?

I know why deinitialisation happens

I change the external variable

 
wlad:

in this case, too.

it is the first time the program is attached to the chart

but I'll say it again.

It's not about initiation.

read above



Vlad, there is a mistake here, initialisation happens every time you change external parameters. And that's exactly the point, if it's about the inite.

Reason: