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);                   break;
  105.                  }
  106.                  i++;
  107.                 }
  108.                }
  109.  
  110.           }
  111.  }
  112. /*----------------------------------yv field---------------------------*/
  113.   make_t();
  114.   root2=root;
  115.     while(root2!=NULL)
  116.         if(root2->sele=='Y') break;
  117.         else root2=root2->next;
  118.     if(root2->sele=='Y') {
  119.          p=root2->sstr;
  120.          p4=p2=p;    }
  121.     p1=disp_ch(p2);
  122.         print(4,30,6|1,"╟δ╤í╘±╙≥╫¬╗╗╫╓╢╬");
  123.     sele_ch(p2,p1,p4);
  124. /*------------------------------ttt_obfiled------------------------------*/
  125.     make_t();
  126.     root2=root;
  127.     while(root2!=NULL)
  128.         if(root2->sele=='Y') break;
  129.         else root2=root2->next;
  130.     if(root2->sele=='Y') {
  131.          p=root2->sstr;
  132.          p4=p2=p;    }
  133.      /* 0-all1--n*/
  134.     p1=disp_f(p2,1);
  135.         print(4,30,6|1,"╟δ╤í╘±╫¬╗╗╫╓╢╬");
  136.     sele_f(p2,p1,p4,1,0,1);
  137. /*----------------------------statis condition---------------------------*/
  138.     for(;;) {
  139.      make_t();
  140.      print(4,5,6|1,"╟δ╩Σ╚δ╠⌡╝■▒φ┤∩╩╜");
  141.      root2=root;
  142.      while(root2!=NULL)
  143.        if(root2->sele=='Y')
  144.            break;
  145.        else
  146.            root2=root2->next;
  147.      if(root2->sele=='Y') {
  148.         p=root2->sstr;
  149.         p4=p2=p;     }
  150.      clear_win(5,4,9,76,6,0,black);
  151.      p1=disp_f(p2,0);
  152.      if((sele_f(p2,p1,p4,2,0,0))==1)
  153.          break; }
  154. /*----------------------------------------------------------------------*/
  155.   strcpy(name,file);
  156.   itoa(num,tail,10);
  157.   strcat(name,tail);
  158.   w_menu(name);
  159.   strcat(name,".prg");  if((fp1=fopen(name,"w"))==NULL)
  160.      exit(0);
  161. /*-----gene----*/
  162.   root2=root;
  163.   while(root2!=NULL)
  164.     if(root2->sele=='Y')  break;
  165.     else root2=root2->next;    /*op*/
  166.   root4=root;
  167.   while(root4!=NULL)
  168.      if(root4->sort==1) break;
  169.      else root4=root4->next;
  170.      clear_win(5,8,9,70,6,0,black);
  171.      fprintf(fp1,"set talk off\nset echo off\n set safe off\nclose all\n");
  172.      print(7,20,6|1,"─·╥¬╔·│╔═°┬τ╢α╙├╗º│╠╨≥┬≡ú┐(Y/N): ");
  173.     lan=getcc();
  174.     if((lan=='Y')||(lan=='y'))
  175.     fprintf(fp1,"set excl off\n");
  176.     else
  177.        fprintf(fp1,"set excl on\n");
  178.   fprintf(fp1,"sele 2\nuse %s\\%s\n",root4->path,root4->dbname);
  179.   if(((lan=='Y')||(lan=='y'))&&(root4->serve=='Y'))
  180.   {
  181.     fprintf(fp1,"do while .T.\ntime=0\ndo while .not.flock().and.time<250\n");
  182.     fprintf(fp1,"time=time+1\nenddo\nif time<250\n");
  183.    }
  184.   fprintf(fp1,"copy to tetr.dbf\n");
  185.   if(((lan=='y')||(lan=='Y'))&&(root4->serve=='Y'))
  186.      {     fprintf(fp1,"unlock\nexit\nelse\nyes=' '\nclear\n@12,10 say \"╬─╝■╥╤▒╗╞Σ╦√╙├╗º,╝╠╨°╝╙╦°┬≡ú┐(Y/N)\" get  yes\n");
  187.      fprintf(fp1,"read\nclear\nif yes='N'.or.yes='n'\n@15,10 say \"╟δ╣²╥╗╗ß╢∙╘┘╙├\" \nwait\n");
  188.      fprintf(fp1,"canc\nendif\nendif\nenddo\n");
  189.      }
  190.   fprintf(fp1,"sele 2\n use tetr excl\n");
  191.   fprintf(fp1,"sele 1\nuse %s\\%s\n",root2->path,root2->dbname);
  192.   fprintf(fp1,"sele 2\n");
  193. /*  if(((lanP=='Y')||(lan=='y'))
  194.   {
  195.     fprintf(fp1,"do while .T.\ntime=0\ndo while .not.flock().and.time<250\n");
  196.     fprintf(fp1,"time=time+1\nenddo\nif time<250\n");
  197.   }*/
  198.   fprintf(fp1,"index on ");
  199.   for(i=0;i<linknum;i++)
  200.     if (i==0)
  201.       fprintf(fp1," %s",linkfield[i]);
  202.     else
  203.       fprintf(fp1,"+%s",linkfield[i]);
  204.   fprintf(fp1," to tt\n");
  205. /*  if((lan=='y')||(lan=='Y'))
  206.   {
  207.   fprintf(fp1,"unlock\nexit\nelse\nyes=' '\nclear\n@12,10 say \"╬─╝■╥╤▒╗╞Σ╦√╙├╗º,╝╠╨°╝╙╦°┬≡ú┐(Y/N)\" get  yes\n");
  208.   fprintf(fp1,"read\nclear\nif yes='N'.or.yes='n'\n@15,10 say \"╟δ╣²╥╗╗ß╢∙╘┘╙├\" \nwait\n");
  209.   fprintf(fp1,"canc\nendif\nendif\nenddo\n");
  210.   }*/
  211.   fprintf(fp1,"sele 1 \nset relation to ");
  212.   for(i=0;i<linknum;i++)
  213.     if (i==0)
  214.       fprintf(fp1," %s",linkfield[i]);
  215.     else
  216.       fprintf(fp1,"+%s",linkfield[i]);
  217.   fprintf(fp1," into  B\n");
  218.   fprintf(fp1,"go top\ndo while .not.eof()\nsele 2\nif eof()\nappe blan \n");
  219.     for(i=0;i<linknum;i++)
  220.        fprintf(fp1,"repl %s with a->%s\n",linkfield[i],linkfield[i]);
  221.      fprintf(fp1,"endif\nsele 1\nskip\nenddo\nsele 2\n");
  222.      fprintf(fp1,"index on ");
  223.     for(i=0;i<linknum;i++)
  224.     if (i==0)
  225.       fprintf(fp1," %s",linkfield[i]);
  226.     else
  227.       fprintf(fp1,"+%s",linkfield[i]);
  228.       fprintf(fp1," to tt1\nsele 1\n");
  229.       fprintf(fp1,"set relation to ");
  230.   for(i=0;i<linknum;i++)
  231.     if (i==0)
  232.       fprintf(fp1," %s",linkfield[i]);
  233.     else
  234.       fprintf(fp1,"+%s",linkfield[i]);
  235.      fprintf(fp1," into B\n");
  236.      fprintf(fp1,"go top\ndo while .not.eof()\nif ");
  237.      p4=root2->sstr;
  238.      while(p4!=NULL)
  239.        if(p4->obj=='Y') break;
  240.        else p4=p4->next;
  241.      p2=root2->sstr;
  242.      while(p2!=NULL)
  243.     if(p2->cla!=0) break;
  244.     else p2=p2->next;
  245.      fprintf(fp1,"%s \nzl=%s\nzl1=%s\n ",condition,p2->field,p4->field);
  246.    fprintf(fp1,"sele 2\nrepl &zl with &zl+zl1\nendif\nsele 1\nskip\nenddo\nclose all\n");
  247.     fprintf(fp1," !c:brow c:tetr.dbf\n!del c:tt.?dx\n");
  248.    fprintf(fp1,"yes='Y'\nclear\n@10,20 say \"─·╥¬▒ú┴⌠┤╦┤╬╫¬╗╗┬≡ú┐(Y/N): \" get yes\nread\n" );
  249.    fprintf(fp1,"if yes='Y'.or.yes='y'\n");
  250.    fprintf(fp1,"!copy c:tetr.dbf %s\\%s.dbf >zl\nendif\n",root4->path,root4->dbname);
  251.      clear_win(5,8,9,70,6,0,black);
  252.      clear_win(13,4,20,75,6,0,black);
  253.      printf("\033[17;20H┤╦═│╝╞╜ß╣√╥¬╣▓╧φ┬≡ú┐(Y/N)");
  254.      k=getcc();
  255.       if((k=='Y')||(k=='y'))
  256.         { print(19,10,6|1,"╩Σ╚δ╣▓╧φ─┐┬╝╝░╬─╝■├√:  ");
  257.           scanf("%s",gsxih);
  258.           fprintf(fp1,"!copy c:tetr.dbf %s >zl",gsxih);
  259.         }
  260.       print(7,20,6|1,"╒²╘┌╔·│╔,╟δ╔╘║≤...");
  261.       reuse=1;
  262.       num++;
  263.       fprintf(fp1,"clear\n");
  264.       fprintf(fp1,"ser=' '\n@ 10,10 say \"┤╦╫¬╗╗╜ß╣√╥¬▒╕╖▌┬≡ú┐(Y/N)\"  get ser\nread\n");
  265.       fprintf(fp1,"if ser='Y'.or.ser='y'\n ser=space(30)\n@12,10 say \"╟δ╩Σ╚δ─┐┬╝╝░╬─╝■├√│╞:\"  get ser\nread\n");
  266.       fprintf(fp1,"!copy c:tetr.dbf  &ser > zl\nendif\n");
  267.       strcat(file,tail);
  268.       fprintf(fp1,"!copy c:tetr.dbf c:%sj.dbf >zl",file);
  269.       fclose(fp1);
  270.       clear_win(5,8,9,70,6,0,black);
  271.       clear_win(13,4,20,75,6,0,black);
  272.       print(7,20,6|1,"╝╠╨°╔·│╔┬≡ú┐(Y/N): ");
  273.       ten=getcc();
  274.       if((ten=='Y')||(ten=='y'))
  275.          goto ss;
  276.       else
  277.       { fp2=fopen("tcolor.txt","w");
  278.         fprintf(fp2,"#gr+#,#B#,#doub#\n");
  279.             fclose(fp2);
  280.           }
  281. /*-----finish----*/
  282.    system("copy c:\cdbag4\tetris.prg >zl");
  283.    system("copy c:\cdbag4\tetris.dbf >zl");
  284.    system("copy c:\cdbag4\tpage.prg >zl");   system("copy c:\cdbag4\tinput.prg >zl");
  285.    system("copy c:\cdbag4\tcursor.prg >zl");
  286.    system("copy c:\cdbag4\toldcur.prg >zl");
  287.    system("copy c:\cdbag4\tstart.prg >zl");
  288.    system("copy c:\cdbag4\tcolor.dbf >zl");
  289.    system("copy c:\cdbag4\dbstr.dbf >zl");
  290.  
  291. }
  292.  
  293.   select_datbase(maxc)
  294.     int maxc;
  295.        {  clear_win(0,0,24,79,6,0,black);
  296.           print(1,5,0|30,"**%s**","╔·│╔╠¿╒╩╫¬╗╗│╠╨≥");
  297.           print(1,55,0|30,"**ESC->╓╨╢╧═╦│÷**");
  298.           bottom();
  299.           print(4,5,6|1,"╣▓╙╨<%d",0);
  300.           print(4,12,6|1,">╕÷╩²╛▌┐Γ▒╗╤í");
  301.           gframe(5,2,11,78,0,0|30);
  302.           print(11,60,0|30,"PgUp/PgDn");
  303.           gframe(14,2,22,78,1,0|30);
  304.           if(maxc==1)
  305.          print(4,30,6|1,"╟δ╤í╠¿╒╩╫¬╗╗┐Γ");
  306.           else
  307.            print(4,30,6|1
  308.   fprintf(fp,"\n");
  309.   fclose(fp);
  310.   system("copy c:\\cdbag4\\sort.dbf sort.dbf > oztom");
  311.   system("del oztom");
  312. }
  313.