home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a014 / 1.ddi / CDBINC.EXE / TJ_Z.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-12  |  27.3 KB  |  901 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,*root3;/* end*/
  67. extern int basecount,selecount,fselecount,linknum,link[5],sub1,sub2;
  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(),*disp_ch();
  75. extern int ob,f;
  76. extern char condition[200],*con[6];
  77. extern char class[3][100],classbak[3][11];
  78. char classtype[3];
  79.  
  80.  tj_z() {
  81.    FILE *fp,*fq;
  82.    char tail[4], name[13];
  83.    char tjztem[3][20],up;
  84.    int  i,j,k,key;
  85.    char gsxih[50];
  86. /*-----------------------------MAKE TITLE------------------------------------*/
  87. f=0;
  88.   for(i=0;i<3;i++)
  89.      { class[i][0]='\0';
  90.        classbak[i][0]='\0';
  91.      }
  92. if(num[2]==0)
  93.       make_file(2);
  94.    if((insert!='Y')&&(insert!='y'))
  95.       r_mean();
  96.   strcpy(file,"tj_z");
  97.   itoa(num[2],tail,10);
  98.   strcat(file,tail);
  99.   if((insert=='n')||(insert=='N'))
  100.      w_menuz();
  101.   clear_win(5,8,9,60,6,0,black);
  102.   print(7,20,6|1,"═│╝╞╜ß╣√╖┼╘┌╒Γ╥╗└α╡─╔╧├µ┬≡ú┐(Y/N)");
  103.   up=getcc();
  104. /*-----------------------------sele object field------------------------------*/
  105.        make_t();
  106.        print(4,30,6|1,"╤í╘±═│╝╞╫╓╢╬");
  107.        root2=root;
  108.       while(root2!=NULL)
  109.      if(root2->sele=='Y') break;
  110.      else root2=root2->next;
  111.      if(root2->sele=='Y') {
  112.        p=root2->sstr;
  113.        p4=p2=p;    }
  114.    /*0-all,1--n*/
  115.       p1=disp_f(p2,1);
  116.       sele_f(p2,p1,p4,1,0,0);
  117. /*-------------------------------sdfskdfjk--------------------------------*/
  118.     strcpy(name,file);
  119.     strcat(name,".prg");
  120.     if((fp=fopen(name,"w"))==NULL) {
  121.        error("don't open file!");
  122.        exit(0); }
  123.     fprintf(fp,"set echo off\nset talk off\nset safe off\n");
  124.     if((lan=='Y')||(lan=='y'))
  125.     fprintf(fp,"set excl off\n");
  126.      else
  127.     fprintf(fp, "set excl on\n");
  128.     fprintf(fp,"close all\n");
  129.     fprintf(fp,"sele 10\nuse dbstr excl\nif reccount()>1\n zap\n endif\n");
  130.     strcpy(name,file);
  131.     strcat(name,".txt");
  132.     fprintf(fp,"append from %s deli with #\nuse\n",name);
  133.     fprintf(fp,"creat dbf from dbstr\nuse\n");
  134.     fprintf(fp,"run copy c:dbf.dbf c:zx_temp.dbf >zl\n");
  135. /*----------------------------selcetion & index-------------------------*/
  136.      root2=root;
  137.      for(j=0;j<selecount;j++) {
  138.         while(root2!=NULL)
  139.            if(root2->sele=='Y') break;
  140.            else root2=root2->next;
  141.         if(root2->join=='Y')
  142.            fprintf(fp,"if .not.file('%s\\%s.dbf')\nclear\n@12,10 say \"╬─╝■╗╣▓╗┤µ╘┌,─·╙ª╧╚╘╦╨╨▒≡╡─│╠╨≥,▓·╔·┤╦┐Γúí\" \nreturn\nendif\n",root2->path,root2->dbname);
  143.        fprintf(fp,"sele %c\nuse %s\\%s ",j+65,root2->path,root2->dbname);
  144.            if(root2->serve!='Y')
  145.         fprintf(fp," excl \n");
  146.       else
  147.            fprintf(fp," \n");
  148.        if(j!=0)
  149.           {
  150. /*-----------------------------------lock---------------------------------*/
  151.           if(((lan=='y')||(lan=='Y'))&&(root2->serve=='Y'))
  152.               {  fprintf(fp,"do while .T.\ntime=0\ndo while .not.flock().and.time<250\n");
  153.                  fprintf(fp,"time=time+1\nenddo\nif time<250\n");
  154.               }
  155. /*-----------------------------endlock------------------------------------*/
  156.          fprintf(fp,"index on");
  157.          for(i=0;i<link[j-1];i++)
  158.              if(i==0)
  159.                fprintf(fp, " %s",linkfield[j-1][i]);
  160.              else
  161.                fprintf(fp,"+%s",linkfield[j-1][i]);
  162.         fprintf(fp," to ndx%-d\n",j-1);/*j-1*/
  163. /*-------------------------unlock----------------------------------------*/
  164.            if(((lan=='y')||(lan=='Y'))&&(root2->serve=='Y'))
  165.              {  fprintf(fp,"unlock\nexit\nelse\nyes=' '\nclear\n@12,10 say \"╬─╝■╥╤▒╗╞Σ╦√╙├╗º,╝╠╨°╝╙╦°┬≡ú┐(Y/N)\" get  yes\n");
  166.             fprintf(fp,"read\nclear\nif yes='N'.or.yes='n'\n@15,10 say \"╟δ╣²╥╗╗ß╢∙╘┘╙├\" \nwait\n");
  167.             fprintf(fp,"return\nendif\nendif\nenddo\n");
  168.              }
  169. /*----------------------------end unlock cance---------------------------*/
  170.           }
  171.               root2=root2->next;
  172.        }
  173. /*-------------------------set realtion----------------------------*/
  174.      if((linktype=='C')||(linktype=='c')) {
  175.      for(j=0;j<selecount-1;j++)
  176.          { fprintf(fp,"sele %c\nset relation to ",j+65);
  177.         for(i=0;i<link[j];i++)
  178.              if(i==0)
  179.              fprintf(fp," %s",linkfield[j][i]);
  180.              else
  181.              fprintf(fp,"+%s",linkfield[j][i]);
  182.         fprintf(fp," into %c\n",j+66);
  183.            }
  184.        }
  185.      else
  186.        for(j=0;j<selecount-1;j++)
  187.         {  fprintf(fp,"sele A\nset relation to ");
  188.            for(i=0;i<link[j];i++)
  189.                if(i==0)
  190.                  fprintf(fp, "%s",linkfield[j][i]);
  191.                else
  192.                 fprintf(fp, "+%s",linkfield[j][i]);
  193.            fprintf(fp," into %c\n",j+66);
  194.          }
  195. /*----------------------------end relation-----------------------------*/
  196.     fprintf(fp,"sele 10\nuse dbf excl\nnu=1\nsele a\n");
  197.     fprintf(fp,"do while .T.\n");
  198.     fprintf(fp,"go nu\nsele 10\nappen blank\nrepl ");
  199.     root2=root;
  200.     while(root2!=NULL)  {
  201.      if(root2->dbname[0]=='\0') root2->sele='N';
  202.      root2=root2->next; }
  203.      root2=root;
  204.     j=k=0;
  205.     while(root2!=NULL) {
  206.       if(root2->sele=='Y') {
  207.      p2=p=root2->sstr;
  208.      while(p2!=NULL) {
  209.          if(p2->sele=='Y') {
  210.          if(k<5) {
  211.             fprintf(fp," %s with %c->%s ",p2->field,j+65,p2->field);
  212.              k++; }
  213.           else {
  214.              fprintf(fp,"\nrepl ");
  215.              fprintf(fp," %s with %c->%s ",p2->field,j+65,p2->field); k=1;} }
  216.          p2=p2->next; }
  217.      j++;    }
  218.       root2=root2->next;   }
  219.     fprintf(fp,"\nnu=nu+1\nsele 1\nif nu>reccount()\nexit\nendif\nenddo\nsele 10\n");
  220. /*-----------------------------end of gene base ---------------------------------*/
  221.  
  222. /*-----------------------------STATIS class  field------------------------------------*/
  223.        make_t();
  224.        print(4,30,6|1 ,"╤í╘±╖╓└α╫╓╢╬");
  225.        root2=root;
  226.        for(i=0;i<3;i++)
  227.       {  class[i][0]='\0';
  228.          classbak[i][0]='\0';
  229.       }
  230.        k=0;
  231.       while(root2!=NULL)
  232.      if(root2->sele=='Y') break;
  233.      else root2=root2->next;
  234.      if(root2->sele=='Y') {
  235.        p=root2->sstr;
  236.        p4=p2=p;    }
  237.       p1=disp_ch(p2);
  238.       sele_ch(p2,p1,p4,3);
  239. /*---------------------------STATIS  class end------------------------------*/
  240. /*--------------------WRITE--------------TXT-------------------------------*/
  241.     strcpy(name,file);
  242.     strcat(name,".txt");
  243.     if((fq=fopen(name,"w"))==NULL) {
  244.        error("▓╗─▄┤≥┐¬╬─╝■!");
  245.        exit(0);   }
  246.      fprintf(fq,"#▒Ω╝╟#,#C#,8,0\n");
  247.     root2=root;
  248.     k=1;
  249.     p2=NULL;
  250.     while(root2!=NULL)
  251.        { if(root2->sele=='Y')
  252.         { p2=p=root2->sstr;
  253.           while(p2!=NULL)
  254.           { if(p2->cla==k)
  255.               { fprintf(fq,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,p2->length,p2->dec);
  256.                 root2=root;
  257.                 k++;
  258.                 break;
  259.               }
  260.              p2=p2->next;
  261.            }
  262.          }
  263.         if(p2==NULL)
  264.          root2=root2->next;
  265.         else
  266.         p2=NULL;
  267.     }
  268.  
  269.      root2=root;
  270.      while(root2!=NULL)  {
  271.        if(root2->sele=='Y') {
  272.      p2=p=root2->sstr;
  273.      while(p2!=NULL){
  274.        if((p2->sele=='Y')&&(p2->cla==0))
  275.            if(p2->obj=='Y')
  276.             fprintf(fq,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,19,(p2->dec==0? 0:6));
  277.            else
  278.            fprintf(fq,"#%s#,#%c#,%d,%d\n",p2->field,p2->type,p2->length,p2->dec);
  279.        p2=p2->next; }  }
  280.        root2=root2->next;  }
  281.        fclose(fq);
  282. /*-----------------------------------end of txt----------------------------*/
  283. /*-------------------------------gene jg base -------------------------------*/
  284.      fprintf(fp,"\close all \nrun copy c:dbf.dbf c:base_jg.dbf >zl\n");
  285.      fprintf(fp,"close all\nsele 9\nuse zx_temp excl\nzap\nuse base_jg excl\n ");
  286.      if(f!=0) {
  287.      fprintf(fp,"index on ");
  288.      if(f==3)
  289.        fprintf(fp," %s+%s+%s  to zxndx \n",class[0],class[1],class[2]);
  290.      if(f==2)
  291.        fprintf(fp,"%s+%s to zxndx\n",class[0],class[1]);
  292.      if(f==1)
  293.      fprintf(fp,"%s to zxndx\n",class[0]);
  294.      }
  295.      fprintf(fp,"\ncopy to zx_jg1.dbf\nset index to\n use\n");
  296.      if(f!=0)
  297.     fprintf(fp,"r=%d\nfen=''\n",f-1);
  298. /*--------------------------------make zsji----------------------------------*/
  299.       if((up=='Y')||(up=='y'))  {
  300.     fprintf(fp,"\nsele 1\nuse zx_jg1 excl\ngo top\nsum ");
  301.         root2=root;
  302.     k=0;
  303.     while(root2!=NULL) {
  304.      if(root2->sele=='Y') {
  305.       p2=root2->sstr;
  306.       while(p2!=NULL) {
  307.        if(p2->obj=='Y') {
  308.         if(k==0)
  309.          fprintf(fp,"%s ",p2->field);
  310.         else
  311.          fprintf(fp,",%s ",p2->field);
  312.           k++;     }
  313.      p2=p2->next;  }
  314.                  }
  315.      root2=root2->next; }
  316.      for(i=0;i<k;i++)
  317.          if(i==0)
  318.            fprintf(fp," to ll%-d",i);
  319.          else
  320.          fprintf(fp,",ll%-d",i);
  321.  
  322.       fprintf(fp,"\ngo top\n");
  323.      k=f;
  324.      if(k==3) {
  325.         fprintf(fp,"l2=%s\n",classbak[2]);
  326.         k--;}
  327.      if(k==2) {
  328.         fprintf(fp,"l1=%s\n",classbak[1]);
  329.          k--;}
  330.      if(k==1)
  331.        fprintf(fp,"l0=%s\n",classbak[0]);
  332.      fprintf(fp,"sele 9\nuse zx_temp excl\nappen blan\nrepl ▒Ω╝╟ with '╫▄╝╞',");
  333.          root2=root;
  334.     k=0;
  335.     while(root2!=NULL) {
  336.      if(root2->sele=='Y') {
  337.       p2=root2->sstr;
  338.       while(p2!=NULL) {
  339.        if(p2->obj=='Y')  {
  340.         if(k==0)
  341.          fprintf(fp,"%s with ll%-d",p2->field,k);
  342.         else
  343.          fprintf(fp,",%s with ll%-d",p2->field,k);
  344.          k++; }
  345.      p2=p2->next;   }
  346.               }
  347.      root2=root2->next; }
  348.      k=f;
  349.     if(k==3) {
  350.        fprintf(fp,",%s with l2",classbak[2]);
  351.        k--;}
  352.     if(k==2) {
  353.        fprintf(fp,",%s with l1",classbak[1]);
  354.        k--;}
  355.     if(k==1)
  356.        fprintf(fp,",%s with l0\n",classbak[0]);}
  357. /*------------------------end of make zsji----------------------------------*/
  358.      if((f==0)&&((up=='Y')||(up=='y')))
  359.      fprintf(fp,"\nclose all\nsele 1\nuse zx_temp\nappen from zx_jg1\nclose all\n");
  360.      if(f!=0) {
  361.        fprintf(fp,"\nuse\ndo while .T.\nsele 1\nuse zx_jg1 excl\n",f-1);
  362.       k=f;
  363.       if((up=='Y')||(up=='y'))
  364.     {
  365.     if(k==3) {
  366.        fprintf(fp,"if r=%d\nstore '%s'-'+'-'%s'-'+'-'%s' to fen\nbiao='╨í╨í╨í╝╞'\nrecall all\nendif\n",f-k,class[0],class[1],class[2]);
  367.      k--; }
  368.       if(k==2) {
  369.     fprintf(fp,"if r=%d\nstore '%s'-'+'-'%s' to fen\nbiao='╨í╨í╝╞'\nrecall all\nendif\n",f-k,class[0],class[1]);
  370.     k--; }
  371.      if(k==1)
  372.     fprintf(fp,"if r=%d\nfen='%s'\nbiao='╨í╝╞'\nrecall all\nendif\n",f-k,class[0]);
  373.     }
  374.     else {
  375.      if(k==3) {
  376.        fprintf(fp,"if r=2\nstore '%s'-'+'-'%s'-'+'-'%s' to fen\nbiao='╨í╨í╨í╝╞'\nrecall all\nendif\n",class[0],class[1],class[2]);
  377.        k--; }
  378.      if(k==2) {
  379.     fprintf(fp,"if r=1\nstore '%s'-'+'-'%s' to fen\nbiao='╨í╨í╝╞'\nrecall all\nendif\n",class[0],class[1]);
  380.     k--; }
  381.      if(k==1)
  382.     fprintf(fp,"if r=0\nfen='%s'\nbiao='╨í╝╞'\nrecall all\nendif\n",class[0]);
  383.     }
  384.      fprintf(fp,"set uniq on\nc=str(r,1)\nindex on &fen to zxndx&c\nset index to zxndx&c\ndele all\nset uniq off\n");
  385.      fprintf(fp,"index on &fen to zxndx&c\nset index to zxndx&c\n go top\nnu=1\n");
  386.      fprintf(fp,"do while .T. \nbegin=nu\nbrec=recno()\nif deleted()\nskip\n nu=nu+1\n erec=recno()\nendif\n");
  387.      fprintf(fp,"do while .not.deleted().and..not.eof()\nskip\nnu=nu+1 \n erec=recno()\nenddo\n");
  388.      fprintf(fp,"erec=recno()\ncnt=nu-begin\ngo brec\nsum next cnt  ");
  389.      root2=root;
  390.      k=0;
  391.      while(root2!=NULL) {
  392.       if(root2->sele=='Y') {
  393.        p2=root2->sstr;
  394.        while(p2!=NULL) {
  395.     if(p2->obj=='Y') {
  396.        if(k==0)
  397.         fprintf(fp,"%s ",p2->field);
  398.        else
  399.         fprintf(fp,",%s ",p2->field);
  400.         k++;  }
  401.      p2=p2->next;  }
  402.                  }
  403.      root2=root2->next; }
  404.        for(i=0;i<k;i++)
  405.      if(i==0)
  406.         fprintf(fp," to ll%-d",i);
  407.      else
  408.        fprintf(fp,",ll%-d",i);
  409.        if((up=='y')||(up=='Y'))
  410.       fprintf(fp,"\ngo brec\n");
  411.     k=f;
  412.        if(k==3) {
  413.      fprintf(fp,"\nstore %s to l2\n",classbak[2]);
  414.      k--; }
  415.        if(k==2 ) {
  416.      fprintf(fp,"\nstore %s to l1\n",classbak[1]);
  417.      k--; }
  418.        if(k==1)
  419.      fprintf(fp,"\nstore %s to l0\n",classbak[0]);
  420.        fprintf(fp,"sele 9\nuse zx_temp excl\nappen blan\nrepl ▒Ω╝╟ with biao,");
  421.        root2=root;
  422.        k=0;
  423.        while(root2!=NULL) {
  424.         if(root2->sele=='Y') {
  425.         p2=root2->sstr;
  426.         while(p2!=NULL) {
  427.           if(p2->obj=='Y') {
  428.          if(k==0)
  429.              fprintf(fp," %s with ll%-d",p2->field,k);
  430.          else
  431.              fprintf(fp,",%s with ll%-d",p2->field,k);
  432.            k++; }
  433.            p2=p2->next;  }
  434.                  }
  435.      root2=root2->next; }
  436.      k=f;
  437.      if(k==3) {
  438.        fprintf(fp,",%s with l2",classbak[2]);
  439.        k--; }
  440.      if(k==2) {
  441.        fprintf(fp,",%s with l1",classbak[1]);
  442.        k--;}
  443.      if(k==1)
  444.        fprintf(fp,",%s with l0\n",classbak[0]);
  445.     fprintf(fp,"\nsele 1\nif nu>reccount()\nexit\nendif\ngo erec\nenddo\nif r=0\nexit\nendif\n");
  446.     fprintf(fp,"r=r-1\nenddo\n");
  447.     }
  448. /*--------------------------------make zsji----------------------------------*/
  449.       if((up=='N')||(up=='n'))  {
  450.     if(f==0)
  451.       fprintf(fp,"\nclose all\nsele 1\nuse zx_jg1\ncopy to zx_out.dbf\nsele 9\n use zx_temp\n");
  452.     fprintf(fp,"set index to \nsele 1\ngo top\nsum ");
  453.         root2=root;
  454.     k=0;
  455.     while(root2!=NULL) {
  456.      if(root2->sele=='Y') {
  457.       p2=root2->sstr;
  458.       while(p2!=NULL) {
  459.        if(p2->obj=='Y') {
  460.         if(k==0)
  461.          fprintf(fp,"%s ",p2->field);
  462.         else
  463.          fprintf(fp,",%s ",p2->field);
  464.           k++;     }
  465.      p2=p2->next;  }
  466.                  }
  467.      root2=root2->next; }
  468.      for(i=0;i<k;i++)
  469.          if(i==0)
  470.            fprintf(fp," to ll%-d",i);
  471.          else
  472.          fprintf(fp,",ll%-d",i);
  473.  
  474.      fprintf(fp,"\ngo bottom\n");
  475.      k=f;
  476.      if(k==3) {
  477.         fprintf(fp,"l2=%s\n",classbak[2]);
  478.         k--;}
  479.      if(k==2) {
  480.         fprintf(fp,"l1=%s\n",classbak[1]);
  481.          k--;}
  482.      if(k==1)
  483.        fprintf(fp,"l0=%s\n",classbak[0]);
  484.      fprintf(fp,"sele 9\nappen blan\nrepl ▒Ω╝╟ with '╫▄╝╞',");
  485.          root2=root;
  486.     k=0;
  487.     while(root2!=NULL) {
  488.      if(root2->sele=='Y') {
  489.       p2=root2->sstr;
  490.       while(p2!=NULL) {
  491.        if(p2->obj=='Y')  {
  492.         if(k==0)
  493.          fprintf(fp,"%s with ll%-d",p2->field,k);
  494.         else
  495.          fprintf(fp,",%s with ll%-d",p2->field,k);
  496.          k++; }
  497.      p2=p2->next;   }
  498.               }
  499.      root2=root2->next; }
  500.      k=f;
  501.     if(k==3) {
  502.        fprintf(fp,",%s with l2",classbak[2]);
  503.        k--;}
  504.     if(k==2) {
  505.        fprintf(fp,",%s with l1",classbak[1]);
  506.        k--;}
  507.     if(k==1)
  508.        fprintf(fp,",%s with l0\n",classbak[0]);}
  509. /*------------------------------end of make zsji----------------------------*/
  510.      if((up=='N')||(up=='n')) {
  511.       if(f!=0) {
  512.      fprintf(fp," use\nsele 1\nappen from zx_temp\n");
  513.      fprintf(fp,"recall all\n close index\nsele 1\nuse zx_jg1 excl\nindex on ");
  514.      for(i=0;i<f;i++)
  515.       if(i==0)
  516.          fprintf(fp,"%s",class[i]);
  517.       else
  518.         fprintf(fp,"+%s",class[i]);
  519.       fprintf(fp," to zxndx\n");
  520.       fprintf(fp,"set index to zxndx\ncopy to zx_out.dbf\nset index to\nuse zx_out excl\n");
  521.       for(i=0;i<f;i++)
  522.          if((classtype[i]=='D')||(classtype[i]=='d'))
  523.          strcpy(tjztem[i],"ctod('  /  /  ')");
  524.          else
  525.         if((classtype[i]=='N')||(classtype[i]=='n'))
  526.             strcpy(tjztem[i],"0");
  527.         else
  528.              strcpy(tjztem[i],"' '");
  529.       if(f==3)
  530.          {     fprintf(fp,"repl %s with %s, %s with %s, %s with %s for ▒Ω╝╟='╫▄╝╞'\n",classbak[0],tjztem[0],classbak[1],tjztem[1],classbak[2],tjztem[2]);
  531.         fprintf(fp,"repl %s with %s, %s with %s for ▒Ω╝╟='╨í╝╞'\n",classbak[1],tjztem[1],classbak[2],tjztem[2]);
  532.         fprintf(fp,"repl %s with %s for ▒Ω╝╟='╨í╨í╝╞'\n",classbak[2],tjztem[2]);
  533.          }
  534.         if(f==2)
  535.            {  fprintf(fp,"repl %s with %s, %s with %s for ▒Ω╝╟='╫▄╝╞'\n",classbak[0],tjztem[0],classbak[1],tjztem[1]);
  536.           fprintf(fp,"repl %s with %s for ▒Ω╝╟='╨í╝╞'\n",classbak[1],tjztem[1]);
  537.            }
  538.         if(f==1)
  539.           fprintf(fp,"repl %s with %s for ▒Ω╝╟='╫▄╝╞'\n",classbak[0],tjztem[0]);
  540.           fprintf(fp,"\nclose all\n! c:brow c:zx_out.dbf\n"); }
  541.          fprintf(fp,"\n!del c:zx_jg1.dbf >zl\n!del c:base*.dbf >zl\n");
  542.           }
  543. /*------------------------------make up tail---------------------------------*/
  544.     else  {  if(f!=0) {
  545.          fprintf(fp," use\nsele 9\nuse zx_temp excl\nindex on ");
  546.               for(i=0;i<f;i++)
  547.           if(i==0)
  548.           fprintf(fp,"%s",class[i]);
  549.           else
  550.          fprintf(fp,"+%s",class[i]);
  551.         fprintf(fp," to zxndx1\ncopy to zx_temp1\nuse zx_temp1 excl\nappen from zx_jg1\n");
  552.         fprintf(fp,"recall all\n close index\nsele 9\nuse zx_temp1 excl\nindex on ");
  553.         for(i=0;i<f;i++)
  554.           if(i==0)
  555.           fprintf(fp,"%s",class[i]);
  556.           else
  557.          fprintf(fp,"+%s",class[i]);
  558.       fprintf(fp," to zxndx\n");
  559.       fprintf(fp,"set index to zxndx\ncopy to zx_out.dbf\nset index to\nuse zx_out excl\n");
  560.       for(i=0;i<f;i++)
  561.          if((classtype[i]=='D')||(classtype[i]=='d'))
  562.          strcpy(tjztem[i],"ctod('  /  /  ')");
  563.          else
  564.         if((classtype[i]=='N')||(classtype[i]=='n'))
  565.             strcpy(tjztem[i],"0");
  566.         else
  567.              strcpy(tjztem[i],"' '");
  568.       if(f==3)
  569.          {     fprintf(fp,"repl %s with %s, %s with %s, %s with %s for ▒Ω╝╟='╫▄╝╞'\n",classbak[0],tjztem[0],classbak[1],tjztem[1],classbak[2],tjztem[2]);
  570.         fprintf(fp,"repl %s with %s, %s with %s for ▒Ω╝╟='╨í╝╞'\n",classbak[1],tjztem[1],classbak[2],tjztem[2]);
  571.         fprintf(fp,"repl %s with %s for ▒Ω╝╟='╨í╨í╝╞'\n",classbak[2],tjztem[2]);
  572.          }
  573.         if(f==2)
  574.            {  fprintf(fp,"repl %s with %s, %s with %s for ▒Ω╝╟='╫▄╝╞'\n",classbak[0],tjztem[0],classbak[1],tjztem[1]);
  575.           fprintf(fp,"repl %s with %s for ▒Ω╝╟='╨í╝╞'\n",classbak[1],tjztem[1]);
  576.            }
  577.         if(f==1)
  578.           fprintf(fp,"repl %s with %s for ▒Ω╝╟='╫▄╝╞'\n",classbak[0],tjztem[0]);
  579.          fprintf(fp,"close all\n! c:brow c:zx_out.dbf\n");
  580.          fprintf(fp,"!del c:zx_jg1.dbf >zl\n!del c:base*.dbf >zl\n");
  581.     /*     fprintf(fp,"!del c:zx_temp?.dbf >zl\n");
  582.          fprintf(fp,"!del c:zxndx?.?dx >zl\n"); */ }
  583.          }
  584.  
  585. /*-------------------------------------MAKE TAIL---------------------------------------*/
  586.      strcat(file,"j.dbf");
  587.      if(f!=0)
  588.     fprintf(fp,"run copy c:zx_out.dbf c:%s > zl\n",file);
  589.      else
  590.     if((up=='Y')||(up=='y'))
  591.         fprintf(fp,"run copy c:zx_temp.dbf c:%s > zl\n! c:brow c:zx_temp.dbf\n",file);
  592.     else
  593.        { fprintf(fp,"\nclose all\nsele 1\nuse zx_out\nappe from zx_temp\nuse\n run copy c:zx_out.dbf c:%s >zl\n",file);
  594.          fprintf(fp,"! c:brow c:zx_out.dbf\n");
  595.        }
  596.      fprintf(fp,"clear\n");
  597.      fprintf(fp,"ser=' '\n@ 10,10 say \"┤╦═│╝╞╜ß╣√╥¬▒╕╖▌┬≡ú┐(Y/N)\"  get ser\nread\n");
  598.      fprintf(fp,"if ser='Y'.or.ser='y'\n ser=space(30)\n@12,10 say \"╟δ╩Σ╚δ─┐┬╝╝░╬─╝■├√│╞:\"  get ser\nread\n");
  599.      fprintf(fp,"!copy c:%s  &ser > zl\nendif\n",file);
  600.      fprintf(fp,"!del c:dbf.dbf >zl\n!del c:zx_out.dbf >zl\n!del c:zx_temp?.dbf >zl\n");
  601.      clear_win(13,4,20,75,6,0,black);
  602.      printf("\033[17;20H┤╦═│╝╞╜ß╣√╥¬╣▓╧φ┬≡ú┐(Y/N)");
  603.      k=getcc();
  604.      if((k=='Y')||(k=='y'))
  605.       { print(19,10,6|1,"╩Σ╚δ╣▓╧φ─┐┬╝╝░╬─╝■├√:  ");
  606.         scanf("%s",gsxih);
  607.         fprintf(fp,"!copy c:%s %s >zl",file,gsxih);
  608.       }
  609.      num[2]++;
  610.     fclose(fp);
  611.    }
  612. /*----------------------------------end of statis zx-----------------------*/
  613.  
  614. /*----------------------------WRITE STATIS.TXT-------------------------------*/
  615.   w_menuz() {
  616.   FILE *fp;
  617.      if((fp=fopen("statis2.txt","a"))==NULL) {
  618.      error("don't open file statis.txt");
  619.       exit(0); }
  620.      fprintf(fp,"#%s#,#%s#\n",workname,file);
  621.      fclose(fp); }
  622.  
  623.  
  624. /*------z------------sele_char type field--------------------------------*/
  625.  sele_ch(ptr,ptr1,ptr2,num)
  626.  FIELD *ptr,*ptr1,*ptr2;
  627.  int num;
  628.  {
  629.  int i,j,k,key2;
  630.  FIELD *tem,*tem1,*tem2;
  631.  char ch[4];
  632. kk2: ptr2=NULL;
  633. begin:
  634.    while(((ptr->type=='L')||(ptr->sele=='N')||(ptr->type=='l'))&&(ptr!=NULL))
  635.       ptr=ptr->next;
  636.      print(6,10,0|75,"%s",ptr->field);
  637.       disp_fmess(ptr);
  638.     i=6;j=10;
  639.     for(;;)  {
  640.      key2=getcc();
  641. mv:      print(i,j,(ptr->cla!=0 ? 0|113:6|1),"%s",ptr->field);
  642.      switch(key2)  {
  643.         case LEFT:
  644.          if(j==10) printf("\007");
  645.          else {
  646.             j=10;
  647.             ptr=ptr->last;
  648.             while(((ptr->type=='L')||(ptr->sele=='N')||(ptr->type=='l'))&&(ptr!=NULL))
  649.                 ptr=ptr->last;
  650.             }
  651.           break;
  652.         case RIGHT:
  653.             tem1=ptr->next;
  654.             while(((tem1->type=='L')||(tem1->sele=='N')||(tem1->type=='l'))&&(tem1!=NULL))
  655.                tem1=tem1->next;
  656.              if((j==40)||(tem1==NULL)) printf("\007");
  657.           else { j=40;
  658.            ptr=ptr->next;
  659.           while(((ptr->type=='L')||(ptr->sele=='N')||(ptr->type=='l'))&&(ptr!=NULL))
  660.              ptr=ptr->next; }
  661.             break;
  662.         case UP:
  663.           if(i==6) printf("\007");
  664.           else {
  665.             i--;
  666.             ptr=ptr->last;
  667.             while((ptr->type=='L')||(ptr->sele=='N')||(ptr->type=='l'))
  668.                ptr=ptr->last;
  669.             ptr=ptr->last;
  670.             while((ptr->type=='L')||(ptr->sele=='N')||(ptr->type=='l'))
  671.             ptr=ptr->last;
  672.             }
  673.            break;
  674.         case DOWN:
  675.              tem1=ptr->next;
  676.              while(((tem1->type=='L')||(tem1->sele=='N')||(tem1->type=='l'))&&(tem1!=NULL))
  677.             tem1=tem1->next;
  678.              tem2=tem1->next;
  679.               while(((tem2->type=='L')||(tem2->sele=='N')||(tem2->type=='l'))&&(tem2!=NULL))
  680.             tem2=tem2->next;
  681.              if((i==10)||((tem2==NULL)||(tem1==NULL))) printf("\007");
  682.              else {
  683.                i++;
  684.             ptr=ptr->next;
  685.                while(((ptr->type=='L')||(ptr->sele=='N')||(ptr->type=='l'))&&(ptr!=NULL))
  686.               ptr=ptr->next;
  687.              ptr=ptr->next;
  688.             while(((ptr->type=='L')||(ptr->sele=='N')||(ptr->type=='l'))&&(ptr!=NULL))
  689.                ptr=ptr->next;}
  690.                break;
  691.         case PgUp:
  692.             k=0;
  693.              tem=ptr;
  694.              ptr=ptr2;
  695.              while(k<10) {
  696.              ptr=ptr->last;
  697.              while((ptr->type=='L')||(ptr->sele=='N')||(ptr->type=='l'))
  698.                 ptr=ptr->last;
  699.              if(ptr==NULL) break;
  700.              k++; }
  701.            if(ptr!=NULL) {
  702.               clear_win(5,3,9,76,6,0,black);
  703.               ptr1=disp_ch(ptr);
  704.               i=6;j=10;
  705.               ptr2=ptr; }
  706.              else {
  707.             ptr=tem;
  708.             printf("\007"); }
  709.            break;
  710.          case PgDn:
  711.             if(ptr1==NULL) printf("\007");
  712.             else  {
  713.             clear_win(5,3,9,76,6,0,black);
  714.             ptr=ptr1;
  715.             ptr1=disp_ch(ptr);
  716.             i=6;j=10;
  717.             ptr2=ptr;   }
  718.               break;
  719.         case Enter:
  720.         case F5:
  721.            ptr->cla!=0 ? f--:f++;
  722.            if(ptr->cla==0)
  723.           { ptr->cla=f;
  724.             classtype[f-1]=ptr->type;
  725.           }
  726.            else
  727.           ptr->cla=0;
  728.            if(f>3)
  729.            { ptr->cla=0;
  730.               f--;
  731.               error("╖╓└α╫╓╢╬▓╗─▄╢α╙┌╚²╕÷!");
  732.               getcc();
  733.               bottom();
  734.            }
  735.            if(num==1)
  736.             { strcpy(class[0],ptr->field);
  737.               return(1);
  738.              }
  739.            break;
  740.         case F6:
  741.          ptr=p;
  742.          f=0;
  743.          while(ptr!=NULL)
  744.           {
  745.            ptr->cla=0;
  746.            ptr=ptr->next;
  747.            }
  748.           return(-1);
  749.         case F4:
  750.             k=0;
  751.             if((sub1==1)&&(sub2==3)&&(f==0))
  752.                {  error("╟δ─·╤í╖╓└α╫╓╢╬úí");
  753.               getcc();
  754.               bottom();
  755.                           root2=root;
  756.               for(i=0;i<3;i++)
  757.                  {  class[i][0]='\0';
  758.                 classbak[i][0]='\0';
  759.                   }
  760.                  k=0;
  761.                 while(root2!=NULL)
  762.                  if(root2->sele=='Y')
  763.                       break;
  764.                  else
  765.                       root2=root2->next;
  766.                 if(root2->sele=='Y') {
  767.                   p=root2->sstr;
  768.                      p4=p2=p;    }
  769.                  p1=disp_ch(p2);
  770.                  ptr=p2;
  771.                  ptr1=p1;
  772.                  ptr2=p4;
  773.                 goto kk2;
  774.             }
  775.             root2=root;
  776.             while(root2!=NULL) {
  777.                if(root2->sele=='Y') {
  778.               ptr2=root2->sstr;
  779.               while(ptr2!=NULL) {
  780.                 if(ptr2->cla==k+1) {
  781.                   clear_win(5,4,9,76,6,0,black);
  782.                   print(6,15,6|1,"─·╥¬╢╘\"%s\"╫╓╢╬╜°╨╨╫╙┤«╖╓└α┬≡ú┐(Y/N):",ptr2->field);
  783.                   printf("\033[6;59H");
  784.                    key2=getcc();
  785.                    root2=root;
  786.                   if((key2=='Y')||(key2=='y')) {
  787.                 print(8,10,6|1,"╟δ╩Σ╚δ╫╙┤«╖╓└α╡─┐¬╩╝╬╗╓├:   ╫╙┤«╬╗╩²:  ");
  788.             yy1:    printf("\033[8;35H");
  789.                 scanf("%d",&i);
  790.                 if((i<=0)||(i>=ptr2->length)) {error(" ╬╗╓├┤φ╬≤!"); goto yy1;}
  791.             yy2:    printf("\033[8;49H");
  792.                                 scanf("%d",&j);
  793.                 if((j<=0)||(j+i>ptr2->length))
  794.                     { error("│¼│÷┴╦▒╛╫╓╢╬╡─╫▄│ñ╢╚!");
  795.                       goto yy2;
  796.                     }
  797.                 if((ptr2->type=='N')||(ptr2->type=='n'))
  798.                     {  strcat(class[k],"substr(str(");
  799.                        strcat(class[k],ptr2->field);
  800.                        strcat(class[k],",");
  801.                        itoa(ptr2->length,ch,10);
  802.                        strcat(class[k],ch);
  803.                        strcat(class[k],",");
  804.                        itoa(ptr2->dec,ch,10);
  805.                        strcat(class[k],ch);
  806.                        strcat(class[k],")");
  807.                      }
  808.                 if ((ptr2->type=='D')||(ptr2->type=='d'))
  809.                     {  strcat(class[k],"substr(dtoc(");
  810.                     strcat(class[k],ptr2->field);
  811.                     strcat(class[k],")");
  812.                     }
  813.                 if((ptr2->type=='C')||(ptr2->type=='c'))
  814.                     {  strcat(class[k],"substr(");
  815.                        strcat(class[k],ptr2->field);
  816.                     }
  817.                 strcat(classbak[k],ptr2->field);
  818.                 strcat(class[k],",");
  819.                 itoa(i,ch,10);
  820.                 strcat(class[k],ch);
  821.                 strcat(class[k],",");
  822.                 itoa(j,ch,10);
  823.                 strcat(class[k],ch);
  824.                 strcat(class[k],")");
  825.                 k++; ptr2=root2->sstr; continue; }
  826.               else
  827.                  { if((ptr2->type=='N')||(ptr2->type=='n'))
  828.                    {  strcat(class[k],"str(");
  829.                       strcat(class[k],ptr2->field);
  830.                       itoa(ptr2->length,ch,10);
  831.                       strcat(class[k],",");
  832.                       strcat(class[k],ch);
  833.                       strcat(class[k],",");
  834.                       itoa(ptr2->dec,ch,10);
  835.                       strcat(class[k],ch);
  836.                       strcat(class[k],")");
  837.                    }
  838.                    if((ptr2->type=='D')||(ptr2->type=='d'))
  839.                    {  strcat(class[k],"str(year(");
  840.                       strcat(class[k],ptr2->field);
  841.                       strcat(class[k],"),4)+str(month(");
  842.                       strcat(class[k],ptr2->field);
  843.                       strcat(class[k],"),2)+str(day(");
  844.                       strcat(class[k],ptr2->field);
  845.                       strcat(class[k],"),2)");
  846.                     }
  847.                 if((ptr2->type=='C')||(ptr2->type=='c'))
  848.                      strcat(class[k],ptr2->field);
  849.                  strcat(classbak[k],ptr2->field);
  850.                  k++;ptr2=root2->sstr; continue;
  851.                   }   }
  852.                  ptr2=ptr2->next;
  853.                   }   }
  854.             root2=root2->next; }
  855.              return(1);
  856.         case End:  /*next select's base*/
  857.           root1=root2;
  858.          while((root2=root2->next)!=NULL) {
  859.            if(root2->sele=='Y') {
  860.             ptr=root2->sstr;
  861.             ptr2=ptr;
  862.             clear_win(5,4,9,76,6,0,black);
  863.             ptr1=disp_ch(ptr);
  864.              i=0;j=10;
  865.               goto begin; } /*endif*/
  866.            }/*endwhile*/
  867.           if(root2==NULL) {
  868.                printf("\007");
  869.                root2=root1; }
  870.          break;
  871.         case Home:/*last select's base*/
  872.            root1=root2;
  873.            while((root2=root2->last)!=NULL) {
  874.              if(root2->sele=='Y') {
  875.              ptr=root2->sstr;
  876.              ptr2=ptr;
  877.              clear_win(5,4,9,76,6,0,black);
  878.              ptr1=disp_ch(ptr);
  879.             i=0;j=10;
  880.             goto begin;}/*endif*/
  881.             } /*endwhile*/
  882.         if(root2==NULL) {
  883.              printf("\007");
  884.              root2=root1;  }
  885.         break;
  886.         default: printf("\007");break;
  887.           }   /*endswitch*/
  888.            print(i,j,(ptr->cla!=0 ? 0|113:0|75),"%s",ptr->field);
  889.            print(4,10,6|1,"%d",f);
  890.            disp_fpart(ptr);
  891.           }/*end for*/
  892.     }
  893.  
  894.  
  895. /*-----------------------------------END ALL-----------------------------*/
  896.  
  897.  
  898.  
  899.  
  900.  
  901.