[Scilab-users] Clone a function, continued

Samuel Gougeon sgougeon at free.fr
Wed Feb 28 18:48:49 CET 2018


Le 28/02/2018 à 16:30, Stéphane Mottelet a écrit :
> Thanks Samuel, the problem is that
>
> save('macros/%axesData_i_h.bin', '%axesData_i_h')
>
> will produce a .sod file with a .bin extension. Both formats cannot be 
> used indifferently for compiled macros of a library : in the following 
> code (that can be copy/pasted), a library is built, the "fun1" 
> function is saved in sod format, then the reference to "fun1.bin" is 
> replaced by "fun1.sod" in the lib file :
>
> path=TMPDIR+'/test/';
> mkdir(path)
> mputl('function y=fun1(x), y=x, end',path+'fun1.sci');
> genlib('test',path)
> save(path+'fun1.sod','fun1')
> doc=xmlRead(path+'lib');
> doc.root.children(1).attributes.file='fun1.sod';
> disp(xmlDump(doc))
> xmlWrite(doc,path+'lib');
> clear
> lib(TMPDIR+'/test/')
>
> The following output is obtained:
>
> !<?xml version="1.0" encoding="UTF-8" 
> standalone="no"?>                         !
> ! !
> !<scilablib name="test"> !
> ! !
> !  <macro name="fun1" file="fun1.sod" 
> md5="a50d8a8cda2cd6036306e08e61ffcbeb"/>  !
> ! !
> !</scilablib> !
>
> Emplacement des fichiers des fonctions : /.
>
> fun1
>
> -->
>
> Unfortunately, calling fun1 crashes scilab...

Last trial for today:

  * Define fun1() in fun1.sci.
  * Compile fun1.sci with genlib(): OK => fun1.bin available
  * Create fun2.bin as a hard link to fun1.bin:
    host("mklink /H fun2.bin fun1.bin")  // Windows
  * Update (by hand or code, not with genlib) the lib file:

    <?xml  version="1.0"  encoding="UTF-8"  standalone="no"?>
    <scilablib  name="testlib">
       <macro  name="fun1"  file="fun1.bin"  md5="8a3737878c543f1a5005c42122236628"/>
       <macro  name="fun2"  file="fun2.bin"  md5="8a3737878c543f1a5005c42122236628"/>
    </scilablib>

  * load the library (OK : both fun1 and fun2 are loaded):
    --> lib ./
      ans  =
    Functions files location : TMPDIR\test.
    fun1  fun2

  * fun1(1)   //=> OK
  * fun2(1)    // .... => crash

A bad end.
It is likeky vain to go on fighting without Antoine Elias advices and 
comments :)

Samuel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180228/2e1bc98e/attachment.htm>


More information about the users mailing list