<div dir="ltr"><div>Dear Scilabers</div><div><br></div><div>I wish to check for the existence of some files. For this I created a simple function:</div><div><br></div><div><pre style="font-family:Monospaced;font-size:14px;font-style:normal"><span style="color:rgb(74,85,219)">[</span><span style="color:rgb(0,0,0)">out</span><span style="color:rgb(74,85,219)">]</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(176,24,19)">function</span> <span style="color:rgb(0,0,0);text-decoration:underline">file_exist</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(131,67,16);font-weight:bold">fname</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(74,85,219)">[</span><span style="color:rgb(0,0,0)">fd</span><span style="color:rgb(0,0,0)">,</span> <span style="color:rgb(0,0,0)">err</span><span style="color:rgb(74,85,219)">]</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(50,185,185)">mopen</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(131,67,16);font-weight:bold">fname</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span> <span style="color:rgb(100,174,100);font-style:italic">// Try to open file, mode: </span><span style="color:rgb(100,174,100);font-style:italic">'</span><span style="color:rgb(100,174,100);font-style:italic">br</span><span style="color:rgb(100,174,100);font-style:italic">'</span><span style="color:rgb(100,174,100);font-style:italic"> (binary-reading)</span>
<span style="color:rgb(160,32,240)">if</span> <span style="color:rgb(0,0,0)">err</span><span style="color:rgb(92,92,92)">==</span><span style="color:rgb(188,143,143)">0</span> <span style="color:rgb(160,32,240)">then</span>
<span style="color:rgb(0,0,0)">out</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(218,112,214)">%t</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(50,185,185)">mclose</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(131,67,16);font-weight:bold">fname</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(160,32,240)">else</span>
<span style="color:rgb(0,0,0)">out</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(218,112,214)">%f</span>
<span style="color:rgb(160,32,240)">end</span>
<span style="color:rgb(176,24,19)">endfunction</span></pre></div><div><br></div><div>I didn't check, but presumably this would work.</div><div><br></div><div>Is such a function already available? Which way is the "official" way to do this in Scilab?</div><div><br></div><div>Maybe I'm searching for the wrong word, but I found some ways in Scilab. The "fileinfo" seems to be the closest one to what I wish to do.</div><div><br></div><div>Matlab has a function "exist()" which can check for files too. Scilab has the function "exists()" - notice the function name is plural, not singluar - and this one AFAIK only works for Scilab variables (not files), although I didn't check.</div><div><br></div><div>If fileinfo is the right way, maybe an example for the help could be to make a file_exist function, to show ... (?) ... when I search for Scilab file exist function, I'm not guided in any specific way/direction and find myself insecure whether I find the right help.</div><div><br></div><div>Best regards,</div><div>Claus<br></div></div>