Fanuc C-Executer Operating Manual
B-62443EN-3/03E
- 470 -
[Description]
Reads the custom macro variable data stored in the CNC within the
specified range.
Types of custom macro variable are as follows.
(1) Local variables ( #1,..,#33 )
Not readable. (Use cnc_rdmacro function.)
(2) Common variables ( #100,..,#149, #500,..,#531 )
Readable. In case that Custom macro common variable addition option is
added, #100,..,#199 and #500,..,#999 are available to be read.
(3) System variables ( #1000,.. )
Not readable. (Use cnc_rdmacro function.)
Refer "OPERATOR'S MANUAL" of CNC for details of custom macro
variables.
Specify the start custom macro variable number in "s_number"
and the end one in "e_number" with binary format.
The variable data is stored in both "buf.data[i].mcr_val" and
"buf.data[i].dec_val".
The formats of "mcr_val" and "dec_val" are same as ones of "Read
custom macro variable(cnc_rdmacro)". See description of "cnc_rdmacro".
[Example]
The following program reads the custom macro variables within the
specified range and displays them.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* start/end are start/end variable number to be read. */
int example( int start, int end )
{
struct odbmr *buf ;
char strbuf[11] ;
int ret, idx ;
buf = (struct iodbmr *)malloc( 1000 ) ;
ret = cnc_rdmacror( start, end, 1000, buf ) ;
if ( !ret )
for ( idx = 0 ; idx <= end-start ; idx++ ) {
sprintf( &strbuf[1], "%09ld",
buf->data[idx].mcr_val ) ;
if ( strbuf[1] == '0' ) strbuf[1] = ' ' ;
strncpy( &strbuf[0], &strbuf[1],
9 - buf->data[idx].dec_val ) ;
strbuf[9-buf->data[idx].dec_val] = '.' ;
printf( "#%04d %s\n", start+idx, strbuf ) ;
}
else
printf( "ERROR!(%d)\n", ret ) ;
free( buf ) ;
return ( ret ) ;
}