Fanuc C-Executer Operating Manual
B-62443EN-3/03E
- 479 -
[Description]
Reads the macro executor variable (P-code macro variable) data within
the specified range.
Specify the start P-code macro variable number in "s_number"
and the end one in "e_number" with binary format.
The variable data is stored in both "buf.pr_m[i].p6_r.mcr_val" and
"buf.pr_m[i].p6_r.dec_val".
The formats of "mcr_val" and "dec_val" are same as ones of "Read
P-code macro variable(cnc_rdpmacro)". See description of
"cnc_rdpmacro".
Also expanded P-code macro variables (after #20000) which are used
as fixed integer are read as floating point variables.
This function can read only P-code macro variables whose number are
equal to or more than 10000.
"pr_m[i].p2_r.mcr_val" and "pr_m[i].p2_r.dec_val", members of the
structure "odbpr", are definition for compatibility with the past
specification. These are not used now.
[Example]
The following program reads the P-code 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( long start, long end )
{
struct odbpr *buf ;
char strbuf[11] ;
int ret ;
long idx ;
buf = (struct iodbpr *)malloc( 1000 ) ;
ret = cnc_rdpmacror( start, end, 1000, buf ) ;
if ( !ret )
for ( idx = 0 ; idx <= end-start ; idx++ ) {
sprintf( &strbuf[1], "%09ld",
buf->pm_r[idx].p6_r.mcr_val ) ;
if ( strbuf[1] == '0' ) strbuf[1] = ' ' ;
strncpy( &strbuf[0], &strbuf[1],
9 - buf->pm_r[idx].p6_r.dec_val ) ;
strbuf[9-buf->pm_r[idx].p6_r.dec_val] = '.' ;
printf( "#%04ld %s\n", start+idx, strbuf ) ;
}
else
printf( "ERROR!(%d)\n", ret ) ;
free( buf ) ;
return ( ret ) ;
}