<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<font face="Courier New">Samuel,<br>
<br>
Thanks for clarifying. I have still a doubt regardihng the hard
coding. Functions such as cos and abs, which are <br>
</font>primitives, do declare an excess of arguments:<br>
<br>
--> cos(6,7)<br>
<br>
cos: Wrong number of input argument(s): 1 expected.<br>
<br>
Is the behavior different for primitives or they have a way of
bypassing the hard-coded detection?<br>
<br>
Regards,<br>
<br>
Federico Miyara<br>
 <br>
<br>
<div class="moz-cite-prefix">On 06/02/2020 18:35, Samuel Gougeon
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:8e6bac18-ca57-a1a9-e018-c7c16d0d9a30@free.fr">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div class="moz-cite-prefix">Hello Federico,</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Le 06/02/2020 Ã 22:04, Federico
Miyara a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:14dffcee-2416-90f8-9d75-8184ededd60b@fceia.unr.edu.ar">
<meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<br>
<font face="Courier New">Dear All,<br>
<br>
I'm trying to cast an error message for a function<br>
<br>
The test and message are<br>
<br>
</font><font face="Courier New">if argn(2)<>1<br>
  t1 = "%s: Wrong number of input arguments: %d expected.\n"</font><br>
<font face="Courier New">Â Â t2 = "Si" </font><br>
<font face="Courier New">Â Â error(msprintf(gettext(t1),t2,1));<br>
end<br>
</font></blockquote>
<p><br>
</p>
<p>Please pay attention to avoid separating the gettext() call
from its first literal argument. The reason is described with
details in the gettext() page. So, to abstract, writting both
the following is not fully equivalent:</p>
<p><font face="Courier New"><font face="Courier New">t1 = "%s:
Wrong number of input arguments: %d expected.\n"<br>
</font>gettext(t1)</font><br>
<br>
and<br>
<font face="Courier New"><br>
gettext(</font><font face="Courier New"><font face="Courier
New"><font face="Courier New">"%s: Wrong number of input
arguments: %d expected.\n"</font></font>)</font></p>
<p><br>
Here, this separation has no consequence, because you are using
a standard message that already has a translation in Scilab. But
for custom messages as in a toolbox, gettext() could here fail
finding the translation.<br>
</p>
<blockquote type="cite"
cite="mid:14dffcee-2416-90f8-9d75-8184ededd60b@fceia.unr.edu.ar"><font
face="Courier New"> <br>
The function has only one argument, so if invoked with 0 or
more than one argument, the message should be the same. With 0
arguments I get:<br>
<br>
<br>
--> y = Si()<br>
<br>
  0.<br>
at line   26 of function Si ( D:\work_scilab\Si.sci line 26 )<br>
<br>
Si: Wrong number of input arguments: 1 expected.<br>
</font><font face="Courier New"><br>
<br>
This is the correct and expected message. However, with 2
arguments I get<br>
<br>
<br>
--> y = Si(1,2)<br>
<br>
Wrong number of input arguments.<br>
<br>
<br>
This error seems to have been trapped before my test, </font></blockquote>
<p><br>
</p>
<p>Yes, this is the case. This is a general features for all
macros. The detection of a number of input arguments greater
than the max acceptable by the macro is hard-coded, and stops
the execution BEFORE "really" calling and entering the macro.
This is the very first step that must be passed. Afterward,
things actually "occur" in the macro<font face="Courier New">.<br>
</font><br>
</p>
<blockquote type="cite"
cite="mid:14dffcee-2416-90f8-9d75-8184ededd60b@fceia.unr.edu.ar"><font
face="Courier New">the execution is halted and my message
doesn't show. I've also tested the function wavwrite, which
requires 2 or 3 arguments. With 0 or 1 the message is the
expected one, but with 4 or more arguments, I get the same
result as in my example.<br>
<br>
Seems as if less arguments are handled by the custom error
handler, but more than required is handled by sort of a
parser. <br>
<br>
I think this behavior contradicts the facility of customizing
error messages.<br>
</font></blockquote>
<p>Not really. Only this one, related to an excessive number of
inputs. Since the number of possible distinct errors is
infinite, it's cool. Our freedom to customize all other messages
is also infinite :-))<br>
</p>
<br>
Regards<br>
Samuel<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-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>
<br>
</body>
</html>