Parameters and splitting them into a list

I’m attempting to take a parameter from a keyword driven CSV file. The line that is giving me a bit of bother is…

new,selection,tableCustomer\fieldCarOwnership\porsche,

What the script attempts to do is create a new selection using the DB field porsche which is located in the table customer and the field CarOwnership.

The following code is failing with the error message…

Runtime error at line 49: STSubListException - Invalid value (sublist is not a single value)

put param(3) split by "\" into dbStructure

repeat for first 2 items of dbStructure
  scrollTo "ADS\workspaceADS", "ADS\" & it
  doubleClick "ADS\" & it
end repeat

The first line is line 49 btw.

As far as I’m aware, param(3) is “tableCustomer\fieldCarOwnership\porsche” and it gets put into a list called “dbStructure” as the following items…

tableCustomer
fieldCarOwnership
porsche

Have I done something wrong? :oops:

Okay, it took a little bit of digging to figure out the problem here! It turns out that the source of the error is the repeat statement.

The way it’s written, SenseTalk is seeing it as a “repeat for x” statement that will repeat x times (but x in this case is the first 2 items of a list, not a number). In this particular case, the reporting of the error is terrible – not only does it give a very confusing error message, but for some reason it reports the error on the previous line of the script! We will look into improving this!

Meanwhile, what you really want is a “repeat for each” statement (the word “each” is critical to iterate over a series of items). So your repeat statement should look like this:

repeat for each of the first 2 items of dbStructure 
  scrollTo "ADS\workspaceADS", "ADS\" & it 
  doubleClick "ADS\" & it 
end repeat

I hope that helps. Good luck!

I have to say, I was a little confused by the error message and now that I know it was reporting an error on the wrong line I didn’t really stand much of a chance!

Anyway thanks for your help, that sorted it.

Cheers. :smiley: