question

Abhay Bajpai avatar image
0 Likes"
Abhay Bajpai asked Abhay Bajpai commented

Unable to reference counting variable of the outside For Loop

For some reason, the increment variable "m" does not register if I use it inside the internal for loop.

I get the following errors:

1697577929089.png

Reason for using nested for loops: I want to loop through each 'ModelName' column from UniqueModelNames table and then find that 'mth' model name in the 'temp3' table.

ChampionHomes_V8_7_autosave.fsm

Here is the code:

for (int m=1;m<result4.numRows;m++)
int Aggregated_CycleTime_PerModelName = 0;
for (int i=1; i<result3.numRows; i++) 
{ 
if (result4[m][1]==result3[i][2]) 
{
cycleTimeMap[result3[i][3]]=result3[i][10];
}
}
FlexSim 23.2.0
for loop
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Abhay Bajpai commented

You need to use curly braces to define the scope of the outer for loop.

for (int m = 1; m < result4.numRows; m++) {
    int Aggregated_CycleTime_PerModelName = 0;
    for (int i = 1; i < result3.numRows; i++) {
        if (result4[m][1] == result3[i][2]) {
            cycleTimeMap[result3[i][3]] = result3[i][10];
        }
    }
}
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Abhay Bajpai avatar image Abhay Bajpai commented ·
Aw man! I was beating my head! Such a silly mistake. thanks
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.