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

<root>
  <func>
    <title>cnc_rdprogdir4</title>


    <declare>
      <vc>
        <include>#include "fwlib32.h"</include>
        <prottype>FWLIBAPI short WINAPI cnc_rdprogdir4(unsigned short FlibHndl, short type, long top_number, short *num_prog, PRGDIR4 *buf);</prottype>
      </vc>
    </declare>



    <doc>
        <cmn>
            <p>
            Reads the program directory of all the programs registered in the CNC.<br/>
            Reads "Program Number", "Comment", "Date (created and modified)" and "Program size" data of which the specified number of programs are registered programs in the CNC, starting from the program with the specified number(from the first program).
            </p>
        </cmn>
    </doc>



    <argument>
        <hssb>
            <vc>
                <item>
                    <name>FlibHndl</name>
                    <type>in</type>
                    <content>
                        <p>
                            Specify the library handle.<br/>
                            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", "Date" and "Program size"</td>
                                </tr>
                           </table>
                        </content>
                </item>
                <item>
                    <name>top_number</name>
                    <type>in</type>
                    <content>
                        <p>
                            Specified the program number from the head to want to acquire program information.(1-)<br/>
                            The program is acquired in ascending order.
                        </p>
                    </content>
                </item>
                <item>
                    <name>num_prog</name>
                    <type>in / out</type>
                    <content>
                        <p>
                            Pointer to the number of programs to be read. 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 PRGDIR4 structure where program directory data are returned.<br/>
                            The PRGDIR4 structure is as follows.<br/>
                            PRGDIR4 structure is same as PRGDIR3.
                        </p>
                            
<pre>
typedef struct prgdir4 {
        long    number;
        long    length;
        long    page;
        char    comment[52];
        struct{
                short   year;
                short   month;
                short   day;
                short   hour;
                short   minute;
                short   dummy;
        } mdate;
        struct{
                short   year;
                short   month;
                short   day;
                short   hour;
                short   minute;
                short   dummy;
        } cdate;
} PRGDIR4;
</pre>

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

                            <dt>length</dt>
                                <dd>Program size (number of characters)</dd>
                                <dd>Program size is returned by character unit.</dd>
                                <dd>Valid when 2 is specified for the arguments "type".</dd>

                            <dt>page</dt>
                                <dd>unused</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 including leading "(" and trailing ")").<br/>
                                    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/>
                                </dd>
                                <dd>The "Comment" character string is terminated with NULL character.</dd>
                                <dd>Valid when 1 or 2 is specified for the argument "type".</dd>

                            <dt>mdate</dt>
                                <dd>Modified date</dd>
                                <dd>Modified date is returned.</dd>
                                <dd>Valid when 2 is specified for the arguments "type".</dd>
                                <dd>The meaning of structure is as follows.</dd>
                                <dd><table class="dd">
                                    <tr><td>year    </td><td>:</td><td>Year</td></tr>
                                    <tr><td>month   </td><td>:</td><td>Month</td></tr>
                                    <tr><td>day     </td><td>:</td><td>Day</td></tr>
                                    <tr><td>hour    </td><td>:</td><td>Hour</td></tr>
                                    <tr><td>minute  </td><td>:</td><td>Minute</td></tr>
                                    </table>
                                </dd>
                            <dt>cdate</dt>
                                <dd>unused</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>
        </hssb>
    </argument>



    <errcode>
        <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_number) is wrong.
            </content>
        </item>
        <item>
            <name>EW_ATTRIB</name>
            <content>
                Data attribute error<br/>
                Output format (type) is wrong.
            </content>
        </item>
    </errcode>



    <option>
        <hssb>
            <p>The extended driver/library function is necessary.</p>
        </hssb>
    </option>



    <parameter></parameter>



    <mode></mode>



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



    <reference>
        <item>
            <name>cnc_rdprogdir</name>
            <file>Program/cnc_rdprogdir.htm</file>
        </item>
        <item>
            <name>cnc_rdprogdir2</name>
            <file>Program/cnc_rdprogdir2.htm</file>
        </item>
        <item>
            <name>cnc_rdprogdir3</name>
            <file>Program/cnc_rdprogdir3.htm</file>
        </item>
    </reference>



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

#include "fwlib32.h"

#define BUFSIZE 100

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

        do {
                num = BUFSIZE;
                ret = cnc_rdprogdir4( 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>
