home *** CD-ROM | disk | FTP | other *** search
Wrap
#include <stdio.h> #include <dos.h> #include <string.h> #include <ctype.h> #include <sys\stat.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,*root5,*root3,*root9,*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(); extern int ob,sub2; extern char condition[200],*con[6]; tj_h() { FILE *fp,*f1; char tail[4], name[13],object[100],repl[250]; int j,k,key,i,ress; char gsxih[50],copyright[60],copyr[13]; /*------------------------------MAKE START----------------------------*/ ress=0; if(num[1]==0) make_file(1); if((insert!='Y')&&(insert!='y')) r_mean(); strcpy(file,"tj_h"); itoa(num[1],tail,10); strcat(file,tail); strcpy(copyr,file); if((insert=='N')||(insert=='n')) w_menuh(); /*-----------WRITE--------------TXT---------------------*/ 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') fprintf(fp,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,p2->length,p2->dec); p2=p2->next; } } root2=root2->next; } fclose(fp); /*--------------------------------end of txt---------------------------*/ strcpy(name,file); strcat(name,".prg"); if((fp=fopen(name,"w"))==NULL) { error("don't open file!"); exit(0); } /*---------------------------------GENE------------------------------*/ 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"); 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 returne---------------------------*/ } 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-----------------------------*/ 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; } /*--------------------------SELECT STATIS FIELD----------------------------------*/ for(;;) { make_t(); object[0]='\0'; 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-all,1--n*/ p1=disp_f(p2,1); sele_f(p2,p1,p4,1,0,0); /*----------------------------------define exper-----------------------------------*/ root2=root; j=0; while(root2!=NULL) { if(root2->sele=='Y') { p2=root2->sstr; while(p2!=NULL) { if(p2->obj=='Y') { tail[0]=(char)j+65; tail[1]='\0'; strcat(object,tail); strcat(object,"->"); strcat(object,p2->field); strcat(object," "); } p2=p2->next; } j++;} root2=root2->next; } make_t(0); print(14,15,6|1,"╟δ═Ω╔╞╘╦╦π▒φ┤∩╩╜"); print(14,60,6|1,"╕▓╕╟"); clear_win(2,0,3,30,6,0,black); print(4,27,6|1,"╟δ╢¿╥σ║ß╧≥═│╝╞▒φ┤∩╩╜"); print(7,10,6|1,"─·┐╔╥╘╙├╝╙║┼'+',╝⌡║┼'-',│╦║┼'*',│²║┼'/',└¿║┼'(',')'"); print(8,10,6|1,"╝░│ú╩²└┤═Ω╔╞╧┬├µ╡─▒φ┤∩╩╜,╩╣╦ⁿ╖√║╧DBASEPLU╗≥FOXBASEPLU"); print(9,10,6|1,"╡─╙╨╣╪╙∩╖¿. **Enter->╜ß╩°**"); oneline(5,98,70,object); clear_win(13,10,15,65,6,0,black); root5=NULL; /* if(ress==0)*/ add_field(0); /* else add_field(3);*/ if(root5==NULL) { clear_obj(0); 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); ob=1; p1=disp_f(p2,1); print(4,5,6|1,"╟δ╤í ╕÷╫╓╢╬╫≈╬¬║ß╧≥═│╝╞╡─╜ß╣√╫╓╢╬"); sele_f(p2,p1,p4,1,1,0); } else { p2=root5->estr; strcpy(name,file); strcat(name,".txt"); if((f1=fopen(name,"a"))!=NULL) { fprintf(f1,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,p2->length,p2->dec); fclose(f1); } else exit(0); } strcpy(repl,p2->field); strcat(repl," with "); strcat(repl,object); /*-----------------------------tj_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 HORIZON -----------------------------------*/ fprintf(fp,"\nif %s\n",condition); fprintf(fp,"repl %s \nendif",repl); clear_win(2,1,3,79,6,0,black); clear_win(5,4,9,76,6,0,black); clear_win(13,4,20,75,6,0,black); printf("\033[8;20H ╝╠╨°╢¿╥σ║ß╧≥═│╝╞┬≡(Y/N)ú┐"); key=getcc(); if((key=='N')||(key=='n')) break; else { clear_obj(0); ress++; ob=0;} } /*endfor*/ /*--------------------------------while circle statits---------------------------*/ fprintf(fp,"\nnu=nu+1\nsele a\nif nu>reccount()\nexit\nendif\nenddo\n"); /*------------------------------end of statits -----------------------------*/ clear_win(5,4,9,76,6,0,black); clear_win(13,4,20,75,6,0,black); print(7,20,6|1,"╥¬╢╘┤╦═│╝╞╜ß╣√┐Γ╜°╨╨═│╝╞┬≡ú┐(Y/N)"); key=getcc(); strcat(file,"j.dbf"); fprintf(fp,"close all\n! copy c:dbf.dbf c:%s > zl\n",file); if((key=='Y')||(key=='y')) { read_key(); strcpy(root3->path,PATH); strcpy(copyright,"copy "); strcat(copyright,copyr); strcat(copyright,".txt "); strcat(copyright,root3->path); strcat(copyright,"\\"); strcat(copyright,root3->dbname); strcat(copyright,".txt"); system(copyright); fprintf(fp,"!copy c:%s %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:%s \n",file); } else { /* root1=root3; root3=root3->last; root3->next=NULL; */ free(root1); fprintf(fp,"! c:brow.exe c:%s \n",file); } num[1]++; 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); if(selecount!=1) { /*fprintf(fp,"!del c:*.?dx >zl\n");*/ fprintf(fp,"!del c:dbf.dbf >zl\n"); } clear_win(5,8,9,70,6,0,black); 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:%s %s >zl",file,gsxih); } fclose(fp); }/*end*/ /*-------------------------WRITE STATIS.TXT -------------------------*/ w_menuh() { FILE *fp; if((fp=fopen("statis1.txt","a"))==NULL) { error("don't open file statis.txt"); exit(1); } fprintf(fp,"#%s#,#%s#\n",workname,file); fclose(fp); } /*----------------------------CLEAR OBJ--------------------------------*/ clear_obj(flag) int flag; {int i; root2=root; while(root2!=NULL) { if(root2->sele=='Y') { p2=root2->sstr; while(p2!=NULL) { p2->obj='N'; p2=p2->next ;} } root2=root2->next; } if(flag==1) { for(i=0;i<4;i++) link[i]=0; linknum=0; } } /*------------------------------ALL END ------------------------------*/