How do I iterate over a list of strings in dxl?

James Mertz picture James Mertz · Mar 3, 2015 · Viewed 9.2k times · Source

I have a list of strings that I want to iterate over in dxl. They represent module ID's like so:

string limitModules[5] = ['1', '2', '3', '4', '5']

Obviously each of the module ID's are more complicated. I've constructed a for loop using the syntax of for type1 v1 in type2 v2 do. However when I run the script I get the following error:

incorrect arguments for (do)

Here's my loop exactly:

string mod_name = ""
for mod_name in limitModules do {
    // test to see if module is found
}

What am I missing?

Answer

Steve Valliere picture Steve Valliere · Mar 3, 2015

You can create a Skip List to put them in and iterate over it that way (see skip lists in the DOORS DXL Help).

Or if you need to use the String array that way you can use the following:

for(i = 0; i < 5; i++)
{
  mod_name = limitModules[i]
  // other code here
}

This method is fine if you know the size of the array. However skip lists are more efficient for this sort of thing.