⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apsmp.c

📁 CASIO DT900 常上电脑C语言源程序和编译后的程序实例
💻 C
📖 第 1 页 / 共 2 页
字号:
    s_sound( 2250, 5 );            

            lcd_csr_put( 1, 0 );
            cputstr(LCD_ATTR_NORMAL,"重复扫描!(ln518)");
            lcd_csr_put( 5, 0 );
            cputstr(LCD_ATTR_NORMAL,"按任意键继续...");
	    getkey();
	    close(fhnd);
	    continue;
	}
	else
	{
	lseek(fhnd,0L,2);
	write(fhnd,bar,22);
	close(fhnd);	
	}

	if(( fhnd = open("data.txt", O_RDWR  ))== E_LOWERR )
	{  
         fmode=O_CREAT|O_RDWR;
         if(( fhnd = open("data.txt", fmode ))== E_LOWERR )
	   {
            lcd_cls();
            lcd_csr_put( 1, 0 );
            cputstr(LCD_ATTR_NORMAL,"文件打开错误!(ln539)");
            getkey();
            return;                     
	   }
        }
 	lseek(fhnd,0L,2);
 	write(fhnd,att,1);
 	lseek(fhnd,0L,2);
 	write(fhnd,lib_no,3);
 	lseek(fhnd,0L,2);
 	write(fhnd,time,24);
	lseek(fhnd,0L,2);
	if(strlen(sum)==0)
	{
	memcpy(sum,"     ",5);
 	write(fhnd,sum,5);	
	memset(sum,0x0,6);
	}
	else
	write(fhnd,sum,5);	
 	lseek(fhnd,0L,2);
 	write(fhnd,cr,2);
 	lseek(fhnd,0L,2);
 	write(fhnd,bar,22);
 	lseek(fhnd,0L,2);
 	write(fhnd,cr,2);
	n++;
 	close(fhnd);
	break;
	}

	memcpy(temp,bar,22);
	while(1)
	{
	memset(now_s,0x0,6);
	sprintf(now_s,"%5d",n);

	x=atol(now_s);
	y=atol(sum);
	if(x==y)
	{
	
    Wait2( 5L );
    s_sound( 2250, 5 );             
    Wait2( 5L );
    s_sound( 2250, 5 );            
    Wait2( 5L );
    s_sound( 2250, 5 );            

 	lcd_cls();
	lcd_csr_put( 1, 0 );
        cputstr(LCD_ATTR_NORMAL,"已完成设定任务! ");
	lcd_csr_put( 3, 3 );
        cputstr(LCD_ATTR_NORMAL,"已采集      台 ");
	lcd_csr_put( 3, 10 );
        cputstr(LCD_ATTR_WIDTH,sum);
	lcd_csr_put( 5, 0 );
        cputstr(LCD_ATTR_NORMAL,"是否继续? ");
	lcd_csr_put( 7, 0 );
        cputstr(LCD_ATTR_NORMAL,"[ENT是 CLR否]");
	lcd_csr_put( 9, 0 );
        cputstr(LCD_ATTR_WIDTH,dsp);
	key_clear();
        while(((i=getkey())!=0x0c)&&(i!=0x0d));
	if(i==0x0c)
	{
	WriteEnd(sum);
	return;
	}
	else;
	}
 	lcd_cls();
	lcd_csr_put( 9, 0 );
        cputstr(LCD_ATTR_WIDTH,dsp);
	lcd_csr_put( 1, 0 );
        cputstr(LCD_ATTR_NORMAL,"请扫描条码... ");
	lcd_csr_put( 5, 0 );
        cputstr(LCD_ATTR_NORMAL,temp);
	if(strlen(sum)!=0)
	{
	lcd_csr_put( 9, 9 );
        cputstr(LCD_ATTR_NORMAL,now_s);
	lcd_csr_put( 9, 14 );
        cputstr(LCD_ATTR_NORMAL,"/");
	lcd_csr_put( 9, 15 );
        cputstr(LCD_ATTR_NORMAL,sum);
	}
	else
	{
	lcd_csr_put( 9, 8 );
        cputstr(LCD_ATTR_NORMAL,"已采集:");
	lcd_csr_put( 9, 15 );
        cputstr(LCD_ATTR_NORMAL,now_s);
	}
	memset(bar,0x0,23);
        i=read_str(20,1,0,bar,22); 
	if(i==E_KEY_CLR)
	{
	lcd_csr_put( 5, 0 );
        cputstr(LCD_ATTR_NORMAL,"真的要退出吗?        ");
	lcd_csr_put( 7, 0 );
        cputstr(LCD_ATTR_NORMAL,"[ENT是 CLR否]        ");
        while(((i=getkey())!=0x0c)&&(i!=0x0d));
	if(i==0x0d)
	{
	x=atol(now_s);
	memset(now_s,0x0,6);
	sprintf(now_s,"%-5d",x);
	if(strlen(now_s)<5)
	for(j=strlen(now_s);j<5;j++)
	now_s[j]=0x20;
	WriteEnd(now_s);
	return;
	}
	else
	continue;
	}

	if((strlen(bar)==0)||(strlen(bar)>22))
	continue;
	if(strlen(bar)<22)
	for(i=strlen(bar);i<22;i++)
	bar[i]=0x20;
	memset(temp,0x0,23);
	memcpy(temp,bar,22);

	if(( fhnd = open(filename, O_RDWR  ))== E_LOWERR )
	{  
         fmode=O_CREAT|O_RDWR;
         if(( fhnd = open(filename, fmode ))== E_LOWERR )
	   {
            lcd_cls();
            lcd_csr_put( 1, 0 );
            cputstr(LCD_ATTR_NORMAL,"文件打开错误!(ln671)");
            getkey();
            return;                     
	   }
        }
	start=0;
	ret=dat_F_Search(filename,start,22,0,22,bar,buffer,&fp);
	if(ret==E_OK)
	{

    Wait2( 5L );
    s_sound( 2250, 5 );            

            lcd_csr_put( 1, 0 );
            cputstr(LCD_ATTR_NORMAL,"重复扫描!           ");
            lcd_csr_put( 5, 0 );
            cputstr(LCD_ATTR_NORMAL,"按任意键继续...      ");
	    getkey();
	    close(fhnd);
	    continue;
	}
	else
	{
	lseek(fhnd,0L,2);
	write(fhnd,bar,22);
	close(fhnd);	
	}

	if(( fhnd = open("data.txt", O_RDWR  ))== E_LOWERR )
	{
            lcd_cls();
            lcd_csr_put( 1, 0 );
            cputstr(LCD_ATTR_NORMAL,"文件打开错误!(ln503)");
            getkey();
            return;
	}
 	lseek(fhnd,0L,2);
 	write(fhnd,bar,22);
 	lseek(fhnd,0L,2);
 	write(fhnd,cr,2);
	n++;
	close(fhnd);
	}
}

