We like to use the execstr to customize our variable names or expressions based on the results of calculations or strings manipulations. However it looks like iterating this function too fast may cause some issues: without a sleep(0.001) or longer, Scilab is crashing and exiting without any error message.
```scilab
// load a list of text files
[status,list1,bb] = host('dir /b /on /s ""C:\TEMP\blabla*.inp""',echo=%t);
nfiles = max(size(list1));
i=1;
while i <= nfiles
mprintf('%d/%d...\n', i, nfiles)
// load the file line by line
fd=mopen(list1(i),'r')
MyData = mgetl(fd);
mclose(fd)
nrows = size(MyData,'r');
// initialize the table
str = "MyTable" +string(i) + "= zeros(nrows,20)";
execstr(str)
for j=1:nrows
// retrieve each individual value by line
// row #j in filename(i)
rowcells = tokens(MyData(j))';
ncols = size(rowcells,'c');
temp = strtod(rowcells);
str = "MyTable" +string(i)+"(" + string(j) + ",1:ncols) = temp(1:ncols)";
execstr(str)
sleep(0.001)
end
i = i + 1;
end
mprintf("%d files done\n", nfiles)
Is there good recommendations for the use of this function? Even the ‘errcatch’ option do not prevent the silent crash from Scilab.
Thank you!