<?xml version="1.0" encoding="Shift_JIS"?>
<?xml-stylesheet type="text/xsl" href="../Fmethod_xsl/fmethod_he_c.xsl"?>

<root>
  <func>


    <title>cnc_wrmacror</title>



    <declare>
      <vc>
        <include>#include "fwlib32.h"</include>
        <prottype>FWLIBAPI short WINAPI cnc_wrmacror(unsigned short FlibHndl, short length, IODBMR *macror);</prottype>
      </vc>
    </declare>



    <doc>
        <cmn>
            <p>Writes the custom macro variable specified by "datano_s", "datano_e". The data must be stored in "IODBMR" with signed binary format.</p>

            <p>The kind of custom macro variable is as follows. The local variable cannot be written.</p>

            <ol>
                <li>Common variable (#100,..,#999)</li>
                    See the description of <a href="ncdata/cnc_rdmacroinfo.htm" target="_parent">cnc_rdmacroinfo</a> function about the available range of common variables.<br/>
            </ol>

            <p>It is possible to exchange the type of macro variable by <a href="ncdata/cnc_setmactype.htm" target="_parent">cnc_setmactype</a> function.</p>

            <ul>
                <li>decimal form floating-point type (data format=M*10**(-E))</li>
                <table>
                    <colgroup valign="top">
                    <colgroup valign="top">
                    <colgroup valign="top">
                    <tr>
                        <td>mcr_val</td>
                        <td>:</td>
                        <td>value of variable(=M)<br/>
                        4-byte binary data with sign<br/>
                        (available range:999999999,..,-999999999)</td>
                    </tr>
                    <tr>
                        <td>dec_val</td>
                        <td>:</td>
                        <td>number of places of decimals(=E)<br/>
                        2-byte binary data with sign<br/>
                        (available range:-128,..,127)</td>
                    </tr>
                    </colgroup>
                    </colgroup>
                    </colgroup>
                </table>
                <br/>
                <li>binary form floating-point type (data format=M*2**(-E))</li>
                <table>
                    <colgroup valign="top">
                    <colgroup valign="top">
                    <colgroup valign="top">
                    <tr>
                        <td>mcr_val</td>
                        <td>:</td>
                        <td>numerical part of variable(=M)<br/>
                        4-byte binary data with sign<br/>
                        (available range:No limitation)</td>
                    </tr>
                    <tr>
                        <td>dec_val</td>
                        <td>:</td>
                        <td>exponent part of variable(=E)<br/>
                        2-byte binary data with sign<br/>
                        (available range:-128,..,127)</td>
                    </tr>
                    </colgroup>
                    </colgroup>
                    </colgroup>
                </table>

            </ul>

            <p>The value of an undefined variable is called "vacant", and it is expressed as follows both at decimal form floating-point type and at binary form floating-point type.</p>

            <blockquote>
                <p>mcr_val = 0<br/>
                dec_val = -1</p>
            </blockquote>

            <p>See "OPERATOR'S MANUAL" of CNC for details of the custom macro variable.</p>
        </cmn>
    </doc>



    <argument>
        <common>
            <vc>
                <item>
                    <name>FlibHndl</name>
                    <type>in</type>
                    <content>
                        <p>
                            Specify the library handle. See "<a href="handle.htm" target="_parent">Library handle</a>" for details.
                        </p>
                    </content>
                </item>
                <item>
                    <name>length</name>
                    <type>in</type>
                    <content>
                        <p>Specify the data block length (size of IODBMR structure).</p>

                        <p class="dd">8+8*(Number of custom macro variable)</p>

                        <p><b>IODBMR</b></p>

                        <p><img src="ncdata/nmacro.gif"/></p>

                        <p>N : Number of custom macro variable</p>

                    </content>
                </item>
                <item>
                    <name>macror</name>
                    <type>in</type>
                    <content>
                        <p>Pointer to the IODBMR structure including the custom macro variable. The IODBMR structure is as follows.</p>

<pre>
typedef struct iodbmr {
    short datano_s; /* start custom macro variable number*/
    short dummy;    /* (not used) */
    short datano_e; /* end custom macro variable number */
    struct {
        long  mcr_val; /* value of custom macro var. */
        short dec_val; /* number of places of decimals*/
    } data[N];         /* N : number of variable */
} IODBMR;
</pre>
                        <dl>
                            <dt>datano_s</dt>
                            <dd>Specify the start custom macro variable number.</dd>
                            <br/>
                            <dt>datano_e</dt>
                            <dd>Specify the end custom macro variable number.</dd>
                            <br/>
                            <dt>mcr_val</dt>
                            <dd>Specify the value of variable/numerical part of variable.</dd>
                            <br/>
                            <dt>dec_val</dt>
                            <dd>Specify the number of places of decimals/exponent part of variable.</dd>
                        </dl>
                    </content>
                </item>
            </vc>
        </common>
    </argument>



    <errcode>
        <item>
            <name>EW_LENGTH</name>
            <content>Data block length error<br/>Size of IODBMR structure(length) is wrong.</content>
        </item>
        <item>
            <name>EW_NUMBER</name>
            <content>Data number error<br/>Custom macro variable number(datano_s, datano_e) is wrong.</content>
        </item>
        <item>
            <name>EW_DATA</name>
            <content>Data error<br/>Value of custom macro variable(mcr_val, dec_val) is out of available range.</content>
        </item>
        <item>
            <name>EW_NOOPT</name>
            <content>No option<br/>This function needs the custom macro option.</content>
        </item>
        <item>
            <name>EW_PROT</name>
            <content>protection error (300i/310i/320i only)<br/>The variable is read-only. </content>
        </item>
    </errcode>



    <option>
        <hssb>The extended driver/library function is necessary.</hssb>
        <ethr><p>The Ethernet function and the extended driver/library function are necessary.</p>
              <p>However, in case of Series 160i/180i/210i/0i MODEL B and 300i, the required CNC option is as follows.</p>
              <p>When Embedded Ethernet is used,</p>
              <p><ul>above two optional functions are not required.</ul></p>
              <p>When Ethernet board is used,</p>
              <p><ul>only Ethernet function is required.</ul></p>
        </ethr>
        <need>
            <li>Series 150, 150i, 300i/310i/320i</li>
            Custom macro<br/>
            <br/>
            <li>Series 160/180/210, 160i/180i/210i, 0i, Power Mate i</li>
            Custom macro B<br/>
            <br/>
        </need>
        <type>
            <li>Series 150</li>
            Custom macro common variable 200 sets<br/>
            Custom macro common variable 300 sets<br/>
            Custom macro common variable 600 sets<br/>
            <br/>
            <li>Series 150i</li>
            Custom macro common variable 900 sets<br/>
            <br/>
            <li>Series 160/180/210, 160i/180i/210i, 0i, Power Mate i</li>
            Custom macro common variable extension<br/>
            <br/>
            <li>Series 300i/310i/320i</li>
            Custom macro common variable extension<br/>
            Embedded macro<br/>
            <br/>
        </type>

        <is>
            <hssb>The extended driver/library function is necessary.</hssb>
            <need>
                Custom macro
            </need>
            <type>
                Custom macro common variable extension<br/>
                Embedded macro
            </type>
        </is>
    </option>



    <parameter>
        <type>
            <ul>
            <li>Series 160i/180i-W</li>
            6005#4,#5,#7 (influenced by setting)
            <li>Series 300i/310i/320i</li>
            6031, 6032 (influenced by setting)
            </ul>
        </type>
    </parameter>

    <is_parameter>
    </is_parameter>



    <mode>
    </mode>



    <support>
        <m>
              <fs0ia>H</fs0ia>
            <fs0ib>O</fs0ib>
            <fs15>H</fs15>
            <fs15i>O</fs15i>
            <fs16>H</fs16>
            <fs18>H</fs18>
            <fs21>H</fs21>
            <fs16ia>O</fs16ia>
            <fs18ia>O</fs18ia>
            <fs21ia>O</fs21ia>
            <fs16ib>O</fs16ib>
            <fs18ib>O</fs18ib>
            <fs21ib>O</fs21ib>
            <fs30i>O</fs30i>
        </m>
        <t>
              <fs0ia>H</fs0ia>
            <fs0ib>O</fs0ib>
            <fs15>H</fs15>
            <fs15i>X</fs15i>
            <fs16>H</fs16>
            <fs18>H</fs18>
            <fs21>H</fs21>
            <fs16ia>O</fs16ia>
            <fs18ia>O</fs18ia>
            <fs21ia>O</fs21ia>
            <fs16ib>O</fs16ib>
            <fs18ib>O</fs18ib>
            <fs21ib>O</fs21ib>
            <fs30i>O</fs30i>
        </t>
        <lc>
              <fs0ia>X</fs0ia>
            <fs0ib>X</fs0ib>
            <fs15>X</fs15>
            <fs15i>X</fs15i>
            <fs16>H</fs16>
            <fs18>H</fs18>
            <fs21>H</fs21>
            <fs16ia>H</fs16ia>
            <fs18ia>H</fs18ia>
            <fs21ia>H</fs21ia>
            <fs16ib>H</fs16ib>
            <fs18ib>H</fs18ib>
            <fs21ib>H</fs21ib>
            <fs30i>X</fs30i>
        </lc>
        <p>
            <fs16i>O</fs16i>
            <fs18i>O</fs18i>
        </p>
        <l>
            <fs16i>O</fs16i>
            <fs18i>X</fs18i>
        </l>
        <w>
            <fs16i>O</fs16i>
            <fs18i>O</fs18i>
        </w>
        <pw>
            <d>O</d>
            <h>O</h>
        </pw>
        <add><b></b></add>

        <is>
            <m>
                <fs30is>O</fs30is>
            </m>
            <t>
                <fs30is>O</fs30is>
            </t>
        </is>
    </support>



    <reference>
        <item>
            <name>cnc_rdmacro</name>
            <file>ncdata/cnc_rdmacro.htm</file>
        </item>
        <item>
            <name>cnc_wrmacro</name>
            <file>ncdata/cnc_wrmacro.htm</file>
        </item>
        <item>
            <name>cnc_rdmacror</name>
            <file>ncdata/cnc_rdmacror.htm</file>
        </item>
        <item>
            <name>cnc_rdmacror2</name>
            <file>ncdata/cnc_rdmacror2.htm</file>
        </item>
        <item>
            <name>cnc_wrmacror2</name>
            <file>ncdata/cnc_wrmacror2.htm</file>
        </item>
        <item>
            <name>cnc_rdmacroinfo</name>
            <file>ncdata/cnc_rdmacroinfo.htm</file>
        </item>
        <item>
            <name>cnc_getmactype</name>
            <file>ncdata/cnc_getmactype.htm</file>
        </item>
        <item>
            <name>cnc_setmactype</name>
            <file>ncdata/cnc_setmactype.htm</file>
        </item>
    </reference>



    <example>
<vc>
The following program writes the specified values into the custom macro
variables within the specified range.

#include "fwlib32.h"

/* start is start variable number to be written. */
/* value is array of value to be written. */
/* number is number of variable. */
short example( short start, long *value, short number )
{
        IODBMR *macror ;
        short ret, idx ;
        macror = (IODBMR *)malloc( 8+8*number ) ;
        macror-&#62;datano_s = start ;
        macror-&#62;datano_e = start + number - 1 ;
        for ( idx = 0 ; idx &#60; number ; idx++ ) {
                macror-&#62;data[idx].mcr_val = value[idx] ;
                macror-&#62;data[idx].dec_val = 0 ;
        }
        ret = cnc_wrmacror( h, 8+8*number, macror ) ;
        free( macror ) ;
        return ( ret ) ;
}
</vc>
    </example>



  </func>
</root>
