home *** CD-ROM | disk | FTP | other *** search
Wrap
#include <stdio.h> #include <dos.h> #include <string.h> #include <ctype.h> #define black 0x0 #define blue 0x10 #define green 0x20 #define cyan 0x30 #define red 0x40 #define white 0x70 #define PgUp 18688 #define PgDn 20736 #define UP 18432 #define DOWN 20480 #define LEFT 19200 #define RIGHT 19712 #define Enter 13 #define Home 18176 #define End 20224 #define ESC 27 #define Del 21248 #define Ins 20992 #define F1 15104 #define F2 15360 #define F3 15616 #define F4 15872 #define F5 16128 #define F6 16384 #define F7 16640 #define F8 16896 #define F9 17152 #define F10 17408 typedef struct PPP { /* this is a database's structure */ char field[11]; char type; int length; int dec; struct PPP *last; /* poniter of the last block */ struct PPP *next; /* pointer of the next block */ char sele; char obj; int cla; }FIELD; extern FIELD *p,*p5; typedef struct MM { /*store base name*/ char mean[30]; char dbname[11]; /* the name of the database */ char mainkey[4][11]; /* mainkey of the database */ struct PPP *sstr; /* point to the database's structure */ struct PPP *estr;/* pointer for end of block of base*/ char flag; /*if finish base 0--not finish 1--finish*/ char serve; char path[30]; char sele; int sort; char join; struct MM *last; struct MM *next; }BASE ; extern BASE *root,*root3,*root5,*roothead;/* end*/ extern int basecount,selecount,fselecount,linknum,link[5]; extern char linkfield[5][4][11],workname[30],linktype,lan,insert; extern BASE *root2,*root1,*root4; extern FIELD *p1,*p2,*p4; extern int num[6],use; extern char file[13],*title3[],PATH[30]; extern FIELD *NEXT(),*LAST(); extern FIELD *disp_f(),*disp_ch(); extern int ob,f; extern char condition[200],*con[6]; extern char class[3][100],classbak[3][11]; tj_q() { FILE *fp,*fp1; char tail[4], name[13],copyright[60],copyr[13]; int i,j,k,key; char gsxih[50]; /*-------------------------------MAKE START--------------------------------*/ if(num[4]==0) make_file(4); if((insert!='Y')&&(insert!='y')) r_mean(); strcpy(file,"tj_q"); itoa(num[4],tail,10); strcat(file,tail); strcpy(copyr,file); if((insert=='N')||(insert=='n')) w_menuq(); /*-----------------------select object fields-----------------------------*/ make_t(); print(4,30,6|1,"╤í═│╝╞╫╓╢╬"); root2=root; while(root2!=NULL) if(root2->sele=='Y') break; else root2=root2->next; if(root2->sele=='Y') { p=root2->sstr; p4=p2=p; } /*0-all1--n*/ p1=disp_f(p2,1); sele_f(p2,p1,p4,1,0,0); /*------------select statistics condition--------------------------------*/ for(;;) { make_t(); print(4,5,6|1,"╟δ╩Σ╚δ╠⌡╝■▒φ┤∩╩╜"); root2=root; while(root2!=NULL) if(root2->sele=='Y') break; else root2=root2->next; if(root2->sele=='Y') { p=root2->sstr; p4=p2=p; } clear_win(5,4,9,76,6,0,black); p1=disp_f(p2,0); if((sele_f(p2,p1,p4,2,0,0))==1) break; } /*2--condition*/ /*---------------------------gene txt base-------------------------------*/ if(selecount>1) { strcpy(name,file); strcat(name,".txt"); if((fp=fopen(name,"w"))==NULL) { error("▓╗─▄┤≥┐¬╬─╝■!"); exit(0); } root2=root; while(root2!=NULL) { if(root2->sele=='Y') { p2=p=root2->sstr; while(p2!=NULL){ if(p2->sele=='Y') if (p2->obj=='Y') fprintf(fp,"#%s#,#%c#,19,%d\n",p2->field,p2->type,(p2->dec==0? 0:6)); else fprintf(fp,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,p2->length,p2->dec); p2=p2->next; } } root2=root2->next; } fclose(fp); } /*-------------------------gene base--------------------------------------*/ strcpy(name,file); strcat(name,".prg"); if((fp=fopen(name,"w"))==NULL) { error("don't open file!"); exit(0); } fprintf(fp,"set echo off\nset talk off\nset safe off\n"); if((lan=='Y')||(lan=='y')) fprintf(fp,"set excl off\n"); else fprintf(fp, "set excl on\n"); fprintf(fp,"close all\n"); if(selecount>1) { fprintf(fp,"sele 10\nuse dbstr excl\nif reccount()>1\n zap\n endif\n"); strcpy(name,file); strcat(name,".txt"); fprintf(fp,"append from %s deli with #\nuse\n",name); fprintf(fp,"creat dbf from dbstr\n"); } /*----------------------------selcetion & index-------------------------*/ root2=root; for(j=0;j<selecount;j++) { while(root2!=NULL) if(root2->sele=='Y') break; else root2=root2->next; if(root2->join=='Y') fprintf(fp,"if .not.file('%s\\%s.dbf')\nclear\n@12,10 say \"╬─╝■╗╣▓╗┤µ╘┌,─·╙ª╧╚╘╦╨╨▒≡╡─│╠╨≥,▓·╔·┤╦┐Γúí\" \nreturn\nendif\n",root2->path,root2->dbname); fprintf(fp,"sele %c\nuse %s\\%s ",j+65,root2->path,root2->dbname); if(root2->serve!='Y') fprintf(fp," excl \n"); else fprintf(fp," \n"); if(j!=0) { /*-----------------------------------lock---------------------------------*/ if(((lan=='y')||(lan=='Y'))&&(root2->serve=='Y')) { fprintf(fp,"do while .T.\ntime=0\ndo while .not.flock().and.time<250\n"); fprintf(fp,"time=time+1\nenddo\nif time<250\n"); } /*-----------------------------endlock------------------------------------*/ fprintf(fp,"index on"); for(i=0;i<link[j-1];i++) if(i==0) fprintf(fp, " %s",linkfield[j-1][i]); else fprintf(fp,"+%s",linkfield[j-1][i]); fprintf(fp," to ndx%-d\n",j-1);/*j-1*/ /*-------------------------unlock----------------------------------------*/ if(((lan=='y')||(lan=='Y'))&&(root2->serve=='Y')) { fprintf(fp,"unlock\nexit\nelse\nyes=' '\nclear\n@12,10 say \"╬─╝■╥╤▒╗╞Σ╦√╙├╗º,╝╠╨°╝╙╦°┬≡ú┐(Y/N)\" get yes\n"); fprintf(fp,"read\nclear\nif yes='N'.or.yes='n'\n@15,10 say \"╟δ╣²╥╗╗ß╢∙╘┘╙├\" \nwait\n"); fprintf(fp,"return\nendif\nendif\nenddo\n"); } /*----------------------------end unlock cance---------------------------*/ } root2=root2->next; } /*-------------------------set realtion----------------------------*/ if((linktype=='C')||(linktype=='c')) { for(j=0;j<selecount-1;j++) { fprintf(fp,"sele %c\nset relation to ",j+65); for(i=0;i<link[j];i++) if(i==0) fprintf(fp," %s",linkfield[j][i]); else fprintf(fp,"+%s",linkfield[j][i]); fprintf(fp," into %c\n",j+66); } } else for(j=0;j<selecount-1;j++) { fprintf(fp,"sele A\nset relation to "); for(i=0;i<link[j];i++) if(i==0) fprintf(fp, "%s",linkfield[j][i]); else fprintf(fp, "+%s",linkfield[j][i]); fprintf(fp," into %c\n",j+66); } /*----------------------------end relation-----------------------------*/ if(selecount>1) { fprintf(fp,"sele 10\nuse dbf excl\nnu=1\nsele a\n"); fprintf(fp,"do while .T.\n"); fprintf(fp,"go nu\nsele 10\nappen blank\nrepl "); root2=root; while(root2!=NULL) { if(root2->dbname[0]=='\0') root2->sele='N'; root2=root2->next; } root2=root; j=k=0; while(root2!=NULL) { if(root2->sele=='Y') { p2=p=root2->sstr; while(p2!=NULL) { if(p2->sele=='Y') { if(k<5) { fprintf(fp," %s with %c->%s ",p2->field,j+65,p2->field); k++; } else { fprintf(fp,"\nrepl "); fprintf(fp," %s with %c->%s ",p2->field,j+65,p2->field); k=1; } } p2=p2->next; } j++; } root2=root2->next; } fprintf(fp,"\nnu=nu+1\nsele 1\nif nu>reccount()\nexit\nendif\nenddo\nsele 10\n"); } else fprintf(fp,"copy to dbf.dbf\n"); /*-------------------end of gene base ------------------------------------*/ /*-----------------tatistics_class-field----------------------------------*/ make_t(); print(4,30,6|1,"╤í╖╓└α╫╓╢╬"); root2=root; while(root2!=NULL) if(root2->sele=='Y') break; else root2=root2->next; if(root2->sele=='Y') { p=root2->sstr; p4=p2=p; } p1=disp_ch(p2); sele_ch(p2,p1,p4,1); /*-----------------------statistics_class--end-----------------------------*/ strcpy(name,file); strcat(name,"j.txt"); if((fp1=fopen(name,"w"))==NULL) { error("▓╗─▄┤≥┐¬╬─╝■%s",name); exit(0); } else { root2=root; while(root2!=NULL) { if(root2->sele=='Y') { p2=p=root2->sstr; while(p2!=NULL){ if(p2->obj=='Y') fprintf(fp1,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,19,(p2->dec==0? 0:6)); if(p2->cla!=0) fprintf(fp1,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,p2->length,p2->dec); p2=p2->next; } } root2=root2->next; } fclose(fp1); } /*---------------------gene jg base ---------------------------------------*/ strcpy(name,file); strcat(name,".dbf"); fprintf(fp,"\nclose all \nrun copy c:dbf.dbf c:base_jg.dbf >zl\n"); fprintf(fp,"sele 1\nuse base_jg excl\n"); fprintf(fp,"index on "); fprintf(fp," %s ",class[0]); fprintf(fp,"to qundx0\nset index to qundx0\n"); fprintf(fp,"\ngo top\ntotal on "); fprintf(fp," %s ",class[0]); fprintf(fp,"to %sj.dbf fields",file); i=0; root2=root; while(root2!=NULL) { if(root2->sele=='Y') { p2=root2->sstr; while(p2!=NULL) { if(p2->obj=='Y') { if(i==0) fprintf(fp," %s",p2->field); else fprintf(fp," ,%s",p2->field); i++; } p2=p2->next; } } root2=root2->next; } fprintf(fp," for %s \n",condition); fprintf(fp,"!del c:qundx?.?dx >zl\n"); fprintf(fp,"!del c:base_jg.dbf >zl\n"); fprintf(fp,"! c:brow c:%sj.dbf\n",file); /*-----------gene----------------end--------------------------------------*/ clear_win(5,4,9,76,6,0,black); print(7,10,6|1,"╥¬╢╘┤╦═│╝╞╜ß╣√┐Γ╜°╨╨═│╝╞┬≡ú┐(Y/N)"); key=getcc(); root5=NULL; if((key=='Y')||(key=='y')) { read_key(); strcpy(root3->path,PATH); strcpy(copyright,"copy "); strcat(copyright,copyr); strcat(copyright,"j.txt "); strcat(copyright,root3->path); strcat(copyright,"\\"); strcat(copyright,root3->dbname); strcat(copyright,".txt"); system(copyright); fprintf(fp,"!copy c:%sj.dbf %s\\%s.dbf >zl\n",file,root3->path,root3->dbname); root3->serve='N'; root3->join='Y'; roothead->last=root3; root3->next=roothead; roothead=root3; roothead->sstr=NULL; roothead->estr=NULL; fprintf(fp,"! c:brow.exe c:%sj.dbf \n",file); } fprintf(fp,"clear\n"); fprintf(fp,"ser=' '\n@ 10,10 say \"┤╦═│╝╞╜ß╣√╥¬▒╕╖▌┬≡ú┐(Y/N)\" get ser\nread\n"); fprintf(fp,"if ser='Y'.or.ser='y'\n ser=space(30)\n@12,10 say \"╟δ╩Σ╚δ─┐┬╝╝░╬─╝■├√│╞:\" get ser\nread\n"); fprintf(fp,"!copy c:%s &ser > zl\nendif\n",file); fprintf(fp,"!del c:dbf.dbf >zl\n"); clear_win(13,4,20,75,6,0,black); printf("\033[17;20H┤╦═│╝╞╜ß╣√╥¬╣▓╧φ┬≡ú┐(Y/N)"); k=getcc(); if((k=='Y')||(k=='y')) { print(19,10,6|1,"╩Σ╚δ╣▓╧φ─┐┬╝╝░╬─╝■├√: "); scanf("%s",gsxih); fprintf(fp,"!copy c:%sj.dbf %s >zl",file,gsxih); } fclose(fp); num[4]++; }/*end*/ /*--------------------------WRITE STATIS.TXT------------------------------------*/ w_menuq() { FILE *fp; if((fp=fopen("statis4.txt","a"))==NULL) { error("don't open file statis.txt"); exit(1); } fprintf(fp,"#%s#,#%s#\n",workname,file); fclose(fp); } /*--------------------------------END ALL ----------------------------------------*/