<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi Samuel<br>
<br>
Thank you. It works ... (of course :-) ).<br>
<br>
Best regards,<br>
Claus<br>
<br>
On 30.09.2018 22:03, Samuel Gougeon wrote:<br>
</div>
<blockquote type="cite"
cite="mid:d67c773d-8e1a-9ec8-adad-f67c8f010a3a@free.fr">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<div class="moz-cite-prefix">Le 30/09/2018 à 20:59, Claus Futtrup
a écrit :<br>
</div>
<blockquote
cite="mid:ef379ef7-456c-d127-bcf4-7daf7826c610@gmail.com"
type="cite">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
<p>Hi Scilabers</p>
<p>I have almost always included a neat piece of code in my
Scilab scripts, so that I can later dump the plots into e.g.
SVG or PNG files (script path is not write-protected). The
code doesn't work anymore:</p>
<pre style="font-family:Monospaced;font-style:normal;font-size:12.0;"><span style="color:rgb(100,174,100);font-style:italic;">// Extract the filename and path of this script:</span>
<span style="color:rgb(74,85,219);">[</span><span style="color:rgb(0,0,0);">units</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">typs</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">nams</span><span style="color:rgb(74,85,219);">]</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(50,185,185);">file</span><span style="color:rgb(74,85,219);">(</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;">// nams(1) = script file name incl. path</span>
<span style="color:rgb(0,0,0);">fpathname</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(50,185,185);">strsplit</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">nams</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">,</span> <span style="color:rgb(74,85,219);">[</span><span style="color:rgb(50,185,185);">filesep</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">]</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;">// disp(b($-1));</span>
<span style="color:rgb(0,0,0);">scriptpath</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">get_absolute_file_path</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">fpathname</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(255,170,0);">$</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(50,185,185);">chdir</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">scriptpath</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span></pre>
<p>The above code returns an empty string in scriptpath. I'm
using Scilab 6.0.1 (Windows 10) and I wonder what I should do
instead?<br>
</p>
</blockquote>
<br>
The following should work.<br>
In Scilab 6, file() additionally lists stderr as unit #0.<br>
Samuel<br>
<pre style="font-family:Monospaced;font-style:normal;font-size:13.0;"><span style="color:rgb(74,85,219);">[</span><span style="color:rgb(0,0,0);">units</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);"> typs</span><span style="color:rgb(0,0,0);">, </span><span style="color:rgb(0,0,0);">nams</span><span style="color:rgb(74,85,219);">]</span><span style="color:rgb(92,92,92);"> = </span><span style="color:rgb(50,185,185);">file</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(0,0,0);">nams</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(50,185,185);">find</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">units</span><span style="color:rgb(92,92,92);">==</span><span style="color:rgb(188,143,143);">0</span> <span style="color:rgb(92,92,92);">|</span> <span style="color:rgb(0,0,0);">units</span><span style="color:rgb(92,92,92);">==</span><span style="color:rgb(188,143,143);">5</span> <span style="color:rgb(92,92,92);">|</span> <span style="color:rgb(0,0,0);">units</span><span style="color:rgb(92,92,92);">==</span><span style="color:rgb(188,143,143);">6</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(74,85,219);">[</span><span style="color:rgb(74,85,219);">]</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(0,0,0);">scriptpath</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">fileparts</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">nams</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(255,170,0);">$</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">path</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(50,185,185);">chdir</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">scriptpath</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span></pre>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<p><br>
</p>
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br />
<table style="border-top: 1px solid #D3D4DE;">
<tr>
<td style="width: 55px; padding-top: 13px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;" /></a></td>
<td style="width: 470px; padding-top: 12px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a>
</td>
</tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>