void Calcu(short attr)
{
	int m,n,i,len;
	char dsp[7],bg[3],sp[3],code[23],sum[6];
	H   fmode,fhnd;
	ER ret;
	W start;

	if(( fhnd = open("data.txt", O_RDWR  ))== E_LOWERR )
	{
            lcd_cls();
            lcd_csr_put( 1, 0 );
            cputstr(LCD_ATTR_NORMAL,"无采集数据!(ln728)");
            getkey();
            return;
	}
	close(fhnd);

	memset(dsp,0x0,7);

      switch (attr)
      {
       case 1:
        memcpy(dsp,"1:入库 ",6);
        break;
       case 2:
        memcpy(dsp,"2:移库 ",6);
        break;
       case 3:
        memcpy(dsp,"3:提货 ",6);
        break;
       case 4:
        memcpy(dsp,"4:领用 ",6);
        break;
       case 5:
        memcpy(dsp,"5:盘点 ",6);
        break;
       case 6:
        memcpy(dsp,"6:借机 ",6);
        break;
       default:
	break;
      }

 	lcd_cls();
	lcd_csr_put( 9, 14 );
        cputstr(LCD_ATTR_WIDTH,dsp);
	while(1)
	{
	lcd_csr_put( 1, 0 );
        cputstr(LCD_ATTR_NORMAL,"请输入 ");
	lcd_csr_put( 3, 0 );
        cputstr(LCD_ATTR_NORMAL,"统计条码的起始位: ");
	memset(bg,0x0,3);
        i=read_str(18,3,2,bg,2);
	if(i==E_KEY_CLR)
	return;
	if((strlen(bg)==0)||(strlen(bg)>2))
	continue;
	m=atoi(bg);
	if((m>22)||(m<1))
	continue;
	break;
	}
	while(1)
	{
	lcd_csr_put( 5, 0 );
        cputstr(LCD_ATTR_NORMAL,"请输入 ");
	lcd_csr_put( 7, 0 );
        cputstr(LCD_ATTR_NORMAL,"统计条码的终止位: ");
	memset(sp,0x0,3);
        i=read_str(18,7,2,sp,2);
	if(i==E_KEY_CLR)
	return;
	if((strlen(sp)==0)||(strlen(sp)>2))
	continue;
	n=atoi(sp);
	if((n>22)||(n<1))
	continue;
	if(n<m)
	{
    Wait2( 5L );
    s_sound( 2250, 5 );            
	lcd_csr_put( 9, 0 );
        cputstr(LCD_ATTR_NORMAL,"非法输入!(ln800) ");
	key_clear();	
	getkey();
	return;
	}
	break;
	}

 	lcd_cls();
	lcd_csr_put( 9, 14 );
        cputstr(LCD_ATTR_WIDTH,dsp);
	lcd_csr_put( 3, 5 );
        cputstr(LCD_ATTR_NORMAL,"请稍候...");
	Check(m,n,attr);
 	lcd_cls();
	lcd_csr_put( 9, 14 );
        cputstr(LCD_ATTR_WIDTH,dsp);
	if(( fhnd = open("total.txt", O_RDWR  ))== E_LOWERR )
	{

    Wait2( 5L );
    s_sound( 2250, 5 );             
    Wait2( 5L );
    s_sound( 2250, 5 );             
    Wait2( 5L );
    s_sound( 2250, 5 );             

            lcd_cls();
            lcd_csr_put( 1, 0 );
            cputstr(LCD_ATTR_NORMAL,"无统计结果!(ln829)");
            getkey();
            return;
	}
    	Wait2( 5L );
    	s_sound( 2250, 5 );
	start=0;
	len=n-m+1;
	while(1)
	{
 	lcd_cls();
	lcd_csr_put( 9, 14 );
        cputstr(LCD_ATTR_WIDTH,dsp);
	memset(code,0x0,23);
	memset(sum,0x0,6);
	lseek(fhnd,start,0);
	i=read(fhnd,code,len);
	if(i==0)
	break;
	start+=len;
	lseek(fhnd,start,0);
	i=read(fhnd,sum,5);
	if(i==0)
	break;
	start+=5;
	lcd_csr_put( 1, 0 );
        cputstr(LCD_ATTR_NORMAL,code);
	lcd_csr_put( 3, 2 );
        cputstr(LCD_ATTR_NORMAL,"计      台");
	lcd_csr_put( 3, 5 );
        cputstr(LCD_ATTR_NORMAL,sum);
	memset(code,0x0,23);
	memset(sum,0x0,6);
	lseek(fhnd,start,0);
	i=read(fhnd,code,len);
	if(i==0)
	break;
	start+=len;
	lseek(fhnd,start,0);
	i=read(fhnd,sum,5);
	if(i==0)
	break;
	start+=5;
	lcd_csr_put( 5, 0 );
        cputstr(LCD_ATTR_NORMAL,code);
	lcd_csr_put( 7, 2 );
        cputstr(LCD_ATTR_NORMAL,"计      台");
	lcd_csr_put( 7, 5 );
        cputstr(LCD_ATTR_NORMAL,sum);
	lcd_csr_put( 9, 0 );
        cputstr(LCD_ATTR_NORMAL,"按任意键继续..");
	getkey();
	continue;
	}
	lcd_csr_put( 7, 3 );
        cputstr(LCD_ATTR_NORMAL,"统计完成..    ");	
	lcd_csr_put( 9, 0 );
        cputstr(LCD_ATTR_NORMAL,"按任意键继续  ");	
	getkey();
	close(fhnd);
	dat_fdel("total.txt");
}

