home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a014 / 1.ddi / CDBINC.EXE / TJ_H.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-11  |  12.4 KB  |  399 lines

  1. #include <stdio.h>
  2. #include <dos.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include <sys\stat.h>
  6.  
  7. #define black  0x0
  8. #define blue   0x10
  9. #define green  0x20
  10. #define cyan   0x30
  11. #define red    0x40
  12. #define white  0x70
  13.  
  14. #define PgUp 18688
  15. #define PgDn 20736
  16. #define UP   18432
  17. #define DOWN 20480
  18. #define LEFT 19200
  19. #define RIGHT 19712
  20. #define Enter 13
  21. #define Home  18176
  22. #define End   20224
  23. #define ESC   27
  24. #define Del 21248
  25. #define Ins 20992
  26.  
  27. #define  F1    15104
  28. #define  F2    15360
  29. #define  F3    15616
  30. #define  F4    15872
  31. #define  F5    16128
  32. #define  F6    16384
  33. #define  F7    16640
  34. #define  F8    16896
  35. #define  F9    17152
  36. #define  F10   17408
  37.  
  38. typedef struct PPP {              /* this is a database's structure */
  39.     char field[11];
  40.     char type;
  41.     int  length;
  42.     int  dec;
  43.        struct PPP *last;          /* poniter of the last block   */
  44.        struct PPP *next;          /* pointer of the next block   */
  45.     char sele;
  46.     char obj;
  47.     int cla;
  48.      }FIELD;
  49. extern FIELD *p,*p5;
  50.  
  51. typedef struct MM {            /*store base name*/
  52.     char mean[30];
  53.     char dbname[11];     /* the name of the database */
  54.     char mainkey[4][11];      /* mainkey of the database  */
  55.     struct PPP  *sstr;   /* point to the database's structure */
  56.     struct PPP  *estr;/* pointer for end of block of base*/
  57.     char flag;           /*if finish base 0--not finish 1--finish*/
  58.     char serve;
  59.     char path[30];
  60.     char sele;
  61.     int sort;
  62.     char join;
  63.     struct MM *last;
  64.     struct MM *next;
  65.       }BASE ;
  66. extern  BASE  *root,*root5,*root3,*root9,*roothead;/* end*/
  67. extern int basecount,selecount,fselecount,linknum,link[5];
  68. extern char linkfield[5][4][11],workname[30],linktype,lan,insert;
  69. extern BASE *root2,*root1,*root4;
  70. extern FIELD *p1,*p2,*p4;
  71. extern int num[6],use;
  72. extern char file[13],*title3[],PATH[30];
  73. extern FIELD *NEXT(),*LAST();
  74. extern FIELD *disp_f();
  75. extern int ob,sub2;
  76. extern char condition[200],*con[6];
  77.  
  78.  
  79.  tj_h() {
  80.    FILE *fp,*f1;
  81.    char tail[4],  name[13],object[100],repl[250];
  82.    int  j,k,key,i,ress;
  83.    char gsxih[50],copyright[60],copyr[13];
  84. /*------------------------------MAKE START----------------------------*/
  85.  ress=0;
  86.  if(num[1]==0)
  87.       make_file(1);
  88.   if((insert!='Y')&&(insert!='y'))
  89.       r_mean();
  90.   strcpy(file,"tj_h");
  91.   itoa(num[1],tail,10);
  92.   strcat(file,tail); strcpy(copyr,file);
  93.   if((insert=='N')||(insert=='n'))
  94.      w_menuh();
  95. /*-----------WRITE--------------TXT---------------------*/
  96.    strcpy(name,file);
  97.     strcat(name,".txt");
  98.     if((fp=fopen(name,"w"))==NULL) {
  99.        error("▓╗─▄┤≥┐¬╬─╝■!");
  100.        exit(0);   }
  101.      root2=root;
  102.      while(root2!=NULL)  {
  103.        if(root2->sele=='Y') {
  104.      p2=p=root2->sstr;
  105.      while(p2!=NULL){
  106.        if(p2->sele=='Y')
  107.           fprintf(fp,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,p2->length,p2->dec);
  108.        p2=p2->next; }  }
  109.        root2=root2->next;  }
  110.        fclose(fp);
  111. /*--------------------------------end of txt---------------------------*/
  112.     strcpy(name,file);
  113.     strcat(name,".prg");
  114.     if((fp=fopen(name,"w"))==NULL) {
  115.        error("don't open file!");
  116.        exit(0); }
  117. /*---------------------------------GENE------------------------------*/
  118.     fprintf(fp,"set echo off\nset talk off\nset safe off\n");
  119.     if((lan=='Y')||(lan=='y'))
  120.     fprintf(fp,"set excl off\n");
  121.      else
  122.     fprintf(fp, "set excl on\n");
  123.     fprintf(fp,"close all\n");
  124.     fprintf(fp,"sele 10\nuse dbstr excl\nif reccount()>1\n zap\n endif\n");
  125.     strcpy(name,file);
  126.     strcat(name,".txt");
  127.     fprintf(fp,"append from %s deli with #\nuse\n",name);
  128.     fprintf(fp,"creat dbf from dbstr\n");
  129. /*----------------------------selcetion & index-------------------------*/
  130.      root2=root;
  131.      for(j=0;j<selecount;j++) {
  132.         while(root2!=NULL)
  133.            if(root2->sele=='Y') break;
  134.            else root2=root2->next;
  135.        if(root2->join=='Y')
  136.            fprintf(fp,"if .not.file('%s\\%s.dbf')\nclear\n@12,10 say \"╬─╝■╗╣▓╗┤µ╘┌,─·╙ª╧╚╘╦╨╨▒≡╡─│╠╨≥,▓·╔·┤╦┐Γúí\" \nreturn\nendif\n",root2->path,root2->dbname);
  137.       fprintf(fp,"sele %c\nuse %s\\%s ",j+65,root2->path,root2->dbname);
  138.       if(root2->serve!='Y')
  139.         fprintf(fp," excl \n");
  140.       else
  141.            fprintf(fp," \n");
  142.  
  143.        if(j!=0)
  144.           {
  145. /*-----------------------------------lock---------------------------------*/
  146.           if(((lan=='Y')||(lan=='y'))&&(root2->serve=='Y'))
  147.              {  fprintf(fp,"do while .T.\ntime=0\ndo while .not.flock().and.time<250\n");
  148.                 fprintf(fp,"time=time+1\nenddo\nif time<250\n");
  149.              }
  150. /*-----------------------------endlock------------------------------------*/
  151.          fprintf(fp,"index on");
  152.          for(i=0;i<link[j-1];i++)
  153.              if(i==0)
  154.                fprintf(fp, " %s",linkfield[j-1][i]);
  155.              else
  156.                fprintf(fp,"+%s",linkfield[j-1][i]);
  157.         fprintf(fp," to ndx%-d\n",j-1);/*j-1*/
  158. /*-------------------------unlock----------------------------------------*/
  159.         if(((lan=='y')||(lan=='Y'))&&(root2->serve=='Y'))
  160.               { fprintf(fp,"unlock\nexit\nelse\nyes=' '\nclear\n@12,10 say \"╬─╝■╥╤▒╗╞Σ╦√╙├╗º,╝╠╨°╝╙╦°┬≡ú┐(Y/N)\" get  yes\n");
  161.             fprintf(fp,"read\nclear\nif yes='N'.or.yes='n'\n@15,10 say \"╟δ╣²╥╗╗ß╢∙╘┘╙├\" \nwait\n");
  162.             fprintf(fp,"return\nendif\nendif\nenddo\n");
  163.               }
  164. /*----------------------------end unlock returne---------------------------*/
  165.           }
  166.               root2=root2->next;
  167.        }
  168. /*-------------------------set realtion----------------------------*/
  169.      if((linktype=='C')||(linktype=='c')) {
  170.      for(j=0;j<selecount-1;j++)
  171.          { fprintf(fp,"sele %c\nset relation to ",j+65);
  172.         for(i=0;i<link[j];i++)
  173.              if(i==0)
  174.              fprintf(fp," %s",linkfield[j][i]);
  175.              else
  176.              fprintf(fp,"+%s",linkfield[j][i]);
  177.         fprintf(fp," into %c\n",j+66);
  178.            }
  179.        }
  180.      else
  181.        for(j=0;j<selecount-1;j++)
  182.         {  fprintf(fp,"sele A\nset relation to ");
  183.            for(i=0;i<link[j];i++)
  184.                if(i==0)
  185.                  fprintf(fp, "%s",linkfield[j][i]);
  186.                else
  187.                 fprintf(fp, "+%s",linkfield[j][i]);
  188.            fprintf(fp," into %c\n",j+66);
  189.          }
  190. /*----------------------------end relation-----------------------------*/
  191.  
  192.    fprintf(fp,"sele 10\nuse dbf excl\nnu=1\nsele a\n");
  193.     fprintf(fp,"do while .T.\n");
  194.     fprintf(fp,"go nu\nsele 10\nappen blank\nrepl ");
  195.     root2=root;
  196.     while(root2!=NULL)  {
  197.      if(root2->dbname[0]=='\0') root2->sele='N';
  198.      root2=root2->next; }
  199.      root2=root;
  200.     j=k=0;
  201.     while(root2!=NULL) {
  202.       if(root2->sele=='Y') {
  203.      p2=p=root2->sstr;
  204.      while(p2!=NULL) {
  205.          if(p2->sele=='Y') {
  206.          if(k<5) {
  207.             fprintf(fp," %s with %c->%s ",p2->field,j+65,p2->field);
  208.              k++; }
  209.           else {
  210.              fprintf(fp,"\nrepl ");
  211.              fprintf(fp," %s with %c->%s ",p2->field,j+65,p2->field); k=1;} }
  212.  
  213.          p2=p2->next; }
  214.      j++;    }
  215.       root2=root2->next;   }
  216. /*--------------------------SELECT STATIS FIELD----------------------------------*/
  217.      for(;;) {
  218.        make_t();
  219.        object[0]='\0';
  220.        root2=root;
  221.       while(root2!=NULL)
  222.      if(root2->sele=='Y') break;
  223.      else root2=root2->next;
  224.      if(root2->sele=='Y') {
  225.        p=root2->sstr;
  226.        p4=p2=p;    }
  227.      /*0-all,1--n*/
  228.       p1=disp_f(p2,1);
  229.       sele_f(p2,p1,p4,1,0,0);
  230. /*----------------------------------define exper-----------------------------------*/
  231.       root2=root;
  232.       j=0;
  233.        while(root2!=NULL) {
  234.        if(root2->sele=='Y') {
  235.          p2=root2->sstr;
  236.          while(p2!=NULL) {
  237.            if(p2->obj=='Y') {
  238.          tail[0]=(char)j+65;
  239.          tail[1]='\0';
  240.           strcat(object,tail);
  241.           strcat(object,"->");
  242.           strcat(object,p2->field);
  243.           strcat(object," "); }
  244.            p2=p2->next;    }
  245.         j++;}
  246.        root2=root2->next;
  247.        }
  248.       make_t(0);
  249.       print(14,15,6|1,"╟δ═Ω╔╞╘╦╦π▒φ┤∩╩╜");
  250.       print(14,60,6|1,"╕▓╕╟");
  251.       clear_win(2,0,3,30,6,0,black);
  252.       print(4,27,6|1,"╟δ╢¿╥σ║ß╧≥═│╝╞▒φ┤∩╩╜");
  253.       print(7,10,6|1,"─·┐╔╥╘╙├╝╙║┼'+',╝⌡║┼'-',│╦║┼'*',│²║┼'/',└¿║┼'(',')'");
  254.       print(8,10,6|1,"╝░│ú╩²└┤═Ω╔╞╧┬├µ╡─▒φ┤∩╩╜,╩╣╦ⁿ╖√║╧DBASEPLU╗≥FOXBASEPLU");
  255.       print(9,10,6|1,"╡─╙╨╣╪╙∩╖¿.       **Enter->╜ß╩°**");
  256.       oneline(5,98,70,object);
  257.       clear_win(13,10,15,65,6,0,black);
  258.       root5=NULL;
  259. /*      if(ress==0)*/
  260.      add_field(0);
  261. /*      else
  262.      add_field(3);*/
  263.       if(root5==NULL)
  264.      {   clear_obj(0);
  265.        root2=root;
  266.        while(root2!=NULL)
  267.            if(root2->sele=='Y') break;
  268.            else root2=root2->next;
  269.        if(root2->sele=='Y')
  270.           {  p=root2->sstr;
  271.          p4=p2=p;
  272.           }
  273.          clear_win(5,4,9,76,6,0,black);
  274.           ob=1;
  275.          p1=disp_f(p2,1);
  276.          print(4,5,6|1,"╟δ╤í   ╕÷╫╓╢╬╫≈╬¬║ß╧≥═│╝╞╡─╜ß╣√╫╓╢╬");
  277.         sele_f(p2,p1,p4,1,1,0);
  278.         }
  279.       else
  280.       { p2=root5->estr;
  281.        strcpy(name,file);
  282.        strcat(name,".txt");
  283.        if((f1=fopen(name,"a"))!=NULL)
  284.           { fprintf(f1,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,p2->length,p2->dec);
  285.            fclose(f1);
  286.           }
  287.        else exit(0);
  288.       }
  289.       strcpy(repl,p2->field);
  290.       strcat(repl," with ");
  291.       strcat(repl,object);
  292. /*-----------------------------tj_condition-------------------------------*/
  293.      for(;;) {
  294.      make_t();
  295.      print(4,5,6|1,"╟δ╩Σ╚δ╠⌡╝■▒φ┤∩╩╜");
  296.      root2=root;
  297.      while(root2!=NULL)
  298.      if(root2->sele=='Y') break;
  299.      else root2=root2->next;
  300.      if(root2->sele=='Y') {
  301.        p=root2->sstr;
  302.       p4=p2=p;     }
  303.      clear_win(5,4,9,76,6,0,black);
  304.      p1=disp_f(p2,0);
  305.     if((sele_f(p2,p1,p4,2,0,0))==1) break; } /*2--condition*/
  306. /*-------------------------GENE HORIZON -----------------------------------*/
  307.      fprintf(fp,"\nif %s\n",condition);
  308.      fprintf(fp,"repl %s \nendif",repl);
  309.      clear_win(2,1,3,79,6,0,black);
  310.      clear_win(5,4,9,76,6,0,black);
  311.       clear_win(13,4,20,75,6,0,black);
  312.       printf("\033[8;20H ╝╠╨°╢¿╥σ║ß╧≥═│╝╞┬≡(Y/N)ú┐");
  313.       key=getcc();
  314.       if((key=='N')||(key=='n')) break;
  315.       else  { clear_obj(0); ress++; ob=0;}
  316.           } /*endfor*/
  317. /*--------------------------------while circle statits---------------------------*/
  318.     fprintf(fp,"\nnu=nu+1\nsele a\nif nu>reccount()\nexit\nendif\nenddo\n");
  319. /*------------------------------end of statits -----------------------------*/
  320.      clear_win(5,4,9,76,6,0,black);
  321.       clear_win(13,4,20,75,6,0,black);
  322.      print(7,20,6|1,"╥¬╢╘┤╦═│╝╞╜ß╣√┐Γ╜°╨╨═│╝╞┬≡ú┐(Y/N)");
  323.      key=getcc();
  324.       strcat(file,"j.dbf");
  325.      fprintf(fp,"close all\n! copy c:dbf.dbf c:%s > zl\n",file);
  326.      if((key=='Y')||(key=='y'))
  327.     { read_key();
  328.  
  329.       strcpy(root3->path,PATH);
  330.       strcpy(copyright,"copy "); strcat(copyright,copyr);
  331.       strcat(copyright,".txt "); strcat(copyright,root3->path);
  332.       strcat(copyright,"\\");
  333.       strcat(copyright,root3->dbname); strcat(copyright,".txt");
  334.           system(copyright);
  335.       fprintf(fp,"!copy c:%s %s\\%s.dbf >zl\n",file,root3->path,root3->dbname);
  336.       root3->serve='N';
  337.       root3->join='Y';
  338.       roothead->last=root3;
  339.           root3->next=roothead;
  340.       roothead=root3;
  341.       roothead->sstr=NULL; roothead->estr=NULL;
  342.       fprintf(fp,"! c:brow.exe c:%s \n",file);
  343.      }
  344.      else
  345.     {
  346. /*      root1=root3;
  347.       root3=root3->last;
  348.       root3->next=NULL; */
  349.       free(root1);
  350.       fprintf(fp,"! c:brow.exe c:%s \n",file);
  351.     }
  352.      num[1]++;
  353.     fprintf(fp,"clear\n");
  354.     fprintf(fp,"ser=' '\n@ 10,10 say \"┤╦═│╝╞╜ß╣√╥¬▒╕╖▌┬≡ú┐(Y/N)\"  get ser\nread\n");
  355.     fprintf(fp,"if ser='Y'.or.ser='y'\n ser=space(30)\n@12,10 say \"╟δ╩Σ╚δ─┐┬╝╝░╬─╝■├√│╞:\"  get ser\nread\n");
  356.     fprintf(fp,"!copy c:%s  &ser > zl\nendif\n",file);
  357.     if(selecount!=1)
  358.         { /*fprintf(fp,"!del c:*.?dx >zl\n");*/
  359.           fprintf(fp,"!del c:dbf.dbf >zl\n");
  360.         }
  361.      clear_win(5,8,9,70,6,0,black);
  362.       clear_win(13,4,20,75,6,0,black);
  363.      printf("\033[17;20H┤╦═│╝╞╜ß╣√╥¬╣▓╧φ┬≡ú┐(Y/N)");
  364.      k=getcc();
  365.       if((k=='Y')||(k=='y'))
  366.         { print(19,10,6|1,"╩Σ╚δ╣▓╧φ─┐┬╝╝░╬─╝■├√:  ");
  367.           scanf("%s",gsxih);
  368.           fprintf(fp,"!copy c:%s %s >zl",file,gsxih);
  369.         }
  370.     fclose(fp);
  371.    }/*end*/
  372.  
  373. /*-------------------------WRITE STATIS.TXT -------------------------*/
  374.   w_menuh() {
  375.   FILE *fp;
  376.      if((fp=fopen("statis1.txt","a"))==NULL) {
  377.      error("don't open file statis.txt");
  378.       exit(1); }
  379.    fprintf(fp,"#%s#,#%s#\n",workname,file);
  380.     fclose(fp);  }
  381. /*----------------------------CLEAR OBJ--------------------------------*/
  382. clear_obj(flag)
  383.    int flag;
  384.    {int i;
  385.      root2=root;
  386.      while(root2!=NULL) {
  387.       if(root2->sele=='Y') {
  388.       p2=root2->sstr;
  389.       while(p2!=NULL) {
  390.       p2->obj='N';
  391.       p2=p2->next ;} }
  392.       root2=root2->next; }
  393.  if(flag==1)
  394.     {  for(i=0;i<4;i++)
  395.       link[i]=0;
  396.        linknum=0;
  397.     }
  398.  }
  399. /*------------------------------ALL END ------------------------------*/