I am trying to grab a list of files through the Pick File() function.
I want to loop through the list of files and for each file I want to perform a stack, calculate some statistics from a column in the stacked data table, then use the calculated values to update an existing data table.
(The list of files is a list of production lots and I am trying to create a script that trends the mean, stdev, and CPK of the production lots)
When I only look at one file I can get the above steps to work but as soon as I try multiple files I cannot seem to get it to work. The for loop looping through the files only runs once. I have placed a show(i==NItems(lst)) statement and it even shows that the condition for the loop is not met.
Below is an excerpt with the for loop in question.
get_lst_loop = Function({files},
Local({tmp,lst,dt,dt_stack},
Try(
tmp = {};
For(i=1,i<=NItems(files),i++,
show(i==NItems(files));
dt = Open(files[i],Invisible);
dt_stack = bRay_stack(dt);
lst = get_lst(dt_stack,"Data");
Close(dt_stack,NoSave);
Close(dt,NoSave);
Insert Into(tmp,lst)
);
,
Throw("Error in making analysis matrix: "||char(exception_msg));
);
Return(Eval List(tmp));
);
);I will attach the rest of the script and a few testing files to this post.
I have tried a number of different things to get around this but nothing seems to be working.
If there is a better way to accomplish what I am trying please let me know.