[scilab-Users] Scilab equivalent of mfilename?

Samuel Gougeon sgougeon at free.fr
Tue Nov 15 09:26:45 CET 2011


Hello Iai,

Le 15/11/2011 06:33, Iai Masafumi ax a écrit :
> I am wanting something like __FILE__ macro of C language. It should be 
> useful in debugging and in managing a lot of data files and figures 
> generated by different scripts.
>
> The code you provided did not work as I wanted when multiple script 
> files are nested. To solve this, slight modification is made:
>
> [u,t,n]=file();
> i = grep(n',"/(?:.*\.sci|.*\.sce)$/","r");
> p = n(i(length(i)));   // <--- modified.
>
> Still, this method does not give me the file name of *.sci itself. 
> Suppose you have two files, fileA.sci and fileB.sce. A function is 
> defined in fileA.sci and is called from fileB.sce. If you put the 
> above code in fileA.sci and execute the script, fileB.sce, then you 
> get "fileB.sce" in the varialbe, p.
>
> Is there any way to get the file name of sci file as well?
The code provided above works only in scripts. It won't work in functions.
For functions, you may have a look at the function where(),
or/and whereami(), and get_function_path().

HTH
Samuel



More information about the users mailing list