void Check(int begin,int stop,int attr)
{
	int i,value,prop;
	H   fmode,fhnd;
	ER ret;
	W start;
	char content[36],key[23];

	if(( fhnd = open("data.txt", O_RDWR  ))== E_LOWERR )
	{
            lcd_cls();
            lcd_csr_put( 1, 0 );
            cputstr(LCD_ATTR_NORMAL,"文件打开错误!(ln904)");
            getkey();
            return;
	}
	start=0;
	while(1)
	{
	lseek(fhnd,start,0);
	memset(content,0x0,36);
	value=read(fhnd,content,35);
	if(value==0)
	{
	close(fhnd);
	return;
	}
	prop=content[0];
	prop-=0x30;
	start+=35;
	if(prop!=attr)
	{
		while(1)
		{
		lseek(fhnd,start,0);
		memset(content,0x0,36);
		value=read(fhnd,content,24);
		if(value!=24)
		{
		close(fhnd);
		return;
		}
		if(content[5]==0x0d)
		{
		start+=7;
		break;
		}
		start+=24;
		}
	}
	else
	{
		while(1)
		{
		lseek(fhnd,start,0);
		memset(content,0x0,36);
		value=read(fhnd,content,24);
		if(value!=24)
		{
		close(fhnd);
		return;
		}
		if(content[22]==0x0d)
		{
		memset(key,0x0,23);
		memcpy(key,content+begin-1,stop-begin+1);
		WriteFile(key);
		start+=24;
		continue;
		}
		start+=7;
		break;
		}
	}
	}
}

