Jump to content

Correct Syntax for number string concatenation


Hadrian

Recommended Posts

I have the following that i want to reference but i keep getting "t1,t2,t3,t4,t5"...where is my syntax wrong?

 

//Sample  instances
t1 = Field("Cafe Name") + " " + "November 24";
t2 = Field("Cafe Name") + " " + "November 26";
t3 = Field("Cafe Name") + " " + "November 27";
t4 = Field("Cafe Name") + " " + "November 28";
t5 = Field("Cafe Name") + " " + "Thanksgiving";

loc = "";
for (i = 1; i <= 5; i++){
loc += Str("t" + i);
}
return loc;

Link to comment
Share on other sites

I'm pretty sure your problem is:

loc += Str("t" + i);

I don't think you can reference a variable (t1) with another variable (i). Instead, perhaps you could write it as:

//Sample  instances
t = ["November 24","November 26","November 27","November 28","Thanksgiving"];

loc = "";
for (i = 0; i < t.length; i++){
loc += Field("Cafe Name") + " " + t[i];
}
return loc;

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...