Well, after some trials and (mainly) errors,

it seems that when saving a function which name is given by the variable function_name,

        save(function_name + ".bin", function_name)

does not work, while

         execstr("save("""function_name + ".bin""," +function_name+")")

does work.

The attached file contains a routine that goes recursively through folders in a given path to find the .sci files and create a library in a given build folder. It works as follows,

    rgenlib(lib_name, src_path, target_path)

It seems to be 'working' but produces warnings due to:
- the way binary files are saved (see above), which will change in Scilab 6 if I am correct, - the functions in the library being already loaded in Scilab for some reason.

If anyone has an insight concerning the second point, I am interested.

Best regards,


Le 12/10/2016 à 22:00, Pierre Vuillemin a écrit :

Hi all,

I am trying to make a function similar to genlib but which goes recursively through folders to find .sci files, compile them and put them in a given target build folder.

The idea is that I would like to be able to organize my 'macros' folder while still being able to generate a library. In particular, I would like to have that kind of folder organization :

- build
     <binary files should go here>
     <as well as names>
- src
     - sub-folder1
         <.sci files>
     - sub-folder n
        - sub sub folder 1
        <.sci files>
     < .sci files>

At the moment, the function (build.sce in the attached file) goes through the folders contained in the initial 'src' folder, performs an 'exec' on the .sci files that are found, and save the corresponding binary files in the target folder 'build' (at the same level as 'src'). It also generates a 'names' file containing the names of the functions in the 'build' folder.

Finally, it creates a library with the binary files contained in the 'build' folder.

Yet, when I try to use my functions, I get the following error:

  !--error 999
Overloaded load cannot occur in this context

So I guess that there is something wrong with the way I generate my library?

My binary files are generated as follows,

function_name = strsubst(fi,".sci","") // fi is the full name of the file names_to_write = [names_to_write;function_name] // used later to generate the file containing the names exec(file_path, -1) // file_path is the absolute path to my function
         save(target_path + function_name + ".bin", function_name)

and the names file is generated as,

      names_file = target_path  + "names"
       [fd, err] = mopen(names_file,"a")
       mputl(names_to_write, fd)

Best regards,

Pierre Vuillemin

users mailing list

Attachment: rgenlib.sci
Description: application/scilab-sci

users mailing list

Reply via email to