<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE MAN SYSTEM "../../manrev.dtd">
<MAN>
  <LANGUAGE>eng</LANGUAGE>
  <TITLE>mtlb_eval</TITLE>
  <TYPE>M2SCI function</TYPE>
  <DATE>April 2004</DATE>

  <SHORT_DESCRIPTION name="mtlb_eval">Matlab eval emulation function</SHORT_DESCRIPTION>

  <DESCRIPTION>

    <P>Scilab equivalent for Matlab <VERB>eval</VERB> is different according to its inputs and outputs</P>

    <P>
    The function <VERB>mtlb_eval(str1,str2)</VERB> is used by
    <VERB>mfile2sci</VERB> to replace <VERB>eval</VERB> because it was not possible to know
    what were the inputs while porting Matlab code to Scilab. This function will
    determine the correct semantic at run time. If you want to have a
    more efficient code it is possible to replace <VERB>mtlb_eval</VERB> calls:
    </P>

    <DESCRIPTION_INDENT>
    <DESCRIPTION_ITEM>
    <ITEMIZE>
      <ITEM>
        <SP>
        When called with one input and no output,
        <VERB>mtlb_eval(str1)</VERB> may be replaced by <VERB>evstr(str1)</VERB>
	if <VERB>str1</VERB> is a valid Scilab expression
	or by <VERB>execstr(str1)</VERB> 
	if <VERB>str1</VERB> is a valid Scilab instruction.
        </SP>
      </ITEM>

      <ITEM>
        <SP>
        When called with one input and one output,
        <VERB>val=mtlb_eval(str1)</VERB> may be replaced by <VERB>val=evstr(str1)</VERB>
	if <VERB>str1</VERB> is a valid Scilab instruction.
        </SP>
      </ITEM>

      <ITEM>
        <SP>
        When called with two inputs and no output,
        <VERB>mtlb_eval(str1,str2)</VERB> may be replaced by:
	<VERB>if execstr(str1,&quot;errcatch&quot;)&lt;&gt;0 then execstr(str2);end</VERB>
	if <VERB>str1</VERB> and <VERB>str2</VERB> are valid Scilab instructions.
        </SP>
      </ITEM>

      <ITEM>
        <SP>
        When called with more than one output and one input,
        <VERB>[val1,val2,...]=mtlb_eval(str1)</VERB> may be replaced by
	<VERB>execstr(&quot;[val1,val2,...]&quot;+str1)</VERB>
	if <VERB>str1</VERB> is a valid Scilab instruction.
        </SP>
      </ITEM>

      <ITEM>
        <SP>
        When called with two inputs and more than one output,
        <VERB>[val1,val2,...]=mtlb_eval(str1,str2)</VERB> may be replaced by:
        </SP>
	<VERBATIM>
	if execstr(&quot;[val1,val2,...]&quot;+str1,&quot;errcatch&quot;)&lt;&gt;0 then
	  execstr(&quot;[val1,val2,...]&quot;+str2);
	end	  
	</VERBATIM>
        <SP>
	if <VERB>str1</VERB> and <VERB>str2</VERB> are valid Scilab instructions.
        </SP>
      </ITEM>
    </ITEMIZE>
    </DESCRIPTION_ITEM>
    </DESCRIPTION_INDENT>

    <P>Caution: <VERB>mtlb_eval</VERB> has not to be used for hand coded functions.</P>

  </DESCRIPTION>

  <SEE_ALSO>
    <SEE_ALSO_ITEM> <LINK>evstr</LINK> </SEE_ALSO_ITEM>
    <SEE_ALSO_ITEM> <LINK>execstr</LINK> </SEE_ALSO_ITEM>
  </SEE_ALSO>

  <AUTHORS>
    <AUTHORS_ITEM>V.C.</AUTHORS_ITEM>
  </AUTHORS>
</MAN>