void WriteFile(char *content)
{
	H   fmode,fhnd;
	ER ret;
	W start=0,fp,i;
	int Len;
	char buffer[30],fst[6],tmp[6];

        Len=strlen(content)+5;
	memset(fst,0x0,6);
	memcpy(fst,"1    ",5);

	if(( fhnd = open("total.txt", O_RDWR  ))== E_LOWERR )
	{  
         fmode=O_CREAT|O_RDWR;
         if(( fhnd = open("total.txt", fmode ))== E_LOWERR )
	   {
            lcd_cls();
            lcd_csr_put( 1, 0 );
            cputstr(LCD_ATTR_NORMAL,"文件打开错误!(ln988)");
            getkey();
            return;                     
	   }
        }
	memset(buffer,0x0,30);
	ret=dat_F_Search("total.txt",start,Len,0,strlen(content),content,buffer,&fp);
	if(ret!=E_OK)
	{
	lseek(fhnd,0L,2);
	write(fhnd,content,strlen(content));
	lseek(fhnd,0L,2);
	write(fhnd,fst,5);
	}
	else
	{
	memset(tmp,0x0,6);
	memcpy(tmp,buffer+strlen(content),5);
	i=atol(tmp);
	i++;
	sprintf(tmp,"%-5d",i);

/*            lcd_cls();
            lcd_csr_put( 1, 0 );
            cputstr(LCD_ATTR_NORMAL,tmp);
            getkey();*/

	lseek(fhnd,fp+strlen(content),0);
	write(fhnd,tmp,5);
	}
	close(fhnd);
}

void WriteEnd(char *end)
{
	H   fmode,fhnd;
	ER ret;
	char cr[3];
	cr[0]=0x0d;
	cr[1]=0x0a;
	cr[2]=0x00;

	if(( fhnd = open("data.txt", O_RDWR  ))== E_LOWERR )
	{
            lcd_cls();
            lcd_csr_put( 1, 0 );
            cputstr(LCD_ATTR_NORMAL,"文件打开错误!(ln1034)");
            getkey();
            return;
	}
	lseek(fhnd,0L,2);
	write(fhnd,end,5);
	lseek(fhnd,0L,2);
	write(fhnd,cr,2);
	close(fhnd);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -