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

<root>
  <func>
    <title>cnc_rdprogdir2</title>


    <declare>
      <vc>
        <include>#include "fwlib32.h"</include>
        <prottype>FWLIBAPI short WINAPI cnc_rdprogdir2(unsigned short FlibHndl, short type, short *top_prog, short *num_prog, PRGDIR2 *buf);</prottype>
        <prottype><br/><br/></prottype>
        <prottype><br/>For the program number 8 digits :<br/><br/>
                  FWLIBAPI short WINAPI cnc_rdprogdir2(unsigned short FlibHndl, short type, long *top_prog, short *num_prog, PRGDIR2 *buf); 
        </prottype>
      </vc>
    </declare>



    <doc>
        <cmn>
            <p>Reads the program directory of all the programs registered in the CNC.</p>
            <p>
                Reads specified number of "Program Number","Comment" and "Program size (number of characters)"
                data of the registered programs in the CNC, starting from the program with the specified Program number.            </p>
            <p>
                It has the function to specify the number of programs to be read in order to get the information
                corresponding to the number of programs which is set by the application.
            </p>
            <p>
                It is possible to use this function for the program number 8 digits,
                however it is necessary to switch API to the one for the program number 8 digits. 
                See <a href="general.htm#O8" target="_parent">Program number 8 digits</a> for details.
           </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>type</name>
                    <type>in</type>
                       <content>
                            Specify the type of the program directory to read.
                            <table class="dd">
                                <tr>
                                    <td>0   </td><td>:  </td><td>"Program number" only</td>
                                </tr>
                                <tr>
                                    <td>1   </td><td>:  </td><td>"Program number" and "Comment"</td>
                                </tr>
                                <tr>
                                    <td>2   </td><td>:  </td><td>"Program number", "Comment" and "Program size"</td>
                                </tr>
                           </table>
                        </content>
                </item>
                <item>
                    <name>top_prog</name>
                    <type>in / out</type>
                    <content>
                        <p>
                            Pointer to the starting program number.<br/>
                            The program number of the first program actually read is stored after this function call.
                        </p>
                    </content>
                </item>
                <item>
                    <name>num_prog</name>
                    <type>in / out</type>
                    <content>
                        <p>
                            Pointer to the number of programs to be read.<br/>
                            Actual number of programs being read is stored after this function call.
                        </p>
                    </content>
                </item>
                <item>
                    <name>buf</name>
                    <type>out</type>
                    <content>
                        <p>
                            Pointer to the PRGDIR2 structure where program directory data are returned.<br/>
                            The PRGDIR2 structure is as follows.
                        </p>
<pre>
<b>For program number 4 digits,</b>
typedef struct prgdir2 {
        short   number;
        long    length;
        char    comment[51];
        char    dummy;
} PRGDIR2;

<b>For program number 8 digits,</b>
typedef struct prgdir2 {
        long    number;
        long    length;
        char    comment[51];
        char    dummy;
} PRGDIR2;
</pre>

                        <dl>
                            <dt>number</dt>
                                <dd>Program number</dd>
                                <dd>Program number is returned.</dd>

                            <dt>length</dt>
                                <dd>Program size</dd>
                                <dd>Program size is returned.</dd>
                                <dd>Valid when 2 is specified for the arguments "type".</dd>

                            <dt>comment</dt>
                                <dd>Comment</dd>
                                <dd>The "Comment" stored next to the "Program number" in the CNC is returned.<br/>
                                    The maximum length of the comment stored is 48 characters (50 characters 
                                    includ- ing leading "(" and trailing ")"). When the "Comment" is longer than 
                                    48 characters, the part after the 48th character is ignored.<br/>
                                    When no "Comment" is registered only parentheses ("()") are returned.<br/>
                                    The "Comment" character string is terminated with NULL character.<br/>
                                    Valid when 1 or 2 is specified for the argument "type".
                                </dd>
                        </dl>
                                <p>
                                    When no programs are registered or no programs match the specified condition,
                                    "0" is returned to "num_prog".
                                </p>
                    </content>
                </item>
            </vc>
        </common>
    </argument>



    <errcode>
        <item class="xis">
            <name>EW_FUNC</name>
            <content>
                Unavailable (Series 150i,160/180, 160i/180i, 300i, Power Mate i)<br/>
                This application is not customized for the program number 8 digits.<br/>
                See <a href="general.htm#O8" target="_parent">Program number 8 digits</a> for details.
            </content>
        </item>
        <item>
            <name>EW_LENGTH</name>
            <content>
                Data block length error<br/>
                The number of readout(num_prog) is wrong.
            </content>
        </item>
        <item>
            <name>EW_NUMBER</name>
            <content>
                Data number error<br/>
                The start number of program(top_prog) is wrong.
            </content>
        </item>
        <item>
            <name>EW_ATTRIB</name>
            <content>
                Data attribute error<br/>
                Output format(type) is wrong.
            </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>
        <type>
            <li> Series 150/150i</li>
            <ul>
                Program name 48 characters<br/>
                If this option does not exist, the maximum program name is 16 characters.
            </ul>
        </type>
        <is>
            <hssb>The extended driver/library function is necessary.</hssb>
        </is>
    </option>



    <parameter></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>
        
        <is>
            <m>
                <fs30is>O</fs30is>
            </m>
            <t>
                <fs30is>O</fs30is>
            </t>
        </is>
    </support>



    <reference>
        <item class="xis">
            <name>cnc_rdprogdir</name>
            <file>Program/cnc_rdprogdir.htm</file>
        </item>
        <item>
            <name>cnc_rdprogdir3</name>
            <file>Program/cnc_rdprogdir3.htm</file>
        </item>
        <item class="xis">
            <name>cnc_rdprogdir4</name>
            <file>Program/cnc_rdprogdir4.htm</file>
        </item>
    </reference>



    <example>
<vc>
The following program reads all registration information of NC program,
and displays program number list.

#include "fwlib32.h"

#define BUFSIZE 100

void example()
{
        PRGDIR2 prg[BUFSIZE];
        short i, num;
        short top = 0;

        do {
                num = BUFSIZE;
                ret = cnc_rdprogdir2( h, 0, &#38;top, &#38;num, prg );
                if ( ret == EW_NUMBER ) {
                        break;
                }
                if ( ret ) {
                        printf( "ERROR: %d\n", ret );
                        break;
                }
                for ( i = 0 ; i &#60; num ; i++ ) {
                        printf( "O%d\n", prg[i].number );
                }
                top = prg[num-1].number + 1;
        } while ( num &#62;= BUFSIZE );
}
</vc>
    </example>



  </func>
</root>
