problems with "mtlb_dir" variable when porting scilab 5.6 code to scilab 6.0

classic Classic list List threaded Threaded
2 messages Options
christophk christophk
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

problems with "mtlb_dir" variable when porting scilab 5.6 code to scilab 6.0

This post was updated on .
Hi there,

I used to program in a matlab environment and made a small script some time ago that handles multiple files using "mtlb_dir". I am dealing with Excel files and found out along the way that Scilab 5.6 couldn't handle to read the new xlsx-format. (not sure whether that changed with the update to scilab 6.0). This is why I ended up writing the following code example to clear all xlsx files from the mtlb_dir list I originally created. The code worked perfectly fine before but since I upgraded to Scilab 6.0 it started to throw an error description of "Unknown field: dims".

Here is a code example to reproduce the error. The datapath actually needs to contain one or more xls-files to end up throwing errors:

datapath = "C:\";
files = mtlb_dir(datapath + "*.xls");
exception = "xlsx";
j=0;
newfiles = [];
for i=1:size(files.name)
// == T if the current file is not xlsx
    if isempty(strindex(files(i).name,exception))
        j=j+1;
        newfiles(j) = files(i);
    end
end

I realized that "files" is of type struct(Mlist) whilst i create an empty "newfiles" as a double.
That seems to be fine, however as long as I do a unindexed definition such as
newfiles = files(i); I do not quite realise why that is the case.

So I tried to solve this problem by writing "newfiles = struct;" or "newfiles = mlist;" for an empty file allocation instead of just "newfiles = []";. But that ends up giving me a variable type 130 instead of the type 17 I was aiming for.

Finally, I came up with a dirty workaround that I find very unsatisfying: I've done an if-case exception.
So instead of writing
        newfiles(j) = files(i);
I made the following changes inside the code:
        if j == 1
            newfiles = files(i);
        else
            newfiles(j) = files(i);
        end

This works for fine for j == 1 but instead thows a different error as I arrive at j = 2: "Undefined variable: mtlb_mode"

This is where I got stuck. I know I probably shouldn't use the "mtlb_dir" function as Scilab is moving away from being a matlab clone. However, I already built a huge code framework that is totally reliant on the structure that is supplied by the mtlb_dir command. In other words, I'd rather go back to Scilab 5.6 right now instead of having to go through hundreds of lines of code to get the rest of my scripts working with another file handling approach.

Please help!

Best regards,
Christoph
christophk christophk
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problems with "mtlb_dir" variable when porting scilab 5.6 code to scilab 6.0

Just realized I used the wrong function name in the subject line. It's supposed to be "mtlb_dir" instead of "mtl_mode".

Sorry for the confusion. Is there anyone out there that can comment on the error that Scilab throws in my code example?
Loading...