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

  1.  
  2. #include <stdio.h>
  3. #include <dos.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include <sys\stat.h>
  7.  
  8. #define black  0x0
  9. #define blue   0x10
  10. #define green  0x20
  11. #define cyan   0x30
  12. #define red    0x40
  13. #define white  0x70
  14.  
  15. #define PgUp 18688
  16. #define PgDn 20736
  17. #define UP   18432
  18. #define DOWN 20480
  19. #define LEFT 19200
  20. #define RIGHT 19712
  21. #define Enter 13
  22. #define Home  18176
  23. #define End   20224
  24. #define ESC   27
  25. #define Del 21248
  26. #define Ins 20992
  27.  
  28. #define  F1    15104
  29. #define  F2    15360
  30. #define  F3    15616
  31. #define  F4    15872
  32. #define  F5    16128
  33. #define  F6    16384
  34. #define  F7    16640
  35. #define  F8    16896
  36. #define  F9    17152
  37. #define  F10   17408
  38.  
  39. typedef struct PPP {              /* this is a database's structure */
  40.     char field[11];
  41.     char type;
  42.     int  length;
  43.     int  dec;
  44.        struct PPP *last;          /* poniter of the last block   */
  45.        struct PPP *next;          /* pointer of the next block   */
  46.     char sele;
  47.     char obj;
  48.     int cla;
  49.      }FIELD;
  50. extern FIELD *p,*p5;
  51.  
  52. typedef struct MM {            /*store base name*/
  53.     char mean[30];
  54.     char dbname[11];     /* the name of the database */
  55.     char mainkey[4][11];      /* mainkey of the database  */
  56.     struct PPP  *sstr;   /* point to the database's structure */
  57.     struct PPP  *estr;/* pointer for end of block of base*/
  58.     char flag;           /*if finish base 0--not finish 1--finish*/
  59.     char serve;
  60.     char path[30];
  61.     char sele;
  62.     int sort;
  63.     char join;
  64.     struct MM *last;
  65.     struct MM *next;
  66.       }BASE ;
  67. extern  BASE  *root,*root3,*root5,*root6,*roothead;/* end*/
  68. extern int basecount,selecount,fselecount,linknum,link[5];
  69. extern char linkfield[5][4][11],workname[30],linktype,lan,insert;
  70. extern BASE *root2,*root1,*root4;
  71. extern FIELD *p1,*p2,*p4;
  72. extern int num[6],use;
  73. extern char file[13],PATH[30];
  74. extern FIELD *NEXT(),*LAST();
  75. extern FIELD *disp_f(),*disp_ch();
  76. extern int ob,f;
  77. extern char condition[200],*con[6];
  78. extern char class[3][100],classbak[3][11];
  79.  
  80.  tj_t() {
  81.    FILE *fp,*f1,*f2;
  82.    char gsxih[50],copyright[60],copyr[13];
  83.    char tail[4], name[13],*tjtype[]={"╟≤╝╟┬╝╕÷╩²","╟≤╫ε╨í╓╡","╟≤╫ε┤≤╓╡","╟≤╞╜╛∙╓╡","╟≤╫▄║═"};
  84.    int  i,j,k,key,tj,reuse;
  85.    reuse=f=0;
  86.    get_root();
  87.    root6=root1;
  88. /*----------------------------MAKE START---------------------------------*/
  89.   for(i=0;i<3;i++)
  90.      { class[i][0]='\0';
  91.        classbak[i][0]='\0';
  92.      }
  93.  if(num[3]==0)
  94.        make_file(3);
  95.    if((insert!='Y')&&(insert!='y'))
  96.       r_mean();
  97.     strcpy(file,"tj_t");
  98.     itoa(num[3],tail,10);
  99.     strcat(file,tail); strcpy(copyr,file);
  100.     if((insert=='n')||(insert=='N'))
  101.        w_menut();
  102. /*-----------------------------WRITE TXT ---------------------------------*/
  103.    if(selecount!=1)
  104.    {
  105.     strcpy(name,file);
  106.     strcat(name,".txt");
  107.     if((fp=fopen(name,"w"))==NULL)
  108.        { error("▓╗─▄┤≥┐¬╬─╝■!");
  109.      exit(0);
  110.        }
  111.  
  112.  
  113.     root2=root;
  114.     while(root2!=NULL)
  115.     { if(root2->sele=='Y')
  116.           {     p2=p=root2->sstr;
  117.          while(p2!=NULL)
  118.               { if((p2->sele=='Y')&&(p2->cla==0))
  119.                 fprintf(fp,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,p2->length,p2->dec);
  120.             p2=p2->next;
  121.                }
  122.           }
  123.      root2=root2->next;
  124.     }
  125.  
  126.     fclose(fp);
  127.      }
  128. /*-------------------------------end of txt-------------------------------*/
  129. /*------------------------------gene head---------------------------------*/
  130.     strcpy(name,file);
  131.     strcat(name,".prg");
  132.     if((fp=fopen(name,"w"))==NULL)
  133.      {  error("don't open file!");
  134.         exit(0);
  135.      }
  136.     fprintf(fp,"set echo off\nset talk off\nset safe off\n");
  137.     if((lan=='Y')||(lan=='y'))
  138.     fprintf(fp,"set excl off\n");
  139.      else
  140.     fprintf(fp, "set excl on\n");
  141.     fprintf(fp,"close all\n");
  142.     if(selecount!=1)
  143.      {
  144.     fprintf(fp,"sele 10\nuse dbstr excl\nif reccount()>1\n zap\n endif\n");
  145.     strcpy(name,file);
  146.     strcat(name,".txt");
  147.     fprintf(fp,"append from %s deli with #\nuse\n",name);
  148.     fprintf(fp,"creat dbf from dbstr\n");
  149.     }
  150. /*----------------------------selcetion & index-------------------------*/
  151.      root2=root;
  152.      for(j=0;j<selecount;j++) {
  153.         while(root2!=NULL)
  154.            if(root2->sele=='Y') break;
  155.            else root2=root2->next;
  156.         if(root2->join=='Y')
  157.            fprintf(fp,"if .not.file('%s\\%s.dbf')\nclear\n@12,10 say \"╬─╝■╗╣▓╗┤µ╘┌,─·╙ª╧╚╘╦╨╨▒≡╡─│╠╨≥,▓·╔·┤╦┐Γúí\" \nreturn\nendif\n",root2->path,root2->dbname);
  158.        fprintf(fp,"sele %c\nuse %s\\%s ",j+65,root2->path,root2->dbname);
  159.        if(root2->serve!='Y')
  160.         fprintf(fp," excl \n");
  161.       else
  162.            fprintf(fp," \n");
  163.  
  164.        if(j!=0)
  165.           {
  166. /*-----------------------------------lock---------------------------------*/
  167.         if(((lan=='y')||(lan=='Y'))&&(root2->serve=='Y'))
  168.             {  fprintf(fp,"do while .T.\ntime=0\ndo while .not.flock().and.time<250\n");
  169.                fprintf(fp,"time=time+1\nenddo\nif time<250\n");
  170.             }
  171. /*-----------------------------endlock------------------------------------*/
  172.          fprintf(fp,"index on");
  173.          for(i=0;i<link[j-1];i++)
  174.              if(i==0)
  175.                fprintf(fp, " %s",linkfield[j-1][i]);
  176.              else
  177.                fprintf(fp,"+%s",linkfield[j-1][i]);
  178.         fprintf(fp," to ndx%-d\n",j-1);/*j-1*/
  179. /*-------------------------unlock----------------------------------------*/
  180.          if(((lan=='y')||(lan=='Y'))&&(root2->serve=='Y'))
  181.             { fprintf(fp,"unlock\nexit\nelse\nyes=' '\nclear\n@12,10 say \"╬─╝■╥╤▒╗╞Σ╦√╙├╗º,╝╠╨°╝╙╦°┬≡ú┐(Y/N)\" get  yes\n");
  182.               fprintf(fp,"read\nclear\nif yes='N'.or.yes='n'\n@15,10 say \"╟δ╣²╥╗╗ß╢∙╘┘╙├\" \nwait\n");
  183.               fprintf(fp,"return\nendif\nendif\nenddo\n");
  184.             }
  185. /*----------------------------end unlock cance---------------------------*/
  186.            }
  187.         root2=root2->next;
  188.        }
  189. /*-------------------------set realtion----------------------------*/
  190.      if((linktype=='C')||(linktype=='c')) {
  191.      for(j=0;j<selecount-1;j++)
  192.          { fprintf(fp,"sele %c\nset relation to ",j+65);
  193.         for(i=0;i<link[j];i++)
  194.              if(i==0)
  195.              fprintf(fp," %s",linkfield[j][i]);
  196.              else
  197.              fprintf(fp,"+%s",linkfield[j][i]);
  198.         fprintf(fp," into %c\n",j+66);
  199.            }
  200.        }
  201.      else
  202.        for(j=0;j<selecount-1;j++)
  203.         {  fprintf(fp,"sele A\nset relation to ");
  204.            for(i=0;i<link[j];i++)
  205.                if(i==0)
  206.                  fprintf(fp, "%s",linkfield[j][i]);
  207.                else
  208.                 fprintf(fp, "+%s",linkfield[j][i]);
  209.            fprintf(fp," into %c\n",j+66);
  210.          }
  211. /*----------------------------end relation-----------------------------*/
  212.    if(selecount>1)
  213.     {
  214.     fprintf(fp,"sele 10\nuse dbf excl\nnu=1\nsele a\n");
  215.     fprintf(fp,"do while .T.\n");
  216.     fprintf(fp,"go nu\n sele 10\nappen blank\nrepl ");
  217.     root2=root;
  218.     while(root2!=NULL)  {
  219.      if(root2->dbname[0]=='\0') root2->sele='N';
  220.      root2=root2->next; }
  221.      root2=root;
  222.     j=k=0;
  223.     while(root2!=NULL) {
  224.       if(root2->sele=='Y') {
  225.      p2=p=root2->sstr;
  226.      while(p2!=NULL) {
  227.          if(p2->sele=='Y') {
  228.          if(k<5) {
  229.             fprintf(fp," %s with %c->%s ",p2->field,j+65,p2->field);
  230.              k++; }
  231.           else {
  232.              fprintf(fp,"\nrepl ");
  233.              fprintf(fp," %s with %c->%s ",p2->field,j+65,p2->field); k=1;} }
  234.          p2=p2->next; }
  235.      j++;    }
  236.       root2=root2->next;   }
  237.     fprintf(fp,"\nnu=nu+1\nsele 1\nif nu>reccount()\nexit\nendif\nenddo\nsele 10\n");
  238.     }
  239.     else
  240.     fprintf(fp,"copy to dbf.dbf\n");
  241. /*--------------------------end of gene base -----------------------------*/
  242. /*-----------------------statistics_class-field---------------------------*/
  243.        make_t();
  244.        print(4,10,6|1,"%d",0);
  245.        print(4,30,6|1,"╤í╖╓└α╫╓╢╬");
  246.        root2=root;
  247.       while(root2!=NULL)
  248.      if(root2->sele=='Y') break;
  249.      else root2=root2->next;
  250.      if(root2->sele=='Y') {
  251.        p=root2->sstr;
  252.        p4=p2=p;    }
  253.       p1=disp_ch(p2);
  254.       sele_ch(p2,p1,p4,3);
  255. /*-------------------------statistics_class--end--------------------------*/
  256. /*-------------------------gene class base ----------------------------------*/
  257.      fprintf(fp,"\nclose all \nrun copy c:dbf.dbf c:base_jg.dbf >zl\n");
  258.      strcpy(name,file);
  259.      strcat(name,"j.txt");
  260.      fprintf(fp,"sele 10\n use dbstr excl\nzap\nappen from %s deli with #\nuse\ncreat fl_temp from dbstr\n",name);
  261.      fprintf(fp,"close all\nsele 10\nuse fl_temp excl\nzap\nuse base_jg excl\nindex on ");
  262.      if(f==3)
  263.        fprintf(fp," %s+%s+%s  to flndx \n",class[0],class[1],class[2]);
  264.      if(f==2)
  265.        fprintf(fp,"%s+%s to flndx\n",class[0],class[1]);
  266.      if(f==1)
  267.      fprintf(fp,"%s to flndx\n",class[0]);
  268.      fprintf(fp,"copy to fl_jg1.dbf\nset index to\n use\n");
  269.      fprintf(fp,"sele 1\nuse fl_jg1 excl\n");
  270.       k=f;
  271.      if(k==3)
  272.        fprintf(fp,"store '%s'-'+'-'%s'-'+'-'%s' to fen\n",class[0],class[1],class[2]);
  273.      if(k==2)
  274.     fprintf(fp,"store '%s'-'+'-'%s' to fen\n",class[0],class[1]);
  275.      if(k==1)
  276.     fprintf(fp,"fen='%s'\n",class[0]);
  277.      fprintf(fp,"set uniq on\nindex on &fen  to flndx0\nset index to flndx0\ndele all\nset uniq off\n");
  278.      fprintf(fp,"index on &fen to flndx0\nset index to flndx0\n go top\nnu=1\n");
  279.      fprintf(fp,"do while .T. \nbegin=nu\nbrec=recno()\nif deleted()\nskip\n nu=nu+1\n erec=recno()\nendif\n");
  280.      fprintf(fp,"do while .not.deleted().and..not.eof()\nskip\nnu=nu+1 \n erec=recno()\nenddo\n");
  281.      fprintf(fp,"erec=recno()\ncnt=nu-begin\n");
  282. /*------------------------------gene class end----------------------------*/
  283. /*--------------------------------write .jtxt-----------------------------*/
  284.     strcpy(name,file);
  285.     strcat(name,"j.txt");
  286.     if((f1=fopen(name,"w"))==NULL)
  287.      {  error("don't open file!");
  288.         exit(0);
  289.      }
  290.      fclose(f1);
  291.      if((f1=fopen(name,"a"))==NULL)
  292.      {  error("don't open file!");
  293.         exit(0);
  294.      }
  295.     root2=root;
  296.     k=1;
  297.     p2=NULL;
  298.     while(root2!=NULL)
  299.        { if(root2->sele=='Y')
  300.         { p2=p=root2->sstr;
  301.           while(p2!=NULL)
  302.           { if((p2->cla==k)&&(p2->type!='N'))
  303.               { fprintf(f1,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,p2->length,p2->dec);
  304.                 root2=root;
  305.                 k++;
  306.                 break;
  307.               }
  308.              p2=p2->next;
  309.            }
  310.          }
  311.         if(p2==NULL)
  312.          root2=root2->next;
  313.         else
  314.         p2=NULL;
  315.     }
  316.  
  317.     root2=root;
  318.     while(root2!=NULL)
  319.     { if(root2->sele=='Y')
  320.          { p2=root2->sstr;
  321.            while(p2!=NULL)
  322.            { if((p2->cla!=0)&&(p2->type=='N'))
  323.              fprintf(f1,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,p2->length,p2->dec);
  324.              p2=p2->next;
  325.             }
  326.           }
  327.       root2=root2->next;
  328.     }
  329. /*------------------------------end of write .jtxt------------------------*/
  330. /*--------------------------select statistics type -----------------------*/
  331.     for(;;){
  332.      make_t();
  333.      print(4,30,6|1,"╟δ╤í═│╝╞└α╨═");
  334.      for(i=0;i<5;i++)
  335.      print(7,i*12+5,0|15,"%s",tjtype[i]);
  336.      i=0;tj=-1;
  337.      print(7,5,0|75,"%s",tjtype[0]);
  338.      make_ht(10);
  339.      while(tj==-1)
  340.      {  key=getcc();
  341.         print(7,i*12+5,0|15,tjtype[i]);
  342.         switch(key)
  343.         {  case LEFT:
  344.             if(i==0) printf("\007");
  345.             else i--;
  346.             break;
  347.            case RIGHT:
  348.             if(i==4) printf("\007");
  349.             else i++;
  350.             break;
  351.            case Enter:
  352.              tj=i;
  353.              break;
  354.           deflaut : printf("\007");
  355.         }
  356.      print(7,i*12+5,0|75,tjtype[i]);
  357.       }
  358. /*----------------------select object  fields-----------------------------*/
  359.     if(tj!=0)
  360.        {  make_t();
  361.           print(4,30,6|1,"╤í═│╝╞╫╓╢╬");
  362.           root2=root;
  363.           while(root2!=NULL)
  364.         if(root2->sele=='Y') break;
  365.         else root2=root2->next;
  366.          if(root2->sele=='Y')
  367.         {  p=root2->sstr;
  368.            p4=p2=p;
  369.         }
  370.      /*0-all1--n*/
  371.        p1=disp_f(p2,1);
  372.        sele_f(p2,p1,p4,1,0,0);
  373. /*--------------------------get add field --------------------------------*/
  374.        get_root();
  375.        root2=root;
  376.        while(root2!=NULL)
  377.           {  if(root2->sele=='Y')
  378.              {  p2=root2->sstr;
  379.              while(p2!=NULL)
  380.                  {  if(p2->obj=='Y')
  381.                     { clear_win(0,0,4,79,6,0,black);
  382.                       print(4,5,6|1,"╟δ╩Σ╚δ┤µ╖┼╫╓╢╬ %s ═│╝╞╜ß╣√╡─╫╓╢╬├√",p2->field);
  383.                       add_field(1);
  384.                       fprintf(f1,"#%s#,#%c#,%d,%d\n",root5->estr->field,root5->estr->type,root5->estr->length,root5->estr->dec);
  385.                      }
  386.                   p2=p2->next;
  387.                    }
  388.              }
  389.            root2=root2->next;
  390.        }
  391.     } /*endif*/
  392.     else
  393.     { get_root();
  394.       clear_win(0,0,4,79,6,0,black);
  395.       print(4,5,6|1,"╟δ╩Σ╚δ┤µ╖┼╝╟┬╝╕÷╩²╡─╫╓╢╬├√");
  396.       add_field(1);
  397.       fprintf(f1,"#%s#,#%c#,%d,%d\n",root5->sstr->field,root5->sstr->type,root5->sstr->length,root5->sstr->dec);
  398.     }
  399. /*------------------select statistics condition---------------------------*/
  400.      for(;;)
  401.     {  make_t();
  402.        print(4,5,6|1,"╟δ╩Σ╚δ╠⌡╝■▒φ┤∩╩╜");
  403.        root2=root;
  404.        while(root2!=NULL)
  405.         if(root2->sele=='Y') break;
  406.         else root2=root2->next;
  407.        if(root2->sele=='Y')
  408.         { p=root2->sstr;
  409.           p4=p2=p;
  410.         }
  411.        clear_win(5,4,9,76,6,0,black);
  412.        p1=disp_f(p2,0);
  413.        if((sele_f(p2,p1,p4,2,0,0))==1) break;
  414.     } /*2--condition*/
  415. /*--------------------------------condition-------------------------------*/
  416. /*--------------------------GENE TYPE STATIS------------------------------*/
  417.      if(reuse==0)
  418.       fprintf(fp,"sele 10\nuse fl_temp  excl\nappen blan\n");
  419.      switch(tj) {
  420.      case 0:
  421.           fprintf(fp,"\nsele 1\ngo brec\nll0=0\ncctc=0\n");
  422.            i=0;
  423.          root2=root;
  424.           while(root2!=NULL) {
  425.          if(root2->sele=='Y') {
  426.             p2=root2->sstr;
  427.             while(p2!=NULL) {
  428.              if(p2->cla!=0)
  429.                fprintf(fp,"store  %s to l%-d\n",p2->field,i++);
  430.              p2=p2->next;  }  }
  431.         root2=root2->next;   }
  432.           fprintf(fp,"do while cctc<cnt\nif %s\nll0=ll0+1\nendif\ncctc=cctc+1\nskip\nenddo\n",condition);
  433.  
  434.           fprintf(fp,"sele 10\nrepl ");
  435.           root2=root;
  436.            i=0;j=0;k=0;
  437.             while(root2!=NULL) {
  438.            if(root2->sele=='Y') {
  439.           p2=root2->sstr;
  440.           while(p2!=NULL) {
  441.              if(p2->cla!=0) {
  442.               if(k==0)
  443.                   fprintf(fp,"%s with l%-d",p2->field,i++);
  444.               else
  445.                   fprintf(fp, ",%s with l%-d",p2->field,i++);
  446.                   k=1;
  447.                    }
  448.              p2=p2->next;  }  }
  449.         root2=root2->next;   }
  450.         fprintf(fp,",%s with ll0\n",root5->sstr->field);
  451.         break;
  452.      case 1:
  453.          i=0;
  454.          fprintf(fp,"\nsele 1\ngo brec\nn=1\n");
  455.          root2=root;
  456.          while(root2!=NULL) {
  457.            if(root2->sele=='Y') {
  458.           p2=root2->sstr;
  459.           while(p2!=NULL) {
  460.              if(p2->obj=='Y') {
  461.                fprintf(fp,"if %s \nll%-d=%s\nelse\nll%-d=9999999999\nendif\nlll%d=0\n",condition,i,p2->field,i,i);
  462.                i++; }
  463.              p2=p2->next;  }  }
  464.         root2=root2->next;   }
  465.         fprintf(fp,"do while n<=cnt \n");
  466.         i=0;
  467.           root2=root;
  468.          while(root2!=NULL) {
  469.            if(root2->sele=='Y') {
  470.           p2=root2->sstr;
  471.           while(p2!=NULL) {
  472.              if(p2->obj=='Y') {
  473.                fprintf(fp,"if ll%-d>=%s.and.%s\nll%-d=%s\nlll%-d=1\nendif\n",i,p2->field,condition,i,p2->field,i);
  474.               i++; }
  475.              p2=p2->next;  }  }
  476.         root2=root2->next;   }
  477.                 i=0;
  478.       root2=root;
  479.           while(root2!=NULL) {
  480.            if(root2->sele=='Y') {
  481.           p2=root2->sstr;
  482.           while(p2!=NULL) {
  483.              if(p2->cla!=0)
  484.                fprintf(fp,"store  %s to l%-d\n",p2->field,i++);
  485.              p2=p2->next;  }  }
  486.         root2=root2->next;   }
  487.       fprintf(fp,"skip\nn=n+1\nenddo\n");
  488.  
  489.            fprintf(fp,"sele 10 \nrepl ");
  490.            root2=root;
  491.            i=0;j=0;k=0;
  492.            p4=root5->sstr;
  493.            while(root2!=NULL) {
  494.              if(root2->sele=='Y') {
  495.              p2=root2->sstr;
  496.              while(p2!=NULL) {
  497.                  if(p2->cla!=0) {
  498.                  if(k==0)
  499.                        fprintf(fp,"%s with l%-d",p2->field,i++);
  500.                   else
  501.                        fprintf(fp,",%s with l%-d",p2->field,i++);
  502.                   k=1;}
  503.  
  504.              p2=p2->next;  }  }
  505.         root2=root2->next;   }
  506.         root2=root;
  507.         j=0;
  508.         fprintf(fp,"\n");
  509.          p4=root5->sstr;
  510.          while(root2!=NULL) {
  511.              if(root2->sele=='Y') {
  512.              p2=root2->sstr;
  513.              while(p2!=NULL) {
  514.                if(p2->obj=='Y')
  515.                   {   fprintf(fp,"if lll%-d=1\n repl %s with ll%-d \n endif\n",j,p4->field,j);
  516.                    j++;
  517.                   p4=p4->next;
  518.                   }
  519.                p2=p2->next;
  520.                }
  521.             }
  522.              root2=root2->next;
  523.              }
  524.           break;
  525.      case 2:
  526.           i=0;
  527.          fprintf(fp,"\nsele 1\ngo brec\nn=1\n");
  528.          root2=root;
  529.          while(root2!=NULL) {
  530.            if(root2->sele=='Y') {
  531.           p2=root2->sstr;
  532.           while(p2!=NULL) {
  533.              if(p2->obj=='Y') {
  534.                fprintf(fp,"if %s\nll%-d=%s\nelse\nll%-d=-9999999999\nendif\nlll%-d=0\n",condition,i,p2->field,i,i);
  535.                i++; }
  536.              p2=p2->next;  }  }
  537.         root2=root2->next;   }
  538.         fprintf(fp,"do while n<=cnt \n");
  539.         i=0;
  540.                 root2=root;
  541.          while(root2!=NULL) {
  542.            if(root2->sele=='Y') {
  543.           p2=root2->sstr;
  544.           while(p2!=NULL) {
  545.              if(p2->obj=='Y') {
  546.                fprintf(fp,"if ll%-d<=%s.and.%s\nll%-d=%s\nlll%-d=1\nendif\n",i,p2->field,condition,i,p2->field,i);
  547.             i++;}
  548.              p2=p2->next;  }  }
  549.         root2=root2->next;   }
  550.                 i=0;
  551.          root2=root;
  552.        while(root2!=NULL) {
  553.            if(root2->sele=='Y') {
  554.           p2=root2->sstr;
  555.           while(p2!=NULL) {
  556.              if(p2->cla!=0)
  557.                fprintf(fp,"store  %s to l%-d\n",p2->field,i++);
  558.              p2=p2->next;  }  }
  559.         root2=root2->next;   }
  560.       fprintf(fp,"skip\nn=n+1\nenddo\n");
  561.  
  562.        fprintf(fp,"sele 10 \nrepl ");
  563.            root2=root;
  564.         p4=root5->sstr;
  565.            i=0;j=0;k=0;
  566.             while(root2!=NULL) {
  567.            if(root2->sele=='Y') {
  568.           p2=root2->sstr;
  569.           while(p2!=NULL) {
  570.              if(p2->cla!=0)
  571.              { if(k==0)
  572.                    fprintf(fp,"%s with l%-d",p2->field,i++);
  573.                 else
  574.                 fprintf(fp,",%s with l%-d",p2->field,i++);
  575.                 k=1;
  576.              }
  577.  
  578.              p2=p2->next;  }  }
  579.         root2=root2->next;   }
  580.         root2=root;
  581.         j=0;
  582.         fprintf(fp,"\n");
  583.         while(root2!=NULL) {
  584.           if(root2->sele=='Y') {
  585.           p2=root2->sstr;
  586.           while(p2!=NULL) {
  587.                     if(p2->obj=='Y')
  588.               {  fprintf(fp,"if lll%-d=1 \nrepl %s with ll%-d\n endif\n",j,p4->field,j);
  589.                  j++;
  590.                  p4=p4->next;
  591.                }
  592.             p2=p2->next;
  593.             }
  594.           }
  595.           root2=root2->next;
  596.          }
  597.            break;
  598.      case 3:
  599.         fprintf(fp,"\nsele 1\ngo brec\ncctc=0\nactc=0\n");
  600.       i=0;
  601.       root2=root;
  602.  
  603.           while(root2!=NULL) {
  604.            if(root2->sele=='Y') {
  605.           p2=root2->sstr;
  606.           while(p2!=NULL) {
  607.              if(p2->cla!=0)
  608.                fprintf(fp,"store  %s to l%-d\n",p2->field,i++);
  609.              p2=p2->next;  }  }
  610.         root2=root2->next;   }
  611.         i=0;
  612.         root2=root;
  613.         while(root2!=NULL) {
  614.            if(root2->sele=='Y') {
  615.           p2=root2->sstr;
  616.           while(p2!=NULL) {
  617.              if(p2->obj=='Y') {
  618.                 fprintf(fp,"ll%-d=0\n",i);
  619.             i++;          }
  620.              p2=p2->next;  }    }
  621.         root2=root2->next;   }
  622.         fprintf(fp,"do while cctc<cnt\nif %s\n",condition);
  623.         i=0;
  624.         root2=root;
  625.         while(root2!=NULL) {
  626.            if(root2->sele=='Y') {
  627.           p2=root2->sstr;
  628.           while(p2!=NULL) {
  629.              if(p2->obj=='Y') {
  630.                 fprintf(fp,"ll%-d=ll%-d+%s\n",i,i,p2->field);
  631.             i++;          }
  632.              p2=p2->next;  }    }
  633.         root2=root2->next;   }
  634.        fprintf(fp,"actc=actc+1\nendif\ncctc=cctc+1\nskip\nenddo\n");
  635.         i=0;
  636.         root2=root;
  637.         while(root2!=NULL) {
  638.            if(root2->sele=='Y') {
  639.           p2=root2->sstr;
  640.           while(p2!=NULL) {
  641.              if(p2->obj=='Y') {
  642.                 fprintf(fp,"if actc=0\nll%-d=0\nelse\nll%-d=ll%-d/actc\nendif\n",i,i,i);
  643.             i++;          }
  644.              p2=p2->next;  }    }
  645.         root2=root2->next;   }
  646.  
  647.         fprintf(fp,"sele 10 \nrepl ");
  648.          root2=root;
  649.            p4=root5->sstr;
  650.            i=0;j=0;k=0;
  651.             while(root2!=NULL) {
  652.            if(root2->sele=='Y') {
  653.           p2=root2->sstr;
  654.           while(p2!=NULL) {
  655.              if(p2->cla!=0)
  656.              { if(k==0)
  657.                  fprintf(fp,"%s with l%-d",p2->field,i++);
  658.                else
  659.                  fprintf(fp,",%s with l%-d",p2->field,i++);
  660.                k=1;
  661.               }
  662.              if(p2->obj=='Y')
  663.                {  if(k==0)
  664.                    fprintf(fp,"%s with ll%-d",p4->field,j++);
  665.                    else
  666.                    fprintf(fp,",%s with ll%-d",p4->field,j++);
  667.                    k=1;
  668.                    p4=p4->next;
  669.                }
  670.              p2=p2->next;  }  }
  671.         root2=root2->next;   }
  672.         break;
  673.      case 4:
  674.         fprintf(fp,"\nsele 1\ngo brec\ncctc=0\n");
  675.              i=0;
  676.       root2=root;
  677.  
  678.           while(root2!=NULL) {
  679.            if(root2->sele=='Y') {
  680.           p2=root2->sstr;
  681.           while(p2!=NULL) {
  682.              if(p2->cla!=0)
  683.                fprintf(fp,"store  %s to l%-d\n",p2->field,i++);
  684.              p2=p2->next;  }  }
  685.         root2=root2->next;   }
  686.  
  687.         i=0;
  688.         root2=root;
  689.         while(root2!=NULL) {
  690.            if(root2->sele=='Y') {
  691.           p2=root2->sstr;
  692.           while(p2!=NULL) {
  693.              if(p2->obj=='Y') {
  694.                 fprintf(fp,"ll%-d=0\n",i);
  695.             i++;          }
  696.              p2=p2->next;  }    }
  697.         root2=root2->next;   }
  698.         fprintf(fp,"do while cctc<cnt\nif %s\n",condition);
  699.         i=0;
  700.         root2=root;
  701.         while(root2!=NULL) {
  702.            if(root2->sele=='Y') {
  703.           p2=root2->sstr;
  704.           while(p2!=NULL) {
  705.              if(p2->obj=='Y') {
  706.                 fprintf(fp,"ll%-d=ll%-d+%s\n",i,i,p2->field);
  707.             i++;          }
  708.              p2=p2->next;  }    }
  709.         root2=root2->next;   }
  710.        fprintf(fp,"endif\ncctc=cctc+1\nskip\nenddo\n");
  711.         p4=root5->sstr;
  712.         fprintf(fp,"sele 10 \nrepl ");
  713.          root2=root;
  714.            i=0;j=0;k=0;
  715.             while(root2!=NULL) {
  716.            if(root2->sele=='Y') {
  717.           p2=root2->sstr;
  718.           while(p2!=NULL) {
  719.              if(p2->cla!=0)
  720.                { if(k==0)
  721.                   fprintf(fp,"%s with l%-d",p2->field,i++);
  722.              else
  723.                   fprintf(fp,",%s with l%-d",p2->field,i++);
  724.              k=1;
  725.                }
  726.              if(p2->obj=='Y')
  727.               {   if(k==0)
  728.                     fprintf(fp,"%s with ll%-d",p4->field,j++);
  729.                    else
  730.                     fprintf(fp,",%s with ll%-d",p4->field,j++);
  731.                    k=1;
  732.                   p4=p4->next;
  733.               }
  734.              p2=p2->next;  }  }
  735.         root2=root2->next;   }
  736.         break;
  737.      default: break;
  738.      }
  739. /*---------------------------root5<-root6------------------------*/
  740.      p2=root5->sstr;
  741.      while(p2!=NULL)
  742.      { getmem();
  743.        if(root6->sstr==NULL)
  744.           root6->sstr=root6->estr=p1;
  745.        else
  746.           { p1->last=root6->estr;
  747.         root6->estr->next=p1;
  748.         p1->next=NULL;
  749.         root6->estr=p1;
  750.            }
  751.  
  752.        strcpy(p1->field,p2->field);
  753.        p1->type='N';
  754.        p1->length=p2->length;
  755.        p1->dec=p2->dec;
  756.        p2=p2->next;
  757.        }
  758. /*------------------------------------------------------------*/
  759.      free(root5);
  760.      clear_win(5,4,9,76,6,0,black);
  761.      print(7,20,6|1,"╗╣╜°╨╨╞Σ╦√═│╝╞┬≡ú┐(Y/N) ");
  762.      k=getcc();
  763.      reuse++;
  764.      if((k=='N')||(k=='n')) break;
  765.     }
  766.  
  767.  
  768.      fprintf(fp,"\nsele 1\nif nu >reccount() \nexit \n endif\ngo erec \nenddo\n");
  769.      fprintf(fp,"set index to \n sele 10\nclose all\n");
  770.      fprintf(fp,"!del c:fl_jg1.dbf >zl\nuse fl_temp excl\ncopy to %s.dbf\nclose all\n",file);
  771.      fprintf(fp,"! c:brow c:%s.dbf",file);
  772.      fprintf(fp,"\n!copy c:%s.dbf c:%sj.dbf >zl\n",file,file);
  773. /*------------------------------re utili----------------------------------*/
  774.       clear_win(5,4,9,76,6,0,black);
  775.       clear_win(13,4,20,75,6,0,black);
  776.       print(7,20,6|1,"╥¬╢╘┤╦═│╝╞╜ß╣√┐Γ╜°╨╨═│╝╞┬≡ú┐(Y/N) ");
  777.       root5=root6;
  778.       root2=root;
  779.       while(root2!=NULL)
  780.       { if(root2->sele=='Y')
  781.         { p2=root2->sstr;
  782.          while(p2!=NULL)
  783.            { if(p2->cla==0)
  784.              p2->sele='N';
  785.          else
  786.             p2->sele='Y';
  787.         p2=p2->next;
  788.           }
  789.         }
  790.         root2=root2->next;
  791.       }
  792.        key=getcc();
  793.       fclose(f1);
  794.       if((key=='Y')||(key=='y'))
  795.     { read_key();
  796.       strcpy(root3->path,PATH);
  797.       strcpy(copyright,"copy "); strcat(copyright,copyr);
  798.       strcat(copyright,"j.txt "); strcat(copyright,root3->path);
  799.       strcat(copyright,"\\");
  800.       strcat(copyright,root3->dbname); strcat(copyright,".txt");
  801.           system(copyright);
  802.       fprintf(fp,"\n!copy c:%sj.dbf %s\\%s.dbf >zl\n",file,root3->path,root3->dbname);
  803.       root3->serve='N';
  804.       root3->join='Y';
  805.       roothead->last=root3;
  806.           root3->next=roothead;
  807.       roothead=root3;
  808.       roothead->sstr=NULL; roothead->estr=NULL;
  809.       root3->serve='N';
  810.       root3->join='Y';
  811.  
  812.      }
  813.        else
  814.       free(root6);
  815. /*-----------------------end of re----------------------------------------*/
  816. /*-----------------------end---------------------------------------------*/
  817.     fprintf(fp,"clear\n");
  818.     fprintf(fp,"ser=' '\n@ 10,10 say \"┤╦═│╝╞╜ß╣√╥¬▒╕╖▌┬≡ú┐(Y/N)\"  get ser\nread\n");
  819.     fprintf(fp,"if ser='Y'.or.ser='y'\n ser=space(30)\n@12,10 say \"╟δ╩Σ╚δ─┐┬╝╝░╬─╝■├√│╞:\"  get ser\nread\n");
  820.     fprintf(fp,"!copy c:%sj.dbf  &ser > zl\nendif\n",file);
  821.     fprintf(fp,"!del c:dbf.dbf >zl\n");
  822.     clear_win(13,4,20,75,6,0,black);
  823.      printf("\033[17;20H┤╦═│╝╞╜ß╣√╥¬╣▓╧φ┬≡ú┐(Y/N)");
  824.       k=getcc();
  825.      if((k=='Y')||(k=='y'))
  826.        { print(19,10,6|1,"╩Σ╚δ╣▓╧φ─┐┬╝╝░╬─╝■├√:  ");
  827.          scanf("%s",gsxih);
  828.          fprintf(fp,"!copy c:%sj.dbf %s >zl",file,gsxih);
  829.        }
  830.    fclose(fp);
  831.    num[3]++;
  832.    }/*end*/
  833.  
  834. /*----------------------------------MAKE HELP ---------------------------*/
  835.  
  836.  make_ht(f)
  837. int f; {
  838.  if(f==10) {
  839.    print(f+5,30,6|1,"<╣ª─▄╦╡├≈>");
  840.    print(f+6,15,6|1,"╒Γ╨⌐╣ª─▄╩╟╙├╗º╘┌╜°╨╨╫╓╢╬═│╝╞╩▒,╧╡═│╦∙╠ß╣⌐╡─");
  841.    print(f+8,15,6|1,"╕≈╓╓═│╝╞╣ª─▄,╞Σ╓╨╟≤╝╟┬╝╕÷╩²--┐╔╤í╚╬╥Γ└α╨═╫╓╢╬;");
  842.    print(f+10,15,6|1,"╢°╞Σ╦ⁿ╡─╘≥▒╪╨δ╤í╩²╫╓╨═╫╓╢╬.╫╓╢╬╕÷╩²▓╗╧▐."); }
  843.     }
  844. /*----------------------WRITE STATIS.TXT---------------------------------*/
  845.  
  846.   w_menut() {
  847.   FILE *fp;
  848.      if((fp=fopen("statis3.txt","a"))==NULL) {
  849.      error("don't open file statis.txt");
  850.       exit(1); }
  851.      fprintf(fp,"#%s#,#%s#\n",workname,file);
  852.     fclose(fp); }
  853. /*----------------------------END ALL ------------------------------------*/
  854.  
  855.