📄 keypad.c
字号:
gotoxy(0, 7);
scputs("1 YES 2 NO ");
while(1)
{
c = getchar();
if(c == '1')
{
chsize(input_file, 0);
chsize(oper_file, 0);
gotoxy(0, 5);
clr_eol();
puts("完成!");
gotoxy(0, 7);
clr_eol();
OSTimeDly(100);
break;
}
else if(c == '2')
break;
}
}
nSelection = 1;
UppcMenu(1);
break;
case '2':
result = UploadData (2, output_file);
if(result == TRUE)
{
clr_scr();
gotoxy(0, 1);
scputs("传送完成!");
gotoxy(0, 3);
scputs("清空文件吗?");
gotoxy(0, 7);
scputs("1 YES 2 NO ");
while(1)
{
c = getchar();
if(c == '1')
{
chsize(output_file, 0);
chsize(prov_file, 0);
gotoxy(0, 5);
clr_eol();
puts("完成!");
gotoxy(0, 7);
clr_eol();
OSTimeDly(100);
break;
}
else if(c == '2')
break;
OSTimeDly (8);
}
}
nSelection = 2;
UppcMenu(1);
break;
case '3':
UploadDBF(prov_file, 2);
nSelection = 3;
UppcMenu(1);
break;
case '4':
UploadDBF(cust_file, 2);
nSelection = 4;
UppcMenu(1);
break;
case '5':
UploadDBF(oper_file, 2);
nSelection = 5;
UppcMenu(1);
break;
case '6':
UploadDBF(ishee_file, 2);
nSelection = 6;
UppcMenu(1);
break;
case '7':
UploadDBF(oshee_file, 2);
nSelection = 7;
UppcMenu(1);
break;
default:
break;
}
}
/*********************************************************************
以下是只读取扫描头录入信息,并显示在屏幕上的函数
int x; x position for display
int y; x position for display
char *s; returned string read from keyboard
int num; number of key to be read 读取的字节数
int type; 0/1, digit/alpha-num
*********************************************************************/
int read_scode(int x, int y, char *s, int num, int type)
{
int index;
char dummy[30];
dummy[0]=0x00;
for (index=0; index <num; index++)
{
strcat(dummy," ");
}
SetCursor(1);
gotoxy(x,y);
InitScanner1 ();
while(1)
{
if(Decode())
{
if(strlen(CodeBuf)<=13)
{
beep_ok();
gotoxy(x,y);
printf("%s",CodeBuf);
strcpy(s,CodeBuf);
SetCursor(0);
HaltScanner1 ();
return(0);
}
else beep_err();
}
if ((c=getchar())!=0x00)
{
switch (c)
{
case KEY_CR :
s[0]=0x00;
SetCursor(0);
HaltScanner1 ();
return(0);
case KEY_ESC :
SetCursor(0);
s[0]=0x00;
HaltScanner1 ();
return(-1);
default :
break;
}
}
}
}
/*********************************************************************
以下是读取键盘录入信息,并显示在屏幕上的函数
int x; x position for display
int y; x position for display
char *s; returned string read from keyboard
int num; number of key to be read 读取的字节数
int type; 0/1, digit/alpha-num
*********************************************************************/
int read_nkey(int x, int y, char *s, int num, int type)
{
int index;
int l=0;
char dummy[50];
char c;
dummy[0]=0x00;
for (index=0; index <num; index++)
{strcat(dummy," ");}//向dummy的尾部添加字符串" "(空格)
gotoxy(x,y);
printf("%s",dummy);
gotoxy(x,y);
k1: SetCursor(1);//选择:(1)显示光标 (0)隐藏光标 Cursor:'kE:sE指针
while(1)
{
while( (c=getchar()) == 0x00 );
if ( ((type != 0) && (isalnum(c))) || ((type==0) && (isdigit(c)))|| c=='+' || c=='$' ||c=='/' ||c=='*'||c=='-'||c=='%'||c==':'||c==' ' )
{
if(l==0)
{
gotoxy(x,y);
printf("%s",dummy);
gotoxy(x,y);
}
if (l >= num)
{
beep_err();
}
else
{
putchar(c);
s[l++]=c;
}
}
else switch (c)
{
case KEY_CR :
s[l]=0x00;
SetCursor(0);
return(0);
case KEY_ESC :
SetCursor(0);
s[0]=0x00;
return(-1);
case KEY_BS :
if (l == 0)
{
beep_err();
}
else
{
l--;
s[l]=0x00;
gotoxy(x,y);
printf("%s",dummy);
gotoxy(x,y);
printf("%s",s);
}
break;
default :
break;
}
}
}
/*
key input with laser scan
int x; x position for display
int y; x position for display
char *s; returned string read from keyboard
int num; number of key to be read
int type; 0/1, digit/alpha-num
*/
int read_skey(int x, int y, char *s, int num, int type)
{
int index;
int l=0;
int pflag=0;
char dummy[30];
char c;
dummy[0]=0x00;
for (index=0; index <num; index++)
{
strcat(dummy," ");
}
SetCursor(1);
gotoxy(x,y);
InitScanner1 ();
k1:
while(1)
{
if(Decode())
{
if(strlen(CodeBuf)<=20)
{
beep_ok();
gotoxy(x,y);
printf("%s",CodeBuf);
while(strlen(CodeBuf)<20)
{
strcat(CodeBuf," ");
CodeBuf[20]=0x00;
}
strcpy(s,CodeBuf);
SetCursor(0);
HaltScanner1 (); //test
return(0);
}
else beep_err();
}
if ((c=getchar())!=0x00)
{
if (c == 32 || c== '-') /* space */
{
if (l >= num)
{
SetCursor(0);
beep_err(); /* correct type */
}
else
{
if(pflag==0)
{
pflag=1;
gotoxy(x,y);
SetCursor(1);
printf("%s",dummy);
gotoxy(x,y);
}
if(c==32)
{
putchar(' ');
s[l++]=32;
}
else
{
putchar('-');
s[l++]=32;
}
if (l==num)
gotoxy(14,3);
}
}
else if ( ((type!=0) && (isalnum(c))) || ((type==0) && (isdigit(c)))|| c=='+' || c=='$' ||c=='/' ||c=='*'||c=='%'||c==':' )
{
if (l >= num)
{
SetCursor(0);
beep_err();
}
else
{
if(pflag==0)
{
pflag=1;
gotoxy(x,y);
SetCursor(1);
printf("%s",dummy);
gotoxy(x,y);
}
putchar(c);
s[l++]=c;
}
}
else switch (c)
{
case KEY_CR : /*COMPLETE*/
s[l]=0x00;
SetCursor(0);
HaltScanner1 (); //test
return(0);
case KEY_ESC : /* abandom */
SetCursor(0);
s[0]=0x00;
HaltScanner1 (); //test
if(l==0) return(-1);
else return(-8);
case KEY_BS : /* erase last key */
if (l == 0) { beep_err(); }
else
{
l--;
s[l]=0x00;
gotoxy(x,y);
printf("%s",dummy);
gotoxy(x,y);
printf("%s",s);
}
break;
default :
break;
}
}
}
}
//settime
void GetKeyData (int x, int y, int len, char *str);
//时间设置----------------------------------------------------------------//
void INPUTSHOWTIME (BYTE c)
{
switch(c)
{
case KEY_ESC:
GJXMenu(1);
break;
case '1':
SettimeMenu(1);
break;
case '2':
GJXMenu(1);
break;
default:
break;
}
}
void SettimeInput(BYTE c)
{
switch(c)
{
case KEY_ESC:
ShowtimeMenu(1);
break;
case KEY_CR:
set_time (stime);
on_beeper (ok_beep);
SCDispLine (4, "修改成功 ", 1);
OSTimeDly(150);
ShowtimeMenu(1);
break;
default:
break;
}
}
//************************************************
// GetKeyData() : Get keyboard data.
//************************************************
void GetKeyData (int x, int y, int len, char *str)
{
int i, xpos, ypos, pos;
char ckey, skeydata[50];
clr_kb ();
SetCursor (1);
pos = 0;
skeydata[0] = 0;
xpos = x;
ypos = y;
gotoxy (xpos, ypos);
while(1)
{
if (ckey = getchar())
{
switch (ckey)
{
case KEY_BS:
if (pos == 0) break;
gotoxy (--xpos, ypos);
putchar (0x20);
skeydata [--pos] = 0;
gotoxy (xpos, ypos);
break;
case KEY_CR:
if (pos < len) break;
skeydata [pos] = 0;
strcpy (str, skeydata);
SetCursor (0);
return;
default:
if (ckey < '0' || ckey > '9') break;
gotoxy (xpos, ypos);
putchar (ckey);
skeydata [pos++] = ckey;
gotoxy (++xpos, ypos);
if (pos >= len)
{
skeydata [len] = 0;
strcpy (str, skeydata);
SetCursor (0);
return;
}
break;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -