Declaration without type on a string array with declared type

To add comments, please log in or register
Stanislav Ivanov
4181
Stanislav Ivanov  

Hi,

Im having issues with an array that will constantly return compiler error for this array.

string time1 = timeperiod1,time2 = timeperiod2,time3 = timeperiod3,time4 = timeperiod4,
time5 = timeperiod5,time6 = timeperiod6,time7 = timeperiod7,time8 = timeperiod8,time9 = timeperiod9,
time10 = timeperiod10;
string times[10];
 times[0]= time1;
 times[1]= time2;
 times[2]= time3;
 times[3]= time4;
 times[4]= time5;
 times[5]= time6;
 times[6]= time7;
 times[7]= time8;
 times[8]= time9;
 times[9]= time10;

Everything is string , I tried multiple ways, but seems to not work

Marco vd Heijden
Moderator
10977
Marco vd Heijden  
string time1 = "timeperiod1",time2 = "timeperiod2",time3 = "timeperiod3",time4 = "timeperiod4",
time5 = "timeperiod5",time6 = "timeperiod6",time7 = "timeperiod7",time8 = "timeperiod8",time9 = "timeperiod9",
time10 = "timeperiod10";
string times[10];
 times[0]= time1;
 times[1]= time2;
 times[2]= time3;
 times[3]= time4;
 times[4]= time5;
 times[5]= time6;
 times[6]= time7;
 times[7]= time8;
 times[8]= time9;
 times[9]= time10;

Strings are in double quotes "";

Unless your copying one string variable into another but you are not showing any other string values for timeperiod1 - timeperiod10

Stanislav Ivanov
4181
Stanislav Ivanov  
Marco vd Heijden:

thanks for the reply,

all the timeperiods are variables not values, so they contain other values

Marco vd Heijden
Moderator
10977
Marco vd Heijden  

In that case you need to let the compiler know that you have reached the end of a command by placing a semicolon.

So when you try to copy variables that won't work with a comma.

string time1 = timeperiod1;
string time2 = timeperiod2;
string time3 = timeperiod3;
string time4 = timeperiod4;
string time5 = timeperiod5;
string time6 = timeperiod6;
string time7 = timeperiod7;
string time8 = timeperiod8;
string time9 = timeperiod9;
string time10 = timeperiod10;
Stanislav Ivanov
4181
Stanislav Ivanov  
Marco vd Heijden:

In that case you need to let the compiler know that you have reached the end of a command by placing a semicolon.

So when you try to copy variables that won't work with a comma.

ok wil try, thanks

Stanislav Ivanov
4181
Stanislav Ivanov  
Stanislav Ivanov:

ok wil try, thanks

Still doesnt work.

string time1 = timeperiod1;
string time2 = timeperiod2;
string time3 = timeperiod3;
string time4 = timeperiod4;
string time5 = timeperiod5;
string time6 = timeperiod6;
string time7 = timeperiod7;
string time8 = timeperiod8;
string time9 = timeperiod9;
string time10 = timeperiod10;

string times[10];
 times[0]= time1;
 times[1]= time2;
 times[2]= time3;
 times[3]= time4;
 times[4]= time5;
 times[5]= time6;
 times[6]= time7;
 times[7]= time8;
 times[8]= time9;
 times[9]= time10;

Did that and  i still got the same error

Stanislav Ivanov
4181
Stanislav Ivanov  
Stanislav Ivanov:

Still doesnt work.

Did that and  i still got the same error

Ok i fixed it using a dynamic array and a loop to fill !

 Worked. Thanks

William Roeder
18697
William Roeder  
Stanislav Ivanov: #1

Im having issues with an array that will constantly return compiler error for this array.

Everything is string , I tried multiple ways, but seems to not work

  1. Don't state the error and where. There are no mind readers here and our crystal balls are cracked.
  2. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here and our crystal balls are cracked.
Stanislav Ivanov: #5

Still doesnt work.

Did that and  i still got the same error

Same statement, same answer.

Stanislav Ivanov:

Ok i fixed it using a dynamic array and a loop to fill !  Worked. Thanks

You're welcome but no one but you knows what the problem was and what you did.

Stanislav Ivanov
4181
Stanislav Ivanov  
William Roeder:
  1. Don't state the error and where. There are no mind readers here and our crystal balls are cracked.
  2. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here and our crystal balls are cracked.

Same statement, same answer.

You're welcome but no one but you knows what the problem was and what you did.

Hi, Thanks for your reply.

The error i mentioned in the headline, and i thought it was enough. By doesnt work i meant receiving the same error, and i believe you understood that

Alain Verleyen
38044
Alain Verleyen  
Stanislav Ivanov:

Hi,

Im having issues with an array that will constantly return compiler error for this array.

Everything is string , I tried multiple ways, but seems to not work

 times[0]= time1;
 times[1]= time2;
 times[2]= time3;
 times[3]= time4;
 times[4]= time5;
 times[5]= time6;
 times[6]= time7;
 times[7]= time8;
 times[8]= time9;
 times[9]= time10;

You can't assign value on the global scope. It needs to be in a function.

Stanislav Ivanov
4181
Stanislav Ivanov  
Alain Verleyen:

You can't assign value on the global scope. It needs to be in a function.

makes sense, thats the way i did it, worked, thanks

To add comments, please log in or register