📄 newwalk.cpp
字号:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <io.h>
#include <fcntl.h>
#include "commplus.h"
#include <htlcd.h>
#include <htxlcd.h>
#include "htproces.h"
#define _filename "D:\\TEXT\\QDTable.dbf"
typedef struct {
char Meterno[8];
unsigned char Flag;
char StartDateTime[14];
char EndDateTime[14];
} DBF_REC;
typedef struct {
char Meterno[9];
unsigned char Flag;
unsigned char StartDateTime[20];
unsigned char EndDateTime[20];
} C_REC;
extern unsigned _stklen = 32768U;
extern unsigned _heaplen = 1024U;
long fhdsize;
long frcsize;
long reccount;
FILE * fhandle;
DBF_REC dbfitem;
C_REC readitem;
int getdatetime(char *dt,char *todt)
{
memcpy(todt,dt,4);
todt[4]='-';
memcpy(todt+5,dt+4,2);
todt[7]='-';
memcpy(todt+8,dt+6,2);
todt[8]='-';
memcpy(todt+11,dt+8,2);
todt[11]=' ';
memcpy(todt+14,dt+10,2);
todt[14]=':';
memcpy(todt+17,dt+12,2);
todt[17]=':';
memcpy(todt+20,dt+14,2);
return 1;
}
int dbf2c(DBF_REC &dbf,C_REC &c)
{
memcpy(c.Meterno,dbf.Meterno,8);
c.Meterno[9]=0;
c.Flag=dbf.Flag;
getdatetime (c.StartDateTime,dbf.StartDateTime);
return 1;
}
int dbfopen(FILE * fhdl, long *fhdsize,
long *frcsize, long *reccount)
{
unsigned tmp;
char fhead[12];
//unsigned char * fbuff=new char [255];
//fread(fbuff,255,1,fhdl);
fread(fhead,12,1,fhdl);
//delete [] fbuff;
*fhdsize = * (unsigned *)&fhead[8];
*frcsize = * (unsigned *)&fhead[10];
*reccount = * (unsigned *)&fhead[4];
return(0);
}
void dbfread(DBF_REC *crecord)
{
unsigned tmp;
fread(&crecord,38,1,fhandle);
}
void dbfclose(void)
{
fclose(fhandle);
}
void beep(int cnt)
{
int i;
for (i=0; i<cnt; i++)
asm {
mov ax, 0e07h
int 10h
}
}
int main()
{
long numofrec;
fhandle=fopen(_filename,"r");
unsigned tmp;
char fhead[12];
fread(fhead,12,1,fhandle);
fhdsize = * (unsigned *) &fhead[8];
frcsize = * (unsigned *) &fhead[10];
reccount = * (unsigned *)&fhead[4];
fseek(fhandle,162L,0);
dbfread(&dbfitem);
dbf2c(dbfitem,readitem);
dbfclose();
return(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -