This is not allowed with mql4.
you have to use other method, for example use an array : var[3]
Thank's, so the problem with an array that must it be initialize by constant and not dynamically; Is it exact? otherwise explain me how can id do please?
Thank's a lot.
string Arr[3] = {Var1,var2,var3} for(i=0;i<3;i++) { print(Arr[i]); }Is that what you mean?
Cannot declare Arrays with Variables.
- https://www.mql5.com/en/forum/146422
- Some good examples in link above.
ubzen:
Cannot declare Arrays with Variables.
- https://www.mql5.com/en/forum/146422
- Some good examples in link above.
oh ok. Well the Arr declaration is to replace the OP's Var1, Var2 and Var3 declarations so he should be able to do it. I just don't know what the values are. e.g.:
string Arr[3] = {"hello","hi","how are you?"}

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I would want to know, if it's possible to call dynamically variables.
For example:
I create 3 variabless:
string Var1,var2,var3
And I call them in a loop like this:
for(i=1;i<4;i++)
{
print(var+i);
}
When I compile, i have an error:" var+i didn't declare".
Do you have solution please?
Thank's a lot for your answer.