Fanuc C-Executer Operating Manual
B-62443EN-3/03E
- 642 -
[Example]
The following program reads a line of alpha-numeric characters from
the MDI panel. Inputting operation is completed by inputting
[INPUT] key. It displays one of '_' (in normal state) and '^' as
cursor.
#include <bios.h>
#include <ctype.h>
#include <stdio.h>
#define BUFSIZE 80
unsigned char buf[BUFSIZE] ;
void example( void )
{
unsigned int idx = 0, stat = 0 ;
unsigned char ch ;
printf( "\033[>5h_" ) ;
for (;;) {
if ( kbhit() ) {
ch = getch() ;
if ( ch == MDIKEY_INPUT ) {
buf[idx] = 0x00 ;
return ;
}
else if ( ( ch == MDIKEY_CAN ) && idx ) {
buf[--idx] = 0x00 ;
printf( "\010 \010\010_" ) ;
stat = 0 ;
}
else if ( isalnum( ch ) && ( idx < BUFSIZE - 1 ) ) {
buf[idx++] = ch ;
printf( "\010%c_", ch ) ;
stat = 0 ;
}
}
else {
if ( aux_mdi_getstat() & MDI_ST_SHIFT ){
if ( !( stat & MDI_ST_SHIFT ) ) {
printf( "\010^" ) ;
stat = MDI_ST_SHIFT ;
}
}
else if ( stat & MDI_ST_SHIFT ) {
printf( "\010_" ) ;
stat = 0 ;
}
}
}
}