Execstr crashing

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!

Hello @ericlepen

This problem seems similar to an issue that will be fixed in next version: https://gitlab.com/scilab/scilab/-/merge_requests/1785

Can you try with a development version and see if the crash is fixed on your use-case?

Best regards,
Vincent

Hello @vincent.couvert,

I tried the version scilab-branch-main-de137b1a.bin.x64 from here (your link is not working for me): https://gitlab.com/scilab/scilab/-/jobs/17099142909 and it solves the problem! My script can run so fast with no crash :slightly_smiling_face: I’m excited to update to the 2027 version soon! Thanks
Eric

1 Like

Scilab 2027.0.0 has been released: https://scilab.discourse.group/t/scilab-2027-0-0-highlights-what-s-new/

Enjoy!