Just simple
if(someVariable == true) double v1[10] = {47.73,49.384,49.845,50.167,50.465,50.628,50.857,51.12,51.315,51.565}; else v1[10] = {44,50,49.845,50.167,50.465,50.628,50.857,51.12,51.315,51.565};
Just simple
if(someVariable == true) double v1[10] = {47.73,49.384,49.845,50.167,50.465,50.628,50.857,51.12,51.315,51.565}; else v1[10] = {44,50,49.845,50.167,50.465,50.628,50.857,51.12,51.315,51.565};
- I wouldn't think that would even compile. It does but does it work?
- You don't have to declare the size of the array, as it will default to the number of elements in the initialization. double v1[] = {...};
- If the above does not work, use
double v[10]; double v1[] = {47.73, 49.384, 49.845, 50.167, 50.465, 50.628, 50.857, 51.12, 51.315, 51.565}; double v2[] = {44,50, 49.845, 50.167, 50.465, 50.628, 50.857, 51.12, 51.315, 51.565, 0.0}; if(someVariable) ArrayCopy(v, v1); else ArrayCopy(v, v2);
- I wouldn't think that would even compile. It does but does it work?
- You don't have to declare the size of the array, as it will default to the number of elements in the initialization. double v1[] = {...};
- If the above does not work, use
It's actually kind of funny that WHRoeder has pretty much written exactly what I had originally coded (including the v1 and v2s), but the real reason for the question was to get rid of all of the ArrayCopys and make it simpler. In actual fact I have about 50 forks in the statement meaning 50 ArrayCopys.
I'm going with Tonny's solution and will see if it works. Thanks guys!
Test it first before jumping into conclusions.
It's actually kind of funny that WHRoeder has pretty much written exactly what I had originally coded (including the v1 and v2s), but the real reason for the question was to get rid of all of the ArrayCopys and make it simpler. In actual fact I have about 50 forks in the statement meaning 50 ArrayCopys.
double v1[2][10] = {47.73, 49.384, 49.845, 50.167, 50.465, 50.628, 50.857, 51.12, 51.315, 51.565, 44,50, 49.845, 50.167, 50.465, 50.628, 50.857, 51.12, 51.315, 51.565, 0.0}; if (v1[selector][anIndex]) ..You can go two dimensions.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The following is valid.
double v1[10] = {47.73,49.384,49.845,50.167,50.465,50.628,50.857,51.12,51.315,51.565};
The following is not valid.
double v1[10];
v1 = {47.73,49.384,49.845,50.167,50.465,50.628,50.857,51.12,51.315,51.565};
Any ideas how to make it valid? The reason why I ask is that I want to use conditional logic to populate it - eg
double v1[10];
if (someVariable == true)
v1 = {47.73,49.384,49.845,50.167,50.465,50.628,50.857,51.12,51.315,51.565};
else
v1 = {44,50,49.845,50.167,50.465,50.628,50.857,51.12,51.315,51.565};