Unable to reference counting variable of the outside For Loop

Unable to reference counting variable of the outside For Loop

ABajpaiWMKNX
Participant Participant
36 Views
2 Replies
Message 1 of 3

Unable to reference counting variable of the outside For Loop

ABajpaiWMKNX
Participant
Participant

[ FlexSim 23.2.0 ]

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[1]==result3[2]) 
{
cycleTimeMap[result3[3]]=result3[10];
}
}
0 Likes
Accepted solutions (1)
37 Views
2 Replies
Replies (2)
Message 2 of 3

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

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[1] == result3[2]) {
            cycleTimeMap[result3[3]] = result3[10];
        }
    }
}


Matthew Gillespie
FlexSim Software Developer

0 Likes
Message 3 of 3

ABajpaiWMKNX
Participant
Participant
Aw man! I was beating my head! Such a silly mistake. thanks
0 Likes