home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <alloc.h>
- #include <dos.h>
- #define pr(x) fprintf(fp,x)
- #define MAXP 10
- #define CONT 20
- #define CB 14
- typedef struct bb{
- char MEAN[21],DB[9],KEY[4][11],COFLAG,COPATH[11] ;
- int no;
- struct bb *next;
- }BASE;
- typedef struct cc {
- char field[128][11],ftype[128];
- int len1[128];
- int NN;
- int no;
- struct cc *next;
- }CONTENT;
- typedef struct ll {
- int MAR[9][128];
- int no;
- struct ll *next;
- }LINK;
- LINK *flink,*mylink;
- BASE *fbase;
- CONTENT *fcon;
- char *explain="***╠⌡╝■╨▐╕─ ╔·│╔***";
- int NB,repeat,I,J,II,JJ,linkflag;
- int coflag[11] ; /* database in working partion is coused or not */
- char lname[5][31],PATH[31];
- /**/char lnamebak[5][3][11];
- /*╠⌡╝■╨▐╕─*/
- main(int argc,char *argv[])
- { FILE *fp;
- int road[30][6],i=0,fs[30],aa,j,ii,jj,p,k,modi_ctc;
- static char dname[30][20];
- char buff[60];
- BASE *mybase;
- CONTENT *mycon;
- /* LINK *mylink;*/
- if(argc<2)
- return;
- strcpy(PATH,argv[1]);
- i=0;
- if ((fp = fopen("creat\\msub.txt", "r"))!=NULL)
- {
- fscanf(fp,"%d\n",&i) ;
- for(p=0; p<i; p++)
- fscanf(fp,"%s",dname[p]) ;
- }
- getbase();
- /* getcontent(argv[1]);*/
- modi_ctc=i;
- for(;;)
- {
- clear_win(0,0,24,79,0x70);
- clear_win(8,22,14,62,0);
- clear_win(7,20,13,60,30);
- color_puts("─· ╥╤ ╔· │╔ ┴╦ ╕÷ ▓┘ ╫≈ ─ú ┐Θ",30,8,24);
- cursor(8,39);
- printf("%d",modi_ctc);
- color_puts("╟δ ╩Σ ╚δ ─· ╜½ ╨▐ ╕─ ╔· │╔ ─ú ┐Θ",30,9,24);
- color_puts("╡─ ╨≥ ║┼ (0 ╬¬ ═╦ │÷, ┤≤ ╙┌ ",30,10,24);
- printf("%d",modi_ctc);
- color_puts("╘≥ ╠φ ╝╙ ╔· │╔,╖± ╘≥,╨▐ ╕─ ╔· │╔",30,11,24);
- cursor(12,40);
- scanf("%d",&i);
- if (i==0) break;
- if (i>modi_ctc) modi_ctc++;
- i=(i>modi_ctc)?(modi_ctc-1):i-1;
- fp=fopen("meno1.txt","w");
- fclose(fp);
- fp=fopen("meno2.txt","w");
- fclose(fp);
- if((aa=getroad(argv[1],road[i],i))!=0)
- {
- if(aa==1)
- {/* j=0;
- mybase=fbase;
- while(mybase->no!=(road[i][0]-1))
- mybase=mybase->next;
- while (mybase->MEAN[j]!='\0')
- dname[i][j]=mybase->MEAN[j++];
- dname[i][j]='\0';*/
- clear_win(15,36,19,72,0) ;
- clear_win(14,34,18,70,0|53) ;
- color_puts("╢¿╥σ┴¼╜╙┐Γ╡─╩╢▒≡├√(╫ε╢α20╕÷╫╓╖√): ",0|53,15,36) ;
- color_puts(" ",0|53,17,40) ;
- cursor( 17, 43 ) ;
- scanf("%s",dname[i]);
- }
- else
- deflink(road[i],dname[i]);
- flink=(LINK*)malloc(sizeof(LINK));
- flink->next=NULL;
- flink->no=i;
- mylink=flink;
- for(ii=0;ii<9;ii++)
- for(jj=0;jj<128;jj++)
- mylink->MAR[ii][jj]=0;
- sele_disp(road[i],i); /******725***/
- getcondition(&aa);
- if(aa!=0)
- {
- if(aa==1) get_dc(road[i]);
- if(aa==2) get_fc(road[i]);
- fs[i]=aa;
- }
- cr_sub4(road[i],i,fs[i],PATH);
- i++;
- free(flink);
- mycon=fcon;
- while (fcon!=NULL)
- {
- fcon=fcon->next;
- mycon->next=NULL;
- free(mycon);
- mycon=fcon;
- }
- }
- else break;
- }
- i=modi_ctc;
- system("cls");
- cursor(12,20);
- printf("╒²╘┌╔·│╔╠⌡╝■╨▐╕─│╠╨≥,╟δ╔╘║≥!");
- cr_sub41(dname,i);
-
- fp = fopen("creat\\msub.txt","w") ;
- fprintf(fp,"%d\n",i) ;
- for(k=0; k<i; k++)
- fprintf(fp,"%s\n",dname[k]) ;
- fclose(fp) ;
-
- }
-
- /* ╔·│╔╠⌡╝■╨▐╕─│╠╨≥*/
- cr_sub4(int *s,int i,int fs,char *aarr)
- {FILE *fp,*dp,*tp;
- char name[15],buff[130],tname[5];
- int j,k,l,ii,ll,jj,kk,la,lb,lla,llb,row,col,m,n;
- BASE *mybase;
- dp=fopen("creat\\meno2.txt","r");
- tp=fopen("creat\\meno1.txt","r");
- if (i+1<10) {tname[0]='1'+i;tname[1]='\0';}
- if (i+1>9) {tname[0]='0'+(i+1)/10; tname[1]='0'+(i+1)%10; tname[2]='\0';}
- strcpy(name,"msub"); strcat(name,tname); strcat(name,".prg");
- fp=fopen(name,"w");
- j=0;
- pr("clear\n");
- n=s[0]-1;
- mybase=fbase;
- while(mybase->no!=n)
- mybase=mybase->next;
- fprintf(fp,"set procedu to proced\nsele 10\nuse %s%s exclusive\n",aarr,"ndx");
- if( mybase->COFLAG == 'Y' || mybase->COFLAG == 'y' )
- {
- fprintf(fp,"sele A\nuse %s%s\n",mybase->COPATH,mybase->DB) ;
- coflag[1] = 1 ;
- }
- else
- {
- fprintf(fp,"sele A\nuse %s%s exclusive\n",aarr,mybase->DB) ;
- coflag[1] = 0 ;
- }
- j=1;
- while(s[j]!=0)
- {
- mybase=fbase;
- while(mybase->no!=(s[j]-1))
- mybase=mybase->next;
- fprintf(fp,"sele 10\ngo top\n");
- /* fprintf(fp,"loca for trim(╦≈╥²╫╓╢╬)='%s'.and.trim(┐Γ├√)='%s'\n",lname[j-1],mybase->DB);
- fprintf(fp,"nf=trim(╦≈╥²╬─╝■)\n");
- fprintf(fp,"select %c\n",j+1+64);*/
- if( mybase->COFLAG != 'Y' && mybase->COFLAG != 'y')
- {
- fprintf(fp,"sele 10\n use %sndx exclusive\ngo top\n",aarr);
- fprintf(fp,"loca for trim(╦≈╥²╫╓╢╬)='%s'.and.trim(┐Γ├√)='%s'\n",lname[j-1],mybase->DB);
- fprintf(fp,"nf=trim(╦≈╥²╬─╝■)\n");
- fprintf(fp,"select %c\n",j+65);
- coflag[j+1]=0 ;
- fprintf(fp,"use %s%s inde %s&nf exclusive\naflag%c=1\n",aarr,mybase->DB,aarr,s[j]+64) ;
- }
- else
- {
- fprintf(fp,"sele 10\n use %sndx \ngo top\n",mybase->COPATH);
- fprintf(fp,"loca for trim(╦≈╥²╫╓╢╬)='%s'.and.trim(┐Γ├√)='%s'\n",lname[j-1],mybase->DB);
- fprintf(fp,"nf=trim(╦≈╥²╬─╝■)\n");
- fprintf(fp,"select %c\n",j+65);
-
- coflag[j+1] = 1 ;
- fprintf(fp,"use %s%s inde %s&nf\naflag%c=1\n",mybase->COPATH,mybase->DB,mybase->COPATH,s[j]+64) ;
- fprintf(fp,"sele 10\nuse %sndx exclusive\n",aarr) ;
- }
- if (linkflag==0)
- fprintf(fp,"sele A\nset rela to %s into %c\n",lname[j-1],j+65);
- else
- fprintf(fp,"sele %c\nset rela to %s into %c addi\n",j+64,lname[j-1],j+65);
- j++;
- }
- if(fs==1)
- {
- while(fgets(buff,120,dp))
- { if(buff[1]=='#') break;
- pr("clear\nselect 1\ngo top\ndo while .not. eof()\n");
- l=0;
- clear_win(20,3,22,72,0) ;
- clear_win(19,1,21,70,31) ;
- /*** color_puts(" please assure ", 45, 17, 30) ;****/
- color_puts(" ╟δ╚╖╚╧ ", 45, 17, 30) ;
- line_edit(20,2,31,buff,60) ;
- while(buff[l]!='\n') l++;
- buff[l]='\0';
- pr("select 1\n");
- fprintf(fp,"if %s\n",buff);
- pr("w=.t.\n");
- pr("do while w\nclear\nset color to w+/B\n");
- fprintf(fp,"@1,5 say \"╕∙╛▌╠⌡╝■ : %s\"\nset color to W+/B\n",buff);
- min_data(j,i,fp,s,aarr);
- }
- }
- if(fs==2)
- {
- while(fgets(buff,120,tp))
- { if(buff[1]=='#') break;
- mcon(fp,buff);
- pr("clear\n");
- pr("select 1\ndo while .not. eof()\n");
- pr("select 1\n");
- fprintf(fp,"if &condition\n");
- pr("w=.t.\ndo while w\nclear\nset color to W+/B\n");
- pr("@1,2 say condition\n");
- min_data(j,i,fp,s,aarr);
- }
- }
- if(fs==3)
- {
- j=0;
- while(s[j]!=0)
- {
- mybase=fbase;
- while(mybase->no!=(s[j]-1))
- mybase=mybase->next;
- fprintf(fp,"sele %c\ncopy to s%s stru exte\n",j+65,mybase->DB);
- j++;
- }
- pr("sele A\nset color to w+/B\n@0,0 say '╚╬╥Γ╠⌡╝■╨▐╕─'\n");
- pr("condition=''\n");
- pr("cb=1\n");
- pr("cs=.t.\n");
- pr("do while cs\n");
- rcon(i,j,s,fp);
- pr("do rcon with renu,cb,condition,cs\n");
- pr("enddo\n");
- pr("clear\n");
- pr("select 1\ngo top\ndo while .not. eof()\n");
- pr("select 1\n");
- fprintf(fp,"if &condition\n");
- pr("w=.t.\ndo while w\nclear\nset color to W+/B\n");
- pr("@1, 2 say condition\n");
- min_data(j,i,fp,s,aarr);
- }
- fprintf(fp,"sele 10\nuse %sndx inde %sndx exclusive\n",aarr,aarr);
- j=0;
- while(s[j]!=0)
- {
- mybase=fbase;
- while(mybase->no!=(s[j]-1))
- mybase=mybase->next;
- fprintf(fp,"sele 10\ngo top\n");
- fprintf(fp,"loca for trim(┐Γ├√)='%s'\n",mybase->DB);
- fprintf(fp,"do while .not.eof()\nnf=trim(╦≈╥²╬─╝■)\n");
- fprintf(fp,"select %c\n",j+1+64);
- if( mybase->COFLAG == 'Y' || mybase->COFLAG == 'y')
- fprintf(fp,"use %s%s inde %s&nf exclusive\n",mybase->COPATH,mybase->DB,mybase->COPATH) ;
- else
- fprintf(fp,"use %s%s inde &nf exclusive\n",aarr,mybase->DB) ;
- pr("reinde\nuse\nsele 10\ncontinue\nenddo\n") ;
- j++;
- }
- pr("return\n");
- fclose(fp);
- fclose(dp);
- fclose(tp);
- }
-
-
- cr_sub41(char dname[][20],int i)
- {FILE *fp;
- char name[15],buff[130];
- int k,row,col;
- fp=fopen("modify.prg","w");
- pr("set talk off\ndo while .t.\nset color to /w\nclear\nset color to w+/B\n");
- pr("@0,0 say '***╠⌡╝■╨▐╕─***'\n");
- pr("@2,26 say '─·┐╔╢╘╧┬┴╨┐Γ╜°╨╨▓┘╫≈'\n");
- pr("@3,26 say '~~~~~~~~~~~~~~~~~~~~'\nset color to W/B\n");
- fprintf(fp,"set color to w+/n\n@6,15 clea to %d,65\n",6+i/2+i%2+1);
- fprintf(fp,"set color to w+/b\n@5,13 clea to %d,63\n",5+i/2+i%2+1);
- row=6;col=15;
- for(k=0;k<i;k++)
- { fprintf(fp,"@%d,%d say '%d. %s'\n",row,col,k+1,dname[k]);
- if(col==45) {col=15;row++;}
- else col+=30;
- }
- for(k=1;k<=6;k++)
- fprintf(fp,"select %d\nuse\n",k);
- pr("choice=space(2)\nset color to w+/b\n");
- pr("@22,10 say '╟δ╩Σ╚δ─·╡─╤í╘±,0▒φ╩╛═╦│÷ : ' get choice\n read\n");
- pr("set color to W+/N\nif trim(choice)='0'\n");
- pr("return\nendif\n");
- pr("nn='msub'+trim(choice)+'.prg'\n");
- pr("if FILE (nn)\n");
- pr("do msub&choice\n");
- pr("endif\n");
- pr("enddo\n");
- fclose(fp);
- }
-
-
- /*---------------- This is a line editer -----------------------*/
- /* row,col posite the starting cursor */
- /* color denote the color of the */
- /* blackbord and the character */
- /* buff line-editer's interal denoting */
- /*--------------------------------------------------------------*/
- line_edit(int row, int col, int color, char *buff, int len)
- {
- int in_number=0, ins=1, i, j, flag=0 ;
- char *str ;
- union {
- int i;
- char ch[2];
- }key;
-
- len -= 2 ;
- color_puts(buff, color, row, col ) ;
- while(1)
- {
- cursor( row, col+in_number ) ;
- key.i = bioskey(0) ;
- switch(key.i)
- {
- case 15104: /* F1 */
- break ;
-
- case 19200: /* left arrow */
- if(in_number)
- in_number=confirm(buff,in_number-1);
- cursor( row, col+in_number ) ;
- break ;
-
- case 19712: /* right arrow */
- if( buff[in_number]=='\0' )
- buff[in_number]=' ' ;
- if((unsigned)buff[in_number]>128 && (unsigned)buff[in_number]>128)
- in_number+=2 ;
- else
- in_number++ ;
- if(in_number>len)
- in_number=0 ;
- break ;
-
- case 29440: /* Ctrl_left */
- in_number=confirm(buff,in_number-8) ;
- if( in_number <0 )
- in_number=0 ;
- break ;
-
- case 29696: /* ctrl_right */
- in_number = confirm(buff, in_number+8) ;
- if( in_number>(i=strlen(buff)))
- in_number = i ;
- break ;
-
- case 18176: /* Home */
- in_number=0 ;
- cursor( row, col ) ;
- break ;
-
- case 20224: /* End */
- in_number=strlen(buff) ;
- cursor( row, col+in_number ) ;
- break ;
-
- case 21248: /* Del */
- if( in_number==strlen(buff) )
- /* printf("\007");*/ ;
- else
- {
- if( (unsigned)buff[in_number]>128 && (unsigned)buff[in_number]>128 )
- {
- for( i=in_number+2,j=strlen(buff); i<=j; i++ )
- buff[i-2]=buff[i] ;
- color_puts( " ", color, row, col+j-2 ) ;
- }
- else
- {
- for( i=in_number+1,j=strlen(buff); i<=j; i++)
- buff[i-1] = buff[i] ;
- color_puts( " ", color, row, col+j-1 ) ;
- }
- str = &buff[in_number] ;
- color_puts(str, color, row, col+in_number) ;
- }
- break ;
-
- case 3592: /* Backspace */
- if(in_number)
- {
- if( (unsigned)buff[in_number-1]>128 && (unsigned)buff[in_number-2]>128 && in_number>1 )
- {
- for( i=in_number,j=strlen(buff); i<=j; i++)
- buff[i-2] = buff[i] ;
- in_number-=2 ;
- color_puts( " ", color, row, col+j-2 ) ;
- }
- else
- {
- for( i=in_number,j=strlen(buff); i<=j; i++)
- buff[i-1] = buff[i] ;
- in_number-- ;
- color_puts( " ", color, row, col+j-1 ) ;
- }
- str = &buff[in_number] ;
- color_puts( str, color, row, col+in_number ) ;
- }
- else
- /* printf("\007"); */ ;
- break ;
-
- case 20992: /* Ins */
- ins=(ins?0:1) ;
- break ;
-
- case 7181: /* Enter */
- for( i=strlen(buff)-1; buff[i]==' '&&i>=0; i--);
- buff[i+1]='\0' ;
- return ;
-
- default:
- if( ins )
- {
-
- if( strlen(buff)>=len || key.ch[0]==0)
- /* printf("\007") ; */;
- else
- {
- for( i=strlen(buff); i>in_number; i--)
- buff[i] = buff[i-1] ;
- buff[in_number] = key.ch[0] ;
- if( (unsigned)key.ch[0]>128 )
- if( flag==0 ) /* the forehalf of chinese */
- {
- flag++ ;
- in_number++ ;
- }
- else
- {
- flag-- ;
- str = &buff[in_number-1] ;
- color_puts( str, color, row, col-1+in_number++ ) ;
- }
- else
- {
- str = &buff[in_number] ;
- color_puts( str, color,row, col+in_number++ ) ;
- }
- }
- }
- else
- {
- if( in_number>=len || key.ch[0]==0 )
- /* printf("\007") ; */;
- else
- {
- buff[in_number] = key.ch[0] ;
- str = &buff[in_number] ;
- color_puts( str, color, row, col+in_number++ ) ;
- }
- }
-
- }
- }
- }
-
-
- /*----- if the charater is chinese , and then the cursor must be in the first position----*/
- confirm(char *s, int col)
- {
- int i ;
- if( (unsigned)s[col]<128)
- return(col) ;
- for(i=col; (unsigned)s[i]>128&&i>0; i--) ;
- if((col-i)%2!=0)
- return(col) ;
- else
- return(col-1) ;
- }
-