📄 global.c
字号:
/*
filename: Global.c
purpose: define the global parameter and function
author: wx
date: 2003-3-20
*/
#include "8000lib.h"
#include <ucos.h>
#include "global.h"
#include "..\\lib\\ucos.h"
int nStatus; // current state : current function or menu
int nSelection; // current selection of the menu
SETTINGS SysParam;
int modify_flag; // if the SysParam was modifid 0: no 1:modified
int ok_beep[] = { 23,25, 0,0 }; // define the beep sequence for OK
int err_beep[] = { 22,10, 20,10, 22,10, 20,10, 0,0 }; // define the beep sequence for ERR
int init_beep[] = { 20,50, 0,5, 20,50, 0,5, 20,50, 0,5, 0,0};//define the beep sequence for end of transimission
char temp[10]; // Operator Code
int oper_file; // operator file
int prov_file; // provider file
int cust_file; // customer file
int good_file; // good file
int ishee_file; // input sheet file
int oshee_file; // output sheet file
int repeat_file; //a temp file
int input_file; // input file
int output_file; //output file
char err;
// define Barcode decode table
BYTE DefaultBCR [23] =
{ 0x9b, 0xc9, 0x00, 0x00, 0x00, 0x21, 0x54, 0x80, 0x00, 0x9d,
0x3d, 0x50, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
0x66, 0x03, 0x03 };
// system fault routine
static void system_fault (void);
/***************************************************************************/
/* This function will be execute only when the program restart (not resume)*/
/* Actually this function is called from the main() in USER.c */
/***************************************************************************/
void SysInit (void)
{
int i, j;
char f_name[100];
clr_scr ();
//beep_ok();
SetCursor (CURSOR_OFF);
SetFont (2);
//close all the DAT & DBF files
for (i=1; i<=32; i++)
{
close (i);
close_DBF (i);
}
//init operator file
strcpy(f_name,"OPER");
if ((oper_file = create_DBF(f_name, 20)) > 0) //入库
{
create_index(oper_file, 1, 0, 13);
}
else oper_file = open_DBF(f_name);
//init customer file
strcpy(f_name,"CUST");
if ((cust_file = create_DBF(f_name, 20)) > 0)
{
create_index(cust_file, 1, 0, 13);
//create_index(cust_file, 2, 0, 2);
}
else cust_file = open_DBF(f_name);
//init provider file
strcpy(f_name,"PROV");
if ((prov_file = create_DBF(f_name, 20)) > 0) //出库
{
create_index(prov_file, 1, 0, 13);
}
else prov_file = open_DBF(f_name);
//init good file
strcpy(f_name,"GOOD");
if ((good_file = create_DBF(f_name, 20)) > 0)
{
create_index(good_file, 1, 0, 13);
}
else good_file = open_DBF(f_name);
//init inputsheet file
strcpy(f_name,"ISHEE");
if ((ishee_file = create_DBF(f_name, 20)) > 0)
{
create_index(ishee_file, 1, 0, 13);
}
else ishee_file = open_DBF(f_name);
//init ouputsheet file
strcpy(f_name,"OSHEE");
if ((oshee_file = create_DBF(f_name, 20)) > 0)
{
create_index(oshee_file, 1, 0, 13);
}
else oshee_file = open_DBF(f_name);
//init input file
strcpy(f_name,"INPUT");
input_file = open(f_name);
//init output file
strcpy(f_name,"OUTPUT");
output_file = open(f_name);
temp[0]=0x00;
nSelection = 1;
modify_flag = 0;
WelcMenu (1);
}
void DispString (int x, int y, char *str, int mode)
{
if (y < 0 || y > MaxRow)
return;
SetVideoMode (mode);
gotoxy (x, y);
printf ("%s", str);
SetVideoMode (0);
}
/*
display a english ling
*/
void DispLine(int line, char *str, int mode)
{
int y;
if(line < 1 || line > 4)
return;
y = line * 2 - 1;
SetVideoMode (mode);
gotoxy (0, y);
printf ("%s", str);
SetVideoMode (0);
}
/*
display a simplify chinese string line
*/
void SCDispLine(int line, char *str, int mode)
{
int y;
if(line < 1 || line > 4)
return;
y = line * 2 - 1;
SetVideoMode (mode);
gotoxy (0, y);
scputs (str);
SetVideoMode (0);
}
static void system_fault (void)
{
char *s;
clr_scr ();
strcpy(s,"System fault");
DispString (0, 1, s, 0);
strcpy(s,"Call service");
DispString (0, 5, s, 0);
while (1);
}
void ShowDate (void)
{
int i;
int iday;
int font;
char t[20];
char zTime [16];
char szBuf[20];
get_time (zTime);
for (i=0; i<4; i++)
szBuf [i] = zTime [i];
szBuf [i++] = '/';
szBuf [i++] = zTime [4];
szBuf [i++] = zTime [5];
szBuf [i++] = '/';
szBuf [i++] = zTime [6];
szBuf [i++] = zTime [7];
szBuf [i] = 0;
t[0]=zTime[8];
t[1]=zTime[9];
t[2]=':';
t[3]=zTime[10];
t[4]=zTime[11];
t[5]=':';
t[6]=zTime[12];
t[7]=zTime[13];
t[8]=0;
iday = DayOfWeek();
font = GetFont();
SetFont(1);
gotoxy(0,7);
printf("%s",szBuf);
gotoxy (11, 7);
//puts ("TODAY IS ");
switch (iday)
{
case 1:
printf ("<MON>");
SetFont(font);
break;
case 2:
printf ("<TUE>");
SetFont(font);
break;
case 3:
printf ("<WED>");
break;
case 4:
printf ("<THU>");
SetFont(font);
break;
case 5:
printf ("<FRI>");
SetFont(font);
break;
case 6:
printf ("<SAT>");
SetFont(font);
break;
case 7:
printf ("<SUN>");
SetFont(font);
break;
}
SetFont(font);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -