[Scilab-users] Calling a java method in a Scilab function
Samuel Gougeon
sgougeon at free.fr
Sat Dec 10 15:09:53 CET 2016
Hello Pierre,
Le 07/12/2016 10:04, Pierre Vuillemin a écrit :
> Hi all,
>
> I have to create unique IDs for some object in Scilab. For that
> purpose, someone kindly guided me towards the UUID class of java,
> which lead me to create this function in Scilab,
>
> function id = make_id()
> UUID = jimport("java.util.UUID", %f)
> tmp = jinvoke(UUID,"randomUUID")
> id = jinvoke(tmp,"toString")
> endfunction
>
> It works fine.
>
> An a priori similar function is
>
> function id = make_id_err()
> UUID = jimport("java.util.UUID", %f)
> tmp = UUID.randomUUID()
> id = tmp.toString()
> endfunction
>
> where the methods are called without jinvoke. While the instructions
> of the latter function work well in the terminal, they lead to an
> error when trying to exec the function 'make_id_err'.
>
> I was wondering if it is a normal behaviour?
No, but the bug is fixed in Scilab 6.0:
In Scilab 5.5.2:
-->endfunction
UUID = jimport("java.util.UUID", %f)
!--error 26
Récursivité trop complexe ! (Les tables de récurrence sont pleines)
at line 2 of function make_id_err called by :
tmp = UUID.randomUUID()
at line 3 of function make_id_err called by :
tmp = UUID.randomUUID()
at line 3 of function make_id_err called by :
... etc
In Scilab 6.0:
--> getversion("scilab")
ans =
6. 0. 0. 1.477D+09
--> function id = make_id_err()
> UUID = jimport("java.util.UUID", %f)
> tmp = UUID.randomUUID()
> id = tmp.toString()
> endfunction
--> make_id_err()
ans =
49e4f3f1-736a-435f-bc26-f7061f10de27
BR
Samuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20161210/810d7ba0/attachment.htm>
More information about the users
mailing list