[Scilab-users] Clone a function, continued
Stéphane Mottelet
stephane.mottelet at utc.fr
Wed Feb 28 18:55:41 CET 2018
Le 28/02/2018 à 18:48, Samuel Gougeon a écrit :
> 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
>
Already tried this one with fun2.bin as a copy of fun1.bin. I noticed
that under scilab 5.5.2,
* Define fun1()
* fun2=fun1
* save("fun1.bin",fun1)
* save('fun2.bin',fun2)
gives a fun2.bin different from fun1.bin as the string "fun1" appears in
fun1.bin and "fun2" appears in fun2.bin
S.
> A bad end.
> It is likeky vain to go on fighting without Antoine Elias advices and
> comments :)
>
> Samuel
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180228/30ec3ede/attachment.htm>
More information about the users
mailing list