[scilab-Users] test if a scilab macro exists or not

Calixte Denizet calixte at contrib.scilab.org
Sun Jun 12 16:06:25 CEST 2011


Le dimanche 12 juin 2011 à 15:47 +0200, rouxph a écrit :
> Hi,
> 

Salut Philippe,

> 
> i need to test existence of "deprecated/obsolete" functions in scilab.
> i've believed that it was possible with "exists" or "isdef" but i 
> realize that there is somethings i don't understand in this! For example 
> consider that i would like to test existence of "sort" (deprecated and 
> should be replaced by "gsort")  :
> 
> 

exists and isdef seem to work for variables or macros only.

For your purpose, you can use getscilabkeywords().

Calixte

> 
> -->exists('sort')
>   ans  =
> 
>      0.
> 
> -->exists('gsort')
>   ans  =
> 
>      0.
> 
> -->isdef('sort')
>   ans  =
> 
>    F
> 
> -->isdef('sort','all')
>   ans  =
> 
>    F
> 
> although "gsort" exists and "sort" doesn't exists :
> 
> -->sort([1,2])
>              !--error 4
> Variable non définie: sort
> 
> 
> 
> -->gsort([1,2])
>   ans  =
> 
>      2.    1.
> 
> 
> another example with "maxi" (obsolete and should be replaced by "max")
> 
> -->exists('max')
>   ans  =
> 
>      0.
> 
> -->exists('maxi')
>   ans  =
> 
>      0.
> 
> -->maxi=max//now maxi exists
>   maxi  =
> 
> 
> -->exists('maxi')
>   ans  =
> 
>      1.
> 
> -->isdef('max')
>   ans  =
> 
>    F
> 
> -->isdef('maxi')
>   ans  =
> 
>    T
> 
> 
> 
> this seems very strange to me, since "max" and "maxi" has the same type 
> ("fptr" and not "function") but are considered differently :
> 
> -->typeof(max)
>   ans  =
> 
>   fptr
> 
> -->typeof(maxi)
>   ans  =
> 
>   fptr
> 
> i also think in using "whereis" but this also obscure to me :
> 
> -->whereis(max)
>               !--error 999
> whereis : Mauvais type pour l'argument d'entrée n°1.
> 
> 
> -->whereis('max')
>   ans  =
> 
>       []
> 
> -->whereis(imshow)
>   ans  =
> 
>   sivplib
> 
> so i' wait for your ideas!
> 
> Philippe.
> 





More information about the users mailing list