home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a014 / 1.ddi / CDBINC.EXE / MSORT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-09  |  11.1 KB  |  313 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. main(argc,argv)
  4. int argc;
  5. char *argv[];
  6. {
  7.   FILE *fp;
  8.   fp=fopen("sort.prg","w");
  9.   fprintf(fp,"********************************************************\n");
  10.   fprintf(fp,"*  ┼┼╨≥─ú┐Θ( ╙╔sor.prg lsort.prg st.prg sort.dbf╫Θ│╔ ) *\n");
  11.   fprintf(fp,"*  sort.prg maked by hyy of st5622 of BUAA             *           ì\n");
  12.   fprintf(fp,"********************************************************\n");
  13.   fprintf(fp,"********************************************************\n");
  14.   fprintf(fp,"set safe off\nset color to w/b,w/rr,gr\n");
  15.   fprintf(fp,"set talk off\n");
  16.   fprintf(fp,"do while .t.\n");
  17.   fprintf(fp,"  set color to 6/0,0/6,0\n");
  18.   fprintf(fp,"  clear\n");
  19.   fprintf(fp,"  set color to 0/3,3/0,0\n");
  20.   fprintf(fp,"  cho=' '\n  fname=space(8)\n");
  21.   fprintf(fp,"  do while at(cho,'0123')=0\n");
  22.   fprintf(fp,"    @6 ,19 say '⌐│⌐Ñ⌐Ñ⌐Ñ╟δ ╤í ╘± ╥╘ ╧┬ ╣ª ─▄⌐Ñ⌐Ñ⌐╖'\n");
  23.   fprintf(fp,"    @7 ,19 say '⌐º                              ⌐º'\n");
  24.   fprintf(fp,"    @8 ,19 say '⌐º   1 --- ╜¿┴ó┼┼╨≥┐Γ           ⌐º'\n");
  25.   fprintf(fp,"    @9 ,19 say '⌐º                              ⌐º'\n");
  26.   fprintf(fp,"    @10,19 say '⌐º   2 --- ╧╘╩╛╗≥┤≥╙í┼┼╨≥┐Γ     ⌐º'\n");
  27.   fprintf(fp,"    @11,19 say '⌐º                              ⌐º'\n");
  28.   fprintf(fp,"    @12,19 say '⌐º   3 --- ╔╛│²┼┼╨≥┐Γ           ⌐º'\n");
  29.   fprintf(fp,"    @13,19 say '⌐º                              ⌐º'\n");
  30.   fprintf(fp,"    @14,19 say '⌐╗⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐┐'\n");
  31.   fprintf(fp,"    set color to 6/0,0/6,0\n");
  32.   fprintf(fp,"    @16,19 say '╩Σ╚δ╥╗╕÷╩²╫╓(1--3),╗≥░┤ 0 ╖╡╗╪:' get cho pict '9'\n");
  33.   fprintf(fp,"    read\n");
  34.   fprintf(fp,"  enddo\n");
  35.   fprintf(fp,"  if cho='0'\n");
  36.   fprintf(fp,"    return\n");
  37.   fprintf(fp,"  endif\n");
  38.   fprintf(fp,"  if cho='1'\n");
  39.   fprintf(fp,"    ly=.t.\n");
  40.   fprintf(fp,"    do while ly\n      clea\n");
  41.   fprintf(fp,"      do dbfmenu with fname\n");
  42.   fprintf(fp,"      if fname='0'\n");
  43.   fprintf(fp,"        ly=.f.\n");
  44.   fprintf(fp,"      else\n");
  45.   fprintf(fp,"        k1='s'+fname\n");
  46.   fprintf(fp,"        sele 1\n");
  47.   fprintf(fp,"        use %s&fname\n",argv[1]);
  48.   fprintf(fp,"        copy to &k1 stru exte\n");
  49.   fprintf(fp,"        sortfield=space(20)\n");
  50.   fprintf(fp,"        do sor\n");
  51.   fprintf(fp,"        if sortfield<>space(20)\n");
  52.   fprintf(fp,"          dff=space(8)\n");
  53.   fprintf(fp,"          dkk=space(8)\n");
  54.   fprintf(fp,"          do while dkk=space(8).or.dff=space(8)\n");
  55.   fprintf(fp,"            @ 19,0 clear\n");
  56.   fprintf(fp,"            @19,5 say '╟δ╩Σ╚δ┼┼╨≥┐Γ╡─║¼╥σ:' get dkk\n");
  57.   fprintf(fp,"            read\n");
  58.   fprintf(fp,"            @20,5 say '╟δ╩Σ╚╦┼┼╨≥╔·│╔╡─╬─╝■├√ :' get dff\n");
  59.   fprintf(fp,"            read\n");
  60.   fprintf(fp,"            k2=trim(dff)+'.dbf'\n");
  61.   fprintf(fp,"            if file(k2)\n");
  62.   fprintf(fp,"              @24,5 say '**** '+substr(k2,1,12)+'┐Γ╥╤╛¡┤µ╘┌, ╓╪╨┬╩Σ╚δ╬─╝■├√'\n");
  63.   fprintf(fp,"              dff=space(8)\n");
  64.   fprintf(fp,"            endif\n");
  65.   fprintf(fp,"            @24,0 clear\n");
  66.   fprh.tf(fp,"          enddo\n");
  67.   fprintf(fp,"          @24,15 say '╒²╘┌╔·│╔┼┼╨≥┐Γ ... ╟δ╡╚┤² ...'\n");
  68.   fprintf(fp,"          sele 10\n");
  69.   fprintf(fp,"          use sort\n");
  70.   fprintf(fp,"          go bottom\n");
  71.   fprintf(fp,"          append blank\n");
  72.   fprintf(fp,"          go bottom\n");
  73.   fprinsçÿD@@@@@@@@@@Σ╩α╪@┌╩┬▄Φ@ε╥Φ╨@╚╓╓╕▄DRv@@╠αΣ╥▄Φ╠P╠αXD@@@@@@@@@@Σ╩α╪@▄┬┌╩@ε╥Φ╨@╚╠╠╕▄DRv@@╠αΣ╥▄Φ╠P╠αXD@@@@@@@@@@Ωµ╩╕▄DRv@@╠αΣ╥▄Φ╠P╠αXD@@@@@@@@@@µ╩╪╦
  74.   i=0;
  75.    strcpy(name,file);
  76.    tail[0]=tail[1]=tail[2]=tail[3]='\0';
  77.    itoa(i,tail,10);
  78.    strcat(name,tail);
  79.  
  80.    strcat(name,".prg");
  81.     if((fp1=fopen(name,"r"))==NULL)
  82.        { fclose(fp1);
  83.          num=0;
  84.         }
  85.      else
  86.           {  clear_win(0,0,24,79,6,0,black);
  87.          gframe(5,2,11,76,0,0|30);
  88.          print(7,20,6|1,"─·╘°╛¡╔·│╔╥╗╨⌐┤╦─ú┐Θ╡─╬─╝■╕▓╕╟┬≡ú┐(Y/N) ");
  89.          ten=getcc();
  90.          if((ten=='Y')||(ten=='y'))
  91.              {  num=0;
  92.             system("del tt?.prg >zl");
  93.              }
  94.          else
  95.              { i=1;
  96.                        for(;;)
  97.               {  itoa(i,tail,10);
  98.                  strcpy(name,file);
  99.                  itoa(i,tail,10);
  100.                  strcat(name,tail);
  101.                  strcat(name,".prg");
  102.                  num=i;
  103.                  if((fp1=fopen(name,"r"))==NULL)
  104.                  { fclose(fp1);
  105.                    break;
  106.                  }
  107.                  i++;
  108.                 }
  109.                }
  110.  
  111.           }
  112.  }
  113. /*----------------------------------yv field---------------------------*/
  114.   make_t();
  115.   root2=root;
  116.     while(root2!=NULL)
  117.         if(root2->sele=='Y') break;
  118.         else root2=root2->next;
  119.     if(root2->sele=='Y') {
  120.          p=root2->sstr;
  121.          p4=p2=p;    }
  122.     p1=disp_ch(p2);
  123.         print(4,30,6|1,"╟δ╤í╘±╙≥╫¬╗╗╫╓╢╬");
  124.     sele_ch(p2,p1,p4);
  125. /*------------------------------ttt_obfiled------------------------------*/
  126.     make_t();
  127.     root2=root;
  128.     while(root2!=NULL)
  129.         if(root2->sele=='Y') break;
  130.         else root2=root2->next;
  131.     if(root2->sele=='Y') {
  132.          p=root2->sstr;
  133.          p4=p2=p;    }
  134.      /* 0-all1--n*/
  135.     p1=disp_f(p2,1);
  136.         print(4,30,6|1,"╟δ╤í╘±╫¬╗╗╫╓╢╬");
  137.     sele_f(p2,p1,p4,1,0,1);
  138. /*----------------------------statis condition---------------------------*/
  139.     for(;;) {
  140.      make_t();
  141.      print(4,5,6|1,"╟δ╩Σ╚δ╠⌡╝■▒φ┤∩╩╜");
  142.      root2=root;
  143.      while(root2!=NULL)
  144.        if(root2->sele=='Y')
  145.            break;
  146.        else
  147.            root2=root2->next;
  148.      if(root2->sele=='Y') {
  149.         p=root2->sstr;
  150.         p4=p2=p;     }
  151.      clear_win(5,4,9,76,6,0,black);
  152.      p1=disp_f(p2,0);
  153.      if((sele_f(p2,p1,p4,2,0,0))==1)
  154.          break; }
  155. /*----------------------------------------------------------------------*/
  156.   strcpy(name,file);
  157.   itoa(num,tail,10);
  158.   strcat(name,tail);
  159.   w_menu(name);
  160.   strcat(name,".prg");
  161.   if((fp1=fopen(name,"w"))==NULL)
  162.      exit(0);
  163. /*-----gene----*/
  164.   root2=root;
  165.   while(root2!=NULL)
  166.     if(root2->sele=='Y')  break;
  167.     else root2=root2->next;    /*op*/
  168.   root4=root;
  169.   while(root4!=NULL)
  170.      if(root4->sort==1) break;
  171.      else root4=root4->next;
  172.      clear_win(5,8,9,70,6,0,black);
  173.      fprintf(fp1,"set talk off\nset echo off\n set safe off\nclose all\n");
  174.      print(7,20,6|1,"─·╥¬╔·│╔═°┬τ╢α╙├╗º│╠╨≥┬≡ú┐(Y/N): ");
  175.     lan=getcc();
  176.     if((lan=='Y')||(lan=='y'))
  177.     fprintf(fp1,"set excl off\n");
  178.     else
  179.        fprintf(fp1,"set excl on\n");
  180.   fprintf(fp1,"sele 2\nuse %s\\%s\n",root4->path,root4->dbname);
  181.   if(((lan=='Y')||(lan=='y'))&&(root4->serve=='Y'))
  182.   {
  183.     fprintf(fp1,"do while .T.\ntime=0\ndo while .not.flock().and.time<250\n");
  184.     fprintf(fp1,"time=time+1\nenddo\nif time<250\n");
  185.    }
  186.   fprintf(fp1,"copy to tetr.dbf\n");
  187.   if(((lan=='y')||(lan=='Y'))&&(root4->serve=='Y'))
  188.      {
  189.      fprintf(fp1,"unlock\nexit\nelse\nyes=' '\nclear\n@12,10 say \"╬─╝■╥╤▒╗╞Σ╦√╙├╗º,╝╠╨°╝╙╦°┬≡ú┐(Y/N)\" get  yes\n");
  190.      fprintf(fp1,"read\nclear\nif yes='N'.or.yes='n'\n@15,10 say \"╟δ╣²╥╗╗ß╢∙╘┘╙├\" \nwait\n");
  191.      fprintf(fp1,"canc\nendif\nendif\nenddo\n");
  192.      }
  193.   fprintf(fp1,"sele 2\n use tetr excl\n");
  194.   fprintf(fp1,"sele 1\nuse %s\\%s\n",root2->path,root2->dbname);
  195.   fprintf(fp1,"sele 2\n");
  196. /*  if(((lanP=='Y')||(lan=='y'))
  197.   {
  198.     fprintf(fp1,"do while .T.\ntime=0\ndo while .not.flock().and.time<250\n");
  199.     fprintf(fp1,"time=time+1\nenddo\nif time<250\n");
  200.   }*/
  201.   fprintf(fp1,"index on ");
  202.   for(i=0;i<linknum;i++)
  203.     if (i==0)
  204.       fprintf(fp1," %s",linkfield[i]);
  205.     else
  206.       fprintf(fp1,"+%s",linkfield[i]);
  207.   fprintf(fp1," to tt\n");
  208. /*  if((lan=='y')||(lan=='Y'))
  209.   {
  210.   fprintf(fp1,"unlock\nexit\nelse\nyes=' '\nclear\n@12,10 say \"╬─╝■╥╤▒╗╞Σ╦√╙├╗º,╝╠╨°╝╙╦°┬≡ú┐(Y/N)\" get  yes\n");
  211.   fprintf(fp1,"read\nclear\nif yes='N'.or.yes='n'\n@15,10 say \"╟δ╣²╥╗╗ß╢∙╘┘╙├\" \nwait\n");
  212.   fprintf(fp1,"canc\nendif\nendif\nenddo\n");
  213.   }*/
  214.   fprintf(fp1,"sele 1 \nset relation to ");
  215.   for(i=0;i<linknum;i++)
  216.     if (i==0)
  217.       fprintf(fp1," %s",linkfield[i]);
  218.     else
  219.       fprintf(fp1,"+%s",linkfield[i]);
  220.   fprintf(fp1," into  B\n");
  221.   fprintf(fp1,"go top\ndo while .not.eof()\nsele 2\nif eof()\nappe blan \n");
  222.     for(i=0;i<linknum;i++)
  223.        fprintf(fp1,"repl %s with a->%s\n",linkfield[i],linkfield[i]);
  224.      fprintf(fp1,"endif\nsele 1\nskip\nenddo\nsele 2\n");
  225.      fprintf(fp1,"index on ");
  226.     for(i=0;i<linknum;i++)
  227.     if (i==0)
  228.       fprintf(fp1," %s",linkfield[i]);
  229.     else
  230.       fprintf(fp1,"+%s",linkfield[i]);
  231.       fprintf(fp1," to tt1\nsele 1\n");
  232.       fprintf(fp1,"set relation to ");
  233.   for(i=0;i<linknum;i++)
  234.     if (i==0)
  235.       fprintf(fp1," %s",linkfield[i]);
  236.     else
  237.       fprintf(fp1,"+%s",linkfield[i]);
  238.      fprintf(fp1," into B\n");
  239.      fprintf(fp1,"go top\ndo while .not.eof()\nif ");
  240.      p4=root2->sstr;
  241.      while(p4!=NULL)
  242.        if(p4->obj=='Y') break;
  243.        else p4=p4->next;
  244.      p2=root2->sstr;
  245.      while(p2!=NULL)
  246.     if(p2->cla!=0) break;
  247.     else p2=p2->next;
  248.      fprintf(fp1,"%s \nzl=%s\nzl1=%s\n ",condition,p2->field,p4->field);
  249.    fprintf(fp1,"sele 2\nrepl &zl with &zl+zl1\nendif\nsele 1\nskip\nenddo\nclose all\n");
  250.     fprintf(fp1," !c:brow c:tetr.dbf\n!del c:tt.?dx\n");
  251.    fprintf(fp1,"yes='Y'\nclear\n@10,20 say \"─·╥¬▒ú┴⌠┤╦┤╬╫¬╗╗┬≡ú┐(Y/N): \" get yes\nread\n" );
  252.    fprintf(fp1,"if yes='Y'.or.yes='y'\n");
  253.    fprintf(fp1,"!copy c:tetr.dbf %s\\%s.dbf >zl\nendif\n",root4->path,root4->dbname);
  254.      clear_win(5,8,9,70,6,0,black);
  255.      clear_win(13,4,20,75,6,0,black);
  256.      printf("\033[17;20H┤╦═│╝╞╜ß╣√╥¬╣▓╧φ┬≡ú┐(Y/N)");
  257.      k=getcc();
  258.       if((k=='Y')||(k=='y'))
  259.         { print(19,10,6|1,"╩Σ╚δ╣▓╧φ─┐┬╝╝░╬─╝■├√:  ");
  260.           scanf("%s",gsxih);
  261.           fprintf(fp1,"!copy c:tetr.dbf %s >zl",gsxih);
  262.         }
  263.       print(7,20,6|1,"╒²╘┌╔·│╔,╟δ╔╘║≤...");
  264.       reuse=1;
  265.       num++;
  266.       fprintf(fp1,"clear\n");
  267.       fprintf(fp1,"ser=' '\n@ 10,10 say \"┤╦╫¬╗╗╜ß╣√╥¬▒╕╖▌┬≡ú┐(Y/N)\"  get ser\nread\n");
  268.       fprintf(fp1,"if ser='Y'.or.ser='y'\n ser=space(30)\n@12,10 say \"╟δ╩Σ╚δ─┐┬╝╝░╬─╝■├√│╞:\"  get ser\nread\n");
  269.       fprintf(fp1,"!copy c:tetr.dbf  &ser > zl\nendif\n");
  270.       strcat(file,tail);
  271.       fprintf(fp1,"!copy c:tetr.dbf c:%sj.dbf >zl",file);
  272.       fclose(fp1);
  273.       clear_win(5,8,9,70,6,0,black);
  274.       clear_win(13,4,20,75,6,0,black);
  275.       print(7,20,6|1,"╝╠╨°╔·│╔┬≡ú┐(Y/N): ");
  276.       ten=getcc();
  277.       if((ten=='Y')||(ten=='y'))
  278.          goto ss;
  279.       else
  280.       { fp2=fopen("tcolor.txt","w");
  281.         fprintf(fp2,"#gr+#,#B#,#doub#\n");
  282.             fclose(fp2);
  283.           }
  284. /*-----finish----*/
  285.    system("copy c:\cdbag4\tetris.prg >zl");
  286.    system("copy c:\cdbag4\tetris.dbf >zl");
  287.    system("copy c:\cdbag4\tpage.prg >zl");
  288.    system("copy c:\cdbag4\tinput.prg >zl");
  289.    system("copy c:\cdbag4\tcursor.prg >zl");
  290.    system("copy c:\cdbag4\toldcur.prg >zl");
  291.    system("copy c:\cdbag4\tstart.prg >zl");
  292.    system("copy c:\cdbag4\tcolor.dbf >zl");
  293.    system("copy c:\cdbag4\dbstr.dbf >zl");
  294.  
  295. }
  296.  
  297.   select_datbase(maxc)
  298.     int maxc;
  299.        {  clear_win(0,0,24,79,6,0,black);
  300.           print(1,5,0|30,"**%s**","╔·│╔╠¿╒╩╫¬╗╗│╠╨≥");
  301.           print(1,55,0|30,"**ESC->╓╨╢╧═╦│÷**");
  302.           bottom();
  303.           print(4,5,6|1,"╣▓╙╨<%d",0);
  304.           print(4,12,6|1,">╕÷╩²╛▌┐Γ▒╗╤í");
  305.           gframe(5,2,11,78,0,0|30);
  306.           print(11,60,0|30,"PgUp/PgDn");
  307.           gframe(14,2,22,78,1,0|30);
  308.           if(maxc==1)
  309.          print(4,30,6|1,"╟δ╤í╠¿╒╩╫¬╗╗┐Γ");
  310.           else
  311.            print(4,30,6|1
  312.   fprintf(fp,"\n");
  313.   fclose(fp);
  314.   system("copy c:\\cdbag4\\sort.dbf sort.dbf > oztom");
  315.   system("del oztom");
  316. }
  317.