<!--
* 
*
*  ProLinga-Doc
*
*  Copyright (C) 2002-2008 Xobas Software.
*  All rights reserved.
*  
*  This file is part of ProLinga-Doc.
*
*  ProLinga-Doc is free software: you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation, either version 3 of the License, or
*  (at your option) any later version.
*
*  ProLinga-Doc is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with ProLinga-Doc.  If not, see <http://www.gnu.org/licenses/>.
*
*  More information is available at the following addresses:
*
*  Website     : http://www.prolinga.org
*
*  Email       : prolinga-list@prolinga.org
*
*
-->
<refentry id="cmd_let">
  <refmeta>
    <refentrytitle>LET Command</refentrytitle>
    <manvolnum>1</manvolnum>
  </refmeta>

  <refnamediv>
    <refname>LET</refname>
    <refpurpose>Assign a value to a data reference.</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <cmdsynopsis>
      <command>LET</command>
      <arg choice='plain'><replaceable>dest_data_ref</replaceable></arg>
      <arg choice='plain'><option>=</option></arg>
      <arg choice='plain'><replaceable>src_data_ref</replaceable></arg>
      <arg rep='repeat' choice='opt'><replaceable>src_data_ref</replaceable></arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>LET</command>
      <arg choice='plain'><replaceable>dest_data_ref</replaceable></arg>
      <arg choice='plain'><option>=</option></arg>
      <arg choice='plain'><replaceable>num_data_ref</replaceable></arg>
      <arg rep='repeat' choice='opt'><replaceable>calculation-operator/function num_data_ref</replaceable></arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>LET</command>
      <arg choice='plain'><replaceable>dest_data_ref</replaceable></arg>
      <arg choice='plain'><option>=</option></arg>
      <arg choice='plain'><option><link linkend="cmd_call">CALL</link></option></arg>
      <arg choice='plain'><replaceable>logic_name</replaceable></arg>
      <arg rep='repeat' choice='opt'><replaceable>logic_argument</replaceable></arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>LET</command>
      <arg choice='plain'><replaceable>dest_data_ref</replaceable></arg>
      <arg choice='plain'><option>=</option></arg>
      <arg choice='plain'><option>CALCDATE</option></arg>
      <arg choice='plain'><replaceable>src_data_date_ref1</replaceable></arg>
      <arg choice='plain'><option>DIFF</option></arg>
      <arg choice='plain'><replaceable>src_data_date_ref2</replaceable></arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>LET</command>
      <arg choice='plain'><replaceable>dest_data_date_ref</replaceable></arg>
      <arg choice='plain'><option>=</option></arg>
      <arg choice='plain'><option>CALCDATE</option></arg>
      <arg choice='plain'><replaceable>src_data_date_ref</replaceable></arg>
      <arg choice='plain'>
        <group choice='req'>
          <arg choice='plain'><option>+</option></arg>
          <arg choice='plain'><option>-</option></arg>
        </group>
      </arg>
      <arg choice='plain'>
        <group choice='req'>
          <arg choice='plain'><option>DAYS</option></arg>
          <arg choice='plain'><option>WEEKS</option></arg>
          <arg choice='plain'><option>MONTHS</option></arg>
        </group>
      </arg>
      <arg choice='plain'><replaceable>num_data_ref</replaceable></arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>LET</command>
      <arg choice='plain'><replaceable>dest_data_ref</replaceable></arg>
      <arg choice='plain'><option>=</option></arg>
      <arg choice='plain'><option>CALCDATE</option></arg>
      <arg choice='plain'><replaceable>src_data_date_ref</replaceable></arg>
      <arg choice='plain'>
        <group choice='req'>
          <arg choice='plain'><option>DOW</option></arg>
          <arg choice='plain'><option>WEEKNUM</option></arg>
        </group>
      </arg>
    </cmdsynopsis>
  </refsynopsisdiv>

  <refsect1 id="cmd_let_introduction">
    <title>Introduction</title>
    <para>
      The <link linkend="cmd_let">LET</link> command assigns a value to a data 
      reference. This can be a simple 
      copy, the result of a (date) calculation, a concatenation or the return value 
      from a called logic block.
    </para>

    <para>Date calculations can be initiated by using the CALCDATE argument. The 
    following calculations are possible:</para>

    <itemizedlist>
      <listitem>
        <para>DIFF: This gives the number of days between 2 dates. 0 means the dates
        are the same, &lt; 0 means the left date is earlier than the right date and
        &gt; 0 means the left date is later than the right date.</para>
      </listitem>
      <listitem>
        <para>+/- DAYS/WEEKS/MONTHS: add/subtract n number of DAYS/WEEKS/MONTHS
        from the given date and return the result as a date.</para>
      </listitem>
      <listitem>
        <para>DOW: Returns the Day Of Week (0=Sunday, 6=Saturday).</para>
      </listitem>
      <listitem>
        <para>WEEKNUM: Returns 
        the number of the week of the year of the date given.</para>
      </listitem>
    </itemizedlist>

  </refsect1>

  <refsect1 id="cmd_let_arguments">
    <title>Arguments</title>
    <variablelist>
      <varlistentry>
	<term><replaceable>dest_data_ref</replaceable></term>
	<listitem>
	  <simpara>
            Data item which will get a value assigned to. This can either be a 
            simple copy from another data reference, or this can be the result 
            of a calculation. The data item has to be an existing data item 
            and can not be a read-only item like a string for instance.
	  </simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><replaceable>dest_data_date_ref</replaceable></term>
	<listitem>
	  <simpara>
            Data item which will get a date value assigned to. 
            This will be the result 
            of a date calculation. The data item has to be an existing data item 
            and can not be a read-only item like a string for instance.
	  </simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><replaceable>src_data_ref</replaceable></term>
	<listitem>
	  <simpara>
            Data item where the value will be copied from. The data item can
            either be an existing data item, a string or a numeric value.
	  </simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><replaceable>src_data_date_ref</replaceable></term>
	<listitem>
	  <simpara>
            Data item being a valid date in a date format where the value will be 
            copied from. The data item can
            either be an existing data item, a string or a numeric value.
	  </simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><replaceable>num_data_ref</replaceable></term>
	<listitem>
	  <simpara>
            Numeric data item where the value will be used in a (date) calculation. 
            The data item can either be an existing data item or a numeric value.
	  </simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><replaceable>logic_name</replaceable></term>
	<listitem>
	  <simpara>
            Name or single data reference holding a name of a logic block to 
            be called. The returned value of this logic block will be moved 
            into the <replaceable>dest_data_ref</replaceable>. 
	  </simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><replaceable>logic_argument</replaceable></term>
	<listitem>
	  <simpara>
            Optional argument(s) of the called logic block.
	  </simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><replaceable>calculation operator</replaceable></term>
	<listitem>
          <simplelist type='vert' columns='1'>
            <member><![CDATA[++ -- ! ~ unary + -]]></member>
            <member><![CDATA[**]]></member>
            <member><![CDATA[* / %]]></member>
            <member><![CDATA[+ -]]></member>
            <member><![CDATA[<< >> >>>]]></member>
            <member><![CDATA[< <= > >=]]></member>
            <member><![CDATA[== !=]]></member>
            <member><![CDATA[&]]></member>
            <member><![CDATA[^]]></member>
            <member><![CDATA[|]]></member>
            <member><![CDATA[= += -= *= /= %= <<= >>= >>>= &= |= ^= **=]]></member>
          </simplelist>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><replaceable>calculation function</replaceable></term>
	<listitem>
            <simplelist type='horiz' columns='6'>
            <member>abs</member>
            <member>acos</member>
            <member>asin</member>
            <member>atan</member>
            <member>atan2</member>
            <member>cos</member>
            <member>cosh</member>
            <member>exp</member>
            <member>int</member>
            <member>float</member>
            <member>log</member>
            <member>log10</member>
            <member>prime</member>
            <member>sinh</member>
            <member>sqrt</member>
            <member>tan</member>
            <member>tanh</member>
          </simplelist>
	</listitem>
      </varlistentry>
      <varlistentry>
	<listitem>
          <note>calculation functions values need to be surrounded by round 
            brackets. ie: sin(1234)
          </note>
	</listitem>
      </varlistentry>
    </variablelist>

  </refsect1>

  <refsect1 id="cmd_let_example">
    <title>Example</title>
<programlisting>
. . .
. . .
LET L-String = "Hello " V-Name "."
. . .
LET L-Counter = 10
. . .
LET L-Total = L-SubTotal + L-Tax
. . .
LET L-OrderNumber = CALL GetOrderNumber
. . .
LET L-RenewalDate = CALCDATE L-ExpiryDate + MONTHS 1
. . .
LET L-WeekNumber = CALCDATE L-CurrentDate WEEKNUM
. . .
. . .
</programlisting>
  </refsect1>

  <refsect1 id="cmd_let_related">
    <title>Related Commands</title>
    <para>
      <link linkend="cmd_call">CALL</link>
    </para>
  </refsect1>

</refentry>

