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

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <alloc.h>
  4. #include <dos.h>
  5. #define pr(x)  fprintf(fp,x)
  6. #define  MAXP  10
  7. #define CONT 20
  8. #define CB 14
  9. typedef struct bb{
  10.          char MEAN[21],DB[9],KEY[4][11],COFLAG,COPATH[11]    ;
  11.          int no;
  12.          struct bb *next;
  13.         }BASE;
  14. typedef struct cc {
  15.          char field[128][11],ftype[128];
  16.          int len1[128];
  17.                  int NN;
  18.          int no;
  19.          struct cc *next;
  20.            }CONTENT;
  21. typedef struct ll {
  22.             int  MAR[9][128];
  23.             int  no;
  24.             struct ll *next;
  25.             }LINK;
  26. LINK *flink,*mylink;
  27. BASE *fbase;
  28. CONTENT *fcon;
  29. char *explain="***╠⌡╝■╨▐╕─ ╔·│╔***";
  30. int NB,repeat,I,J,II,JJ,linkflag;
  31. int coflag[11]    ;            /*  database in working partion is coused or not */
  32. char lname[5][31],PATH[31];
  33. /**/char lnamebak[5][3][11];
  34. /*╠⌡╝■╨▐╕─*/
  35. main(int argc,char *argv[])
  36. { FILE *fp;
  37.   int road[30][6],i=0,fs[30],aa,j,ii,jj,p,k,modi_ctc;
  38.   static char dname[30][20];
  39.   char buff[60];
  40.   BASE *mybase;
  41.   CONTENT *mycon;
  42. /*  LINK *mylink;*/
  43.   if(argc<2)
  44.     return;
  45.   strcpy(PATH,argv[1]);
  46.   i=0;
  47.   if ((fp = fopen("creat\\msub.txt", "r"))!=NULL)
  48.     {
  49.        fscanf(fp,"%d\n",&i)    ;
  50.        for(p=0; p<i; p++)
  51.        fscanf(fp,"%s",dname[p])    ;
  52.     }
  53.   getbase();
  54. /*  getcontent(argv[1]);*/
  55.   modi_ctc=i;
  56.   for(;;)
  57.   {
  58.      clear_win(0,0,24,79,0x70);
  59.      clear_win(8,22,14,62,0);
  60.      clear_win(7,20,13,60,30);
  61.      color_puts("─· ╥╤ ╔· │╔ ┴╦    ╕÷ ▓┘ ╫≈ ─ú ┐Θ",30,8,24);
  62.      cursor(8,39);
  63.      printf("%d",modi_ctc);
  64.      color_puts("╟δ ╩Σ ╚δ ─· ╜½ ╨▐ ╕─ ╔· │╔ ─ú ┐Θ",30,9,24);
  65.      color_puts("╡─ ╨≥ ║┼ (0 ╬¬ ═╦ │÷,   ┤≤ ╙┌  ",30,10,24);
  66.      printf("%d",modi_ctc);
  67.      color_puts("╘≥ ╠φ ╝╙ ╔· │╔,╖± ╘≥,╨▐ ╕─ ╔· │╔",30,11,24);
  68.      cursor(12,40);
  69.      scanf("%d",&i);
  70.      if (i==0) break;
  71.      if (i>modi_ctc) modi_ctc++;
  72.      i=(i>modi_ctc)?(modi_ctc-1):i-1;
  73.   fp=fopen("meno1.txt","w");
  74.   fclose(fp);
  75.   fp=fopen("meno2.txt","w");
  76.   fclose(fp);
  77.   if((aa=getroad(argv[1],road[i],i))!=0)
  78.     {
  79.        if(aa==1)
  80.        {/* j=0;
  81.      mybase=fbase;
  82.      while(mybase->no!=(road[i][0]-1))
  83.         mybase=mybase->next;
  84.      while (mybase->MEAN[j]!='\0')
  85.      dname[i][j]=mybase->MEAN[j++];
  86.      dname[i][j]='\0';*/
  87.      clear_win(15,36,19,72,0)    ;
  88.      clear_win(14,34,18,70,0|53)    ;
  89.      color_puts("╢¿╥σ┴¼╜╙┐Γ╡─╩╢▒≡├√(╫ε╢α20╕÷╫╓╖√): ",0|53,15,36)    ;
  90.      color_puts("                         ",0|53,17,40)    ;
  91.      cursor( 17, 43 )    ;
  92.      scanf("%s",dname[i]);
  93.        }
  94.        else
  95.        deflink(road[i],dname[i]);
  96.      flink=(LINK*)malloc(sizeof(LINK));
  97.      flink->next=NULL;
  98.      flink->no=i;
  99.      mylink=flink;
  100.        for(ii=0;ii<9;ii++)
  101.        for(jj=0;jj<128;jj++)
  102.          mylink->MAR[ii][jj]=0;
  103.        sele_disp(road[i],i);   /******725***/
  104.        getcondition(&aa);
  105.        if(aa!=0)
  106.      {
  107.        if(aa==1) get_dc(road[i]);
  108.        if(aa==2) get_fc(road[i]);
  109.        fs[i]=aa;
  110.       }
  111.        cr_sub4(road[i],i,fs[i],PATH);
  112.        i++;
  113.        free(flink);
  114.     mycon=fcon;
  115.     while (fcon!=NULL)
  116.           {
  117.           fcon=fcon->next;
  118.           mycon->next=NULL;
  119.           free(mycon);
  120.           mycon=fcon;
  121.           }
  122.      }
  123.   else break;
  124.   }
  125.   i=modi_ctc;
  126.   system("cls");
  127.   cursor(12,20);
  128.   printf("╒²╘┌╔·│╔╠⌡╝■╨▐╕─│╠╨≥,╟δ╔╘║≥!");
  129.   cr_sub41(dname,i);
  130.  
  131.   fp = fopen("creat\\msub.txt","w")    ;
  132.   fprintf(fp,"%d\n",i)    ;
  133.   for(k=0; k<i; k++)
  134.     fprintf(fp,"%s\n",dname[k])    ;
  135.   fclose(fp)    ;
  136.  
  137.  }
  138.  
  139. /* ╔·│╔╠⌡╝■╨▐╕─│╠╨≥*/
  140. cr_sub4(int *s,int i,int fs,char *aarr)
  141. {FILE *fp,*dp,*tp;
  142.  char name[15],buff[130],tname[5];
  143.  int j,k,l,ii,ll,jj,kk,la,lb,lla,llb,row,col,m,n;
  144.  BASE *mybase;
  145.  dp=fopen("creat\\meno2.txt","r");
  146.  tp=fopen("creat\\meno1.txt","r");
  147.   if (i+1<10) {tname[0]='1'+i;tname[1]='\0';}
  148.   if (i+1>9)  {tname[0]='0'+(i+1)/10; tname[1]='0'+(i+1)%10; tname[2]='\0';}
  149.   strcpy(name,"msub"); strcat(name,tname); strcat(name,".prg");
  150.    fp=fopen(name,"w");
  151.    j=0;
  152.    pr("clear\n");
  153.     n=s[0]-1;
  154.     mybase=fbase;
  155.     while(mybase->no!=n)
  156.     mybase=mybase->next;
  157.     fprintf(fp,"set procedu to proced\nsele 10\nuse %s%s exclusive\n",aarr,"ndx");
  158.     if( mybase->COFLAG == 'Y' || mybase->COFLAG == 'y' )
  159.     {
  160.     fprintf(fp,"sele A\nuse %s%s\n",mybase->COPATH,mybase->DB)    ;
  161.     coflag[1] = 1    ;
  162.     }
  163.     else
  164.     {
  165.     fprintf(fp,"sele A\nuse %s%s exclusive\n",aarr,mybase->DB)    ;
  166.     coflag[1] = 0    ;
  167.     }
  168.     j=1;
  169.     while(s[j]!=0)
  170.      {
  171.        mybase=fbase;
  172.        while(mybase->no!=(s[j]-1))
  173.      mybase=mybase->next;
  174.        fprintf(fp,"sele 10\ngo top\n");
  175. /*       fprintf(fp,"loca for trim(╦≈╥²╫╓╢╬)='%s'.and.trim(┐Γ├√)='%s'\n",lname[j-1],mybase->DB);
  176.        fprintf(fp,"nf=trim(╦≈╥²╬─╝■)\n");
  177.        fprintf(fp,"select %c\n",j+1+64);*/
  178.        if( mybase->COFLAG != 'Y' && mybase->COFLAG != 'y')
  179.       {
  180.      fprintf(fp,"sele 10\n use %sndx exclusive\ngo top\n",aarr);
  181.        fprintf(fp,"loca for trim(╦≈╥²╫╓╢╬)='%s'.and.trim(┐Γ├√)='%s'\n",lname[j-1],mybase->DB);
  182.        fprintf(fp,"nf=trim(╦≈╥²╬─╝■)\n");
  183.        fprintf(fp,"select %c\n",j+65);
  184.    coflag[j+1]=0    ;
  185.        fprintf(fp,"use %s%s inde %s&nf exclusive\naflag%c=1\n",aarr,mybase->DB,aarr,s[j]+64)    ;
  186.       }
  187.        else
  188.       {
  189.        fprintf(fp,"sele 10\n use %sndx \ngo top\n",mybase->COPATH);
  190.        fprintf(fp,"loca for trim(╦≈╥²╫╓╢╬)='%s'.and.trim(┐Γ├√)='%s'\n",lname[j-1],mybase->DB);
  191.        fprintf(fp,"nf=trim(╦≈╥²╬─╝■)\n");
  192.        fprintf(fp,"select %c\n",j+65);
  193.  
  194.         coflag[j+1] = 1    ;
  195.         fprintf(fp,"use %s%s inde %s&nf\naflag%c=1\n",mybase->COPATH,mybase->DB,mybase->COPATH,s[j]+64)    ;
  196.         fprintf(fp,"sele 10\nuse %sndx exclusive\n",aarr)    ;
  197.       }
  198.        if (linkflag==0)
  199.       fprintf(fp,"sele A\nset rela to %s into %c\n",lname[j-1],j+65);
  200.        else
  201.       fprintf(fp,"sele %c\nset rela to %s into %c addi\n",j+64,lname[j-1],j+65);
  202.        j++;
  203.      }
  204.    if(fs==1)
  205.      {
  206.     while(fgets(buff,120,dp))
  207.       { if(buff[1]=='#')  break;
  208.         pr("clear\nselect 1\ngo top\ndo while .not. eof()\n");
  209.         l=0;
  210.         clear_win(20,3,22,72,0)    ;
  211.         clear_win(19,1,21,70,31)    ;
  212. /***        color_puts(" please assure ", 45, 17, 30)    ;****/
  213.         color_puts("   ╟δ╚╖╚╧    ", 45, 17, 30)    ;
  214.         line_edit(20,2,31,buff,60)    ;
  215.         while(buff[l]!='\n') l++;
  216.         buff[l]='\0';
  217.        pr("select 1\n");
  218.        fprintf(fp,"if  %s\n",buff);
  219.        pr("w=.t.\n");
  220.        pr("do while w\nclear\nset color to w+/B\n");
  221.        fprintf(fp,"@1,5 say \"╕∙╛▌╠⌡╝■ :  %s\"\nset color to W+/B\n",buff);
  222.        min_data(j,i,fp,s,aarr);
  223.       }
  224.     }
  225.      if(fs==2)
  226.      {
  227.         while(fgets(buff,120,tp))
  228.          { if(buff[1]=='#') break;
  229.            mcon(fp,buff);
  230.            pr("clear\n");
  231.            pr("select 1\ndo while .not. eof()\n");
  232.            pr("select 1\n");
  233.            fprintf(fp,"if  &condition\n");
  234.            pr("w=.t.\ndo while w\nclear\nset color to W+/B\n");
  235.            pr("@1,2 say condition\n");
  236.            min_data(j,i,fp,s,aarr);
  237.          }
  238.        }
  239.   if(fs==3)
  240.   {
  241.     j=0;
  242.     while(s[j]!=0)
  243.      {
  244.        mybase=fbase;
  245.        while(mybase->no!=(s[j]-1))
  246.      mybase=mybase->next;
  247.        fprintf(fp,"sele %c\ncopy to s%s stru exte\n",j+65,mybase->DB);
  248.        j++;
  249.      }
  250.     pr("sele A\nset color to w+/B\n@0,0 say '╚╬╥Γ╠⌡╝■╨▐╕─'\n");
  251.     pr("condition=''\n");
  252.     pr("cb=1\n");
  253.     pr("cs=.t.\n");
  254.     pr("do while cs\n");
  255.     rcon(i,j,s,fp);
  256.     pr("do rcon with renu,cb,condition,cs\n");
  257.     pr("enddo\n");
  258.     pr("clear\n");
  259.     pr("select 1\ngo top\ndo while .not. eof()\n");
  260.     pr("select 1\n");
  261.     fprintf(fp,"if  &condition\n");
  262.     pr("w=.t.\ndo while w\nclear\nset color to W+/B\n");
  263.     pr("@1, 2 say condition\n");
  264.     min_data(j,i,fp,s,aarr);
  265.     }
  266.     fprintf(fp,"sele 10\nuse %sndx inde %sndx exclusive\n",aarr,aarr);
  267.     j=0;
  268.     while(s[j]!=0)
  269.      {
  270.        mybase=fbase;
  271.        while(mybase->no!=(s[j]-1))
  272.      mybase=mybase->next;
  273.        fprintf(fp,"sele 10\ngo top\n");
  274.        fprintf(fp,"loca for trim(┐Γ├√)='%s'\n",mybase->DB);
  275.        fprintf(fp,"do while .not.eof()\nnf=trim(╦≈╥²╬─╝■)\n");
  276.        fprintf(fp,"select %c\n",j+1+64);
  277.        if( mybase->COFLAG == 'Y' || mybase->COFLAG == 'y')
  278.       fprintf(fp,"use %s%s inde %s&nf exclusive\n",mybase->COPATH,mybase->DB,mybase->COPATH)    ;
  279.        else
  280.       fprintf(fp,"use %s%s inde &nf exclusive\n",aarr,mybase->DB)    ;
  281.        pr("reinde\nuse\nsele 10\ncontinue\nenddo\n")    ;
  282.        j++;
  283.      }
  284.   pr("return\n");
  285.   fclose(fp);
  286.   fclose(dp);
  287.   fclose(tp);
  288.  }
  289.  
  290.  
  291. cr_sub41(char dname[][20],int i)
  292. {FILE *fp;
  293.  char name[15],buff[130];
  294.  int k,row,col;
  295.  fp=fopen("modify.prg","w");
  296.  pr("set talk off\ndo while .t.\nset color to /w\nclear\nset color to w+/B\n");
  297.  pr("@0,0 say '***╠⌡╝■╨▐╕─***'\n");
  298.  pr("@2,26 say '─·┐╔╢╘╧┬┴╨┐Γ╜°╨╨▓┘╫≈'\n");
  299.  pr("@3,26 say '~~~~~~~~~~~~~~~~~~~~'\nset color to W/B\n");
  300.  fprintf(fp,"set color to w+/n\n@6,15 clea to %d,65\n",6+i/2+i%2+1);
  301.  fprintf(fp,"set color to w+/b\n@5,13 clea to %d,63\n",5+i/2+i%2+1);
  302.  row=6;col=15;
  303.  for(k=0;k<i;k++)
  304.  { fprintf(fp,"@%d,%d say '%d. %s'\n",row,col,k+1,dname[k]);
  305.    if(col==45) {col=15;row++;}
  306.    else col+=30;
  307.  }
  308.  for(k=1;k<=6;k++)
  309.  fprintf(fp,"select %d\nuse\n",k);
  310.  pr("choice=space(2)\nset color to w+/b\n");
  311.  pr("@22,10 say '╟δ╩Σ╚δ─·╡─╤í╘±,0▒φ╩╛═╦│÷  :      ' get choice\n read\n");
  312.  pr("set color to W+/N\nif trim(choice)='0'\n");
  313.  pr("return\nendif\n");
  314.  pr("nn='msub'+trim(choice)+'.prg'\n");
  315.  pr("if FILE (nn)\n");
  316.  pr("do msub&choice\n");
  317.  pr("endif\n");
  318.  pr("enddo\n");
  319.  fclose(fp);
  320.  }
  321.  
  322.  
  323. /*---------------- This is a line editer -----------------------*/
  324. /*        row,col     posite the starting cursor         */
  325. /*        color       denote the color of the        */
  326. /*                  blackbord and the  character    */
  327. /*        buff        line-editer's interal denoting    */
  328. /*--------------------------------------------------------------*/
  329. line_edit(int row, int col, int color, char *buff, int len)
  330. {
  331.     int in_number=0, ins=1, i, j, flag=0    ;
  332.     char *str    ;
  333.     union {
  334.         int i;
  335.         char ch[2];
  336.           }key;
  337.  
  338.     len -= 2    ;
  339.     color_puts(buff, color, row, col )    ;
  340.     while(1)
  341.       {
  342.         cursor( row, col+in_number )    ;
  343.         key.i = bioskey(0)    ;
  344.         switch(key.i)
  345.           {
  346.             case 15104:    /*    F1    */
  347.                 break    ;
  348.  
  349.             case 19200:    /*    left arrow    */
  350.                 if(in_number)
  351.                     in_number=confirm(buff,in_number-1);
  352.                 cursor( row, col+in_number )    ;
  353.                 break    ;
  354.  
  355.             case 19712:    /*    right arrow    */
  356.                 if( buff[in_number]=='\0' )
  357.                     buff[in_number]=' '    ;
  358.                 if((unsigned)buff[in_number]>128 && (unsigned)buff[in_number]>128)
  359.                     in_number+=2    ;
  360.                 else
  361.                     in_number++    ;
  362.                 if(in_number>len)
  363.                     in_number=0    ;
  364.                 break    ;
  365.  
  366.             case 29440:    /*    Ctrl_left    */
  367.                 in_number=confirm(buff,in_number-8)    ;
  368.                 if( in_number <0 )
  369.                     in_number=0    ;
  370.                 break    ;
  371.  
  372.             case 29696:    /*    ctrl_right    */
  373.                 in_number = confirm(buff, in_number+8)    ;
  374.                 if( in_number>(i=strlen(buff)))
  375.                     in_number = i    ;
  376.                 break    ;
  377.  
  378.             case 18176:    /*    Home    */
  379.                 in_number=0    ;
  380.                 cursor( row, col )    ;
  381.                 break    ;
  382.  
  383.             case 20224:    /*    End    */
  384.                 in_number=strlen(buff)    ;
  385.                 cursor( row, col+in_number )    ;
  386.                 break    ;
  387.  
  388.             case 21248:     /*    Del    */
  389.                 if( in_number==strlen(buff) )
  390. /*                    printf("\007");*/    ;
  391.                 else
  392.                   {
  393.                     if( (unsigned)buff[in_number]>128 && (unsigned)buff[in_number]>128 )
  394.                       {
  395.                         for( i=in_number+2,j=strlen(buff); i<=j; i++ )
  396.                             buff[i-2]=buff[i]    ;
  397.                         color_puts( "  ", color, row, col+j-2 )    ;
  398.                       }
  399.                     else
  400.                       {
  401.                         for( i=in_number+1,j=strlen(buff); i<=j; i++)
  402.                             buff[i-1] = buff[i]    ;
  403.                         color_puts( " ", color, row, col+j-1 )    ;
  404.                       }
  405.                     str = &buff[in_number]    ;
  406.                     color_puts(str, color, row, col+in_number)    ;
  407.                   }
  408.                 break    ;
  409.  
  410.             case 3592:    /*    Backspace    */
  411.                 if(in_number)
  412.                   {
  413.                     if( (unsigned)buff[in_number-1]>128 && (unsigned)buff[in_number-2]>128 && in_number>1 )
  414.                       {
  415.                         for( i=in_number,j=strlen(buff); i<=j; i++)
  416.                             buff[i-2] = buff[i]    ;
  417.                         in_number-=2    ;
  418.                         color_puts( "  ", color, row, col+j-2 )    ;
  419.                       }
  420.                     else
  421.                       {
  422.                         for( i=in_number,j=strlen(buff); i<=j; i++)
  423.                             buff[i-1] = buff[i]    ;
  424.                         in_number--    ;
  425.                         color_puts( " ", color, row, col+j-1 )    ;
  426.                       }
  427.                     str = &buff[in_number]    ;
  428.                     color_puts( str, color, row, col+in_number )    ;
  429.                   }
  430.                 else
  431.                     /*  printf("\007"); */    ;
  432.                 break    ;
  433.  
  434.             case 20992:    /*    Ins    */
  435.                 ins=(ins?0:1)    ;
  436.                 break    ;
  437.  
  438.             case 7181:    /*    Enter    */
  439.                 for( i=strlen(buff)-1; buff[i]==' '&&i>=0; i--);
  440.                 buff[i+1]='\0'    ;
  441.                 return    ;
  442.  
  443.             default:
  444.                 if( ins )
  445.                   {
  446.  
  447.                     if( strlen(buff)>=len || key.ch[0]==0)
  448.                     /*    printf("\007")    ;    */;
  449.                     else
  450.                       {
  451.                         for( i=strlen(buff); i>in_number; i--)
  452.                             buff[i] = buff[i-1]    ;
  453.                         buff[in_number] = key.ch[0]    ;
  454.                         if( (unsigned)key.ch[0]>128 )
  455.                            if( flag==0 )    /*    the forehalf of chinese    */
  456.                              {
  457.                             flag++    ;
  458.                             in_number++    ;
  459.                              }
  460.                            else
  461.                              {
  462.                             flag--    ;
  463.                             str = &buff[in_number-1]    ;
  464.                             color_puts( str, color, row, col-1+in_number++ )    ;
  465.                              }
  466.                         else
  467.                           {
  468.                             str = &buff[in_number]    ;
  469.                             color_puts( str, color,row, col+in_number++ )    ;
  470.                           }
  471.                       }
  472.                   }
  473.                 else
  474.                   {
  475.                     if( in_number>=len || key.ch[0]==0 )
  476.                     /*    printf("\007")    ;    */;
  477.                     else
  478.                       {
  479.                         buff[in_number] = key.ch[0]    ;
  480.                         str = &buff[in_number]    ;
  481.                         color_puts( str, color, row, col+in_number++ )    ;
  482.                       }
  483.                   }
  484.  
  485.          }
  486.     }
  487. }
  488.  
  489.  
  490. /*-----  if the charater is chinese , and then the cursor must be in the first position----*/
  491. confirm(char *s, int col)
  492. {
  493.     int i    ;
  494.     if( (unsigned)s[col]<128)
  495.         return(col)    ;
  496.     for(i=col; (unsigned)s[i]>128&&i>0; i--)    ;
  497.     if((col-i)%2!=0)
  498.         return(col)    ;
  499.     else
  500.         return(col-1)    ;
  501. }
  502.  
  503.