home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <fcntl.h>
- #define white 7
- #define red_back 64
- #define yellow 14
- #define blue_back 16
- #define eblue 3
- struct menu {
- char mean[31];
- char prog_name[9];
- int subprog;
- int start;
- int end;
- int row;
- int col;
- struct menu *last,*next;
- };
-
- struct menu *menuhead,*scrhead,*scrend,*midd;
- struct menu *pagehead,*pageend;
- int flag;
- char path[9]={"\0\0\0\0\0\0\0\0\0"};
- struct menu *dm[7],*dn[7],*dl[7];
- int posi[7];
- extern char pathname[14];
- progag(name)
- char *name;
- {
- FILE *fmenu;
- int ctc;
- char menu_buff[80];
- if ((fmenu=fopen("menu.txt","r"))==NULL) {
- cls(3,46,7,76,6|1);
- frame(3,45,7,74,white | red_back);
- print(3,47,white | red_back,"╢╘▓╗╞≡, ─·├╗╙╨╔·│╔╙ª╙├╧╡═│");
- print(4,47,white | red_back,"╡─▓╦╡Ñ. ▓╗─▄╔·│╔╙ª╙├│╠╨≥ ");
- print(5,47,white | red_back,"Press any key to continue ");
- getchb();
- cls(2,42,8,76,0|113);
- return(0);
- }
- getmenu_mem();
- menuhead=midd; pagehead=midd; pageend=midd;
- while (fgets(menu_buff,80,fmenu)!=NULL)
- {
- sscanf(menu_buff,"#%[^#]#,#%[^#]#,%d,%d,%d,%d",midd->mean,midd->prog_name,\
- &(midd->subprog),&(midd->start),&(midd->end),&(midd->row),&(midd->col));
- getmenu_mem();
- pageend->next=midd; midd->last=pageend;
- pageend=midd;
- }
- pageend=midd->last; midd->last->next=NULL;
- midd->last=NULL; free(midd);
- scrhead=menuhead->next; pageend=menuhead;
- for (ctc=0;ctc<menuhead->end-1;ctc++) pageend=pageend->next;
- scrend=scrhead;
- for (ctc=0;ctc<10;ctc++)
- {
- if (scrend==pageend) break;
- scrend=scrend->next;
- }
- print(24,0,0|75,"%-80s"," íⁿ ╔╧╥╞╣Γ┤° í² ╧┬╥╞╣Γ┤° Enter╤í╘± Esc ═╦│÷ ");
- edit_menu(name);
- return(0);
- }
-
- disp_menu()
- /*int flag;*/
- {
- struct menu *dm;
- int i,j;
- cls(7,45,20,78,6|1);
- frame(7,44,20,76,yellow | blue_back);
- dm=scrhead; i=7; j=45;
- while (dm!=scrend)
- {
- print(i,j,yellow | blue_back,"%-30s",dm->mean);
- i++;
- dm=dm->next;
- }
- print(i,j,yellow | blue_back,"%-30s",dm->mean);
- return(0);
- }
-
- edit_menu(name)
- char *name;
- {
- int js3=7;
- int charact,j,wh_flag;
- int posi[7];
- flag=0;
- j=45;
- if (menuhead->subprog==0)
- {
- mk_dir("",j,name);
- cls(7,44,21,78,yellow | blue_back);
- free(menuhead);
- return(1);
- }
- midd=scrhead; disp_menu();
- path[flag]='\0';
- for(;;)
- {
- print(js3,j,0|113,"%-30s",midd->mean);
- /* path[flag]='\0';*/
- while ((charact=getchb())!=27)
- {
- switch (charact)
- {
- case 272:
- print(js3,j,yellow | blue_back,"%-30s",midd->mean);
- if (midd!=scrhead) {midd=midd->last; path[flag]--; js3--; break;}
- if (scrhead==pagehead->next) break;
- midd=scrhead=midd->last; scrend=scrend->last;
- disp_menu(flag);
- break;
- case 280:
- print(js3,j,yellow | blue_back,"%-30s",midd->mean);
- if (midd!=scrend) {midd=midd->next; path[flag]++; js3++; break;}
- if (scrend==pageend) break;
- midd=scrend=midd->next; scrhead=scrhead->next;
- disp_menu(flag);
- break;
- case 13:path[flag]=path[flag]+65; path[flag+1]='\0';
- if (midd->subprog==0)
- {
- mk_dir(path,j,name);
- cls(6,44,20,78,0|113);
- path[flag]=path[flag]-65;
- disp_menu(flag); break;
- }
- dm[flag]=scrhead; dn[flag]=scrend;
- dl[flag]=midd; posi[flag]=js3; flag++;
- if (flag==1)
- {
- cls(3,7,13,42,6|1);
- frame(3,6,13,40,yellow | blue_back);
- }
- for (wh_flag=0;wh_flag<flag;wh_flag++)
- print(3+wh_flag,8,yellow | blue_back,"%-30s",dl[wh_flag]);
- scrend=menuhead;
- for (j=0;j<midd->start;j++) scrend=scrend->next;
- pagehead=scrend; scrhead=pagehead->next;
- for (j=0;j<midd->end-1;j++) scrend=scrend->next;
- pageend=scrend; scrend=pagehead;
- for (j=0;j<10;j++)
- {
- if (scrend==pageend) break;
- scrend=scrend->next;
- }
- midd=scrhead;
- disp_menu(flag); js3=7; j=45;
- break;
- }
- print(js3,j,0|113,"%-30s",midd->mean);
- }
- path[flag--]='\0';
- if (flag==-1) break;
- if (flag!=0)
- {
- cls(4,8,11,38,yellow | blue_back);
- for (wh_flag=0;wh_flag<flag;wh_flag++)
- print(3+wh_flag,8,yellow | blue_back,"%-30s",dl[wh_flag]);
- }
- else
- cls(2,5,13,42,0|113);
- path[flag]-=65;
- cls(6,44,20,77,0|113);
- scrend=menuhead;
- for (j=0;j<pagehead->start;j++) scrend=scrend->next;
- pagehead=scrend;
- for (j=0;j<pagehead->end-1;j++) scrend=scrend->next;
- pageend=scrend; scrhead=dm[flag];
- scrend=dn[flag]; midd=dl[flag]; js3=posi[flag]; j=45;
- disp_menu();
- }
- cls(6,0,24,79,0|113);
- midd=menuhead->next;
- while (midd==NULL)
- {
- midd->last=NULL;
- menuhead->next=NULL;
- free(menuhead);
- menuhead=midd; midd=midd->last;
- }
- free(menuhead);
- return(0);
- }
-
- getmenu_mem()
- {
- midd=(struct menu *) malloc(sizeof(struct menu));
- midd->last=midd->next=NULL;
- return(0);
- }
-
- mk_dir(path,topcol,name)
- char *path;
- int topcol;
- char *name;
- {
- int i,j;
- FILE *fp,*fw;
- char db[20],buff[80];
- if (strcmp(path,"")==0)
- goto gen;
- if (chdir(path)==0)
- {
- if ((fp=fopen("smain.prg","r"))!=NULL)
- {
- /*cls(12,topcol+6,16,topcol+29,6|1);
- cls(11,topcol+4,15,topcol+26,yellow | blue_back);*/
- cls(12,topcol+5,16,topcol+30,0);
- frame(12,topcol+4,16,topcol+28,0|75);
- print(12,topcol+6,0|75,"─·╘°╛¡╔·│╔╣²▒╛╫╙╧╡═│");
- print(13,topcol+6,0|75,"╙ª╙├│╠╨≥, ─·╩╟╖±╧δ╓╪");
- print(14,topcol+6,0|75,"╔·│╔ (Y/N)? ");
- fclose(fp);
- i=getchb();
- while (i!='Y' && i!='y' && i!='N' && i!='n') i=getchb();
- if (i=='N' || i=='n') {chdir(".."); return(0);}
- }
- }
- else {mkdir(path); chdir(path);}
- disp_menu(flag);
- strcpy(db,name); strcat(db,"\\db.txt");
- fp=fopen(db,"r"); fw=fopen("db.txt","w");
- i=0; j=0;
- while (i<midd->start) {fgets(buff,80,fp);i++;}
- for (j=0;j<midd->end;j++)
- {
- fgets(buff,120,fp);
- fprintf(fw,"%s",buff);
- }
- fclose(fp); fclose(fw);
- gen:generat(topcol,name);
- return(0);
- }
-
- generat(topcol,name)
- int topcol;
- char *name;
- {
- struct process {
- char model[13];
- char pathname[20];
- };
- struct process program[11]={
- {"┬╝╚δ╙δ╬¼╗ñ ","c:\\cdbag4\\get_in "},
- {"▓Θ ╤» ","c:\\cdbag4\\look "},
- {"┼┼ ╨≥ ","c:\\cdbag4\\sort "},
- {"═│╝╞╙δ╝╞╦π ","c:\\cdbag4\\statis "},
- {"╠¿ ╒╩ ▒¿ ▒φ ","c:\\cdbag4\\tetris "},
- {"═│╝╞═╝╨╬╧╘╩╛","c:\\cdbag4\\tjtuxi "},
- {"╩² ╛▌ ┤½ ╡▌ ","c:\\cdbag4\\sjcd "},
- {"═╝╨╬┬╝╚δ▓Θ╤»","c:\\cdbag4\\txlrcx "},
- {"═¿╙├▒¿▒φ┤≥╙í","c:\\cdbag4\\report "},
- {"╚╬╥Γ▒¿▒φ┤≥╙í","c:\\cdbag4\\print "},
- {"└⌐ │Σ │╠ ╨≥ ","c:\\cdbag4\\kccx "},
- };
- int i,j,m,wh_flag;
- struct menu *s_head,*s_end;
- int charact;
- char pname[40];
- /*cls(9,topcol+8,21,topcol+22,6|1);
- cls(8,topcol+7,20,topcol+21,0|113);*/
- cls(9,topcol+8,21,topcol+25,0);
- frame(9,topcol+7,21,topcol+23,0|30);
- charact=9;
- for (i=0;i<11;i++)
- {
- print(9+i,topcol+9,0|30,"%s",program[i].model);
- }
- i=0;
- print(9+i,topcol+9,0|113,"%s",program[i].model);
- while ((charact=getchb())!=27)
- {
- switch (charact)
- {
- case 272:
- print(9+i,topcol+9,0|30,"%s",program[i].model);
- i=(i>0)?i-1:10;
- break;
- case 280:
- print(9+i,topcol+9,0|30,"%s",program[i].model);
- i=(i<10)?i+1:0;
- break;
- case 13 :if (sare_ware(topcol,i)==0)
- {
- /* cls(9,topcol+8,21,topcol+22,6|1);
- cls(8,topcol+7,20,topcol+21,0|113);*/
- cls(9,topcol+8,21,topcol+25,0);
- frame(9,topcol+7,21,topcol+23,0|30);
- for (charact=0;charact<11;charact++)
- print(9+charact,topcol+9,0|30,"%s",program[charact].model);
- break;
- }
- strcpy(pname,program[i].pathname);
- strcat(pname,name);
- /* if (i!=3)*/
- strcat(pname,"\\");
- strcat(pname," wy");
- system(pname);
- cls(0,0,24,79,6|1);
- print(0,0,0|30," ▓╦╡Ñ╔·│╔ ┐Γ╜ß╣╣╔·│╔ ╙ª╙├│╠╨≥╔·│╔ ═╦│÷ ");
- cls(1,0,24,79,0|113); s_head=scrhead; s_end=scrend;
- if (menuhead->subprog==0) goto gen;
- for (m=0;m<flag;m++)
- {
- scrhead=dm[m];
- scrend=dn[m];
- disp_menu(m);
- }
- scrhead=s_head; scrend=s_end; disp_menu(flag);
- print(24,0,0|75,"%-80s"," íⁿ ╔╧╥╞╣Γ┤° í² ╧┬╥╞╣Γ┤° Enter╤í╘± Esc ═╦│÷ ");
- if (flag>=1)
- {
- cls(3,7,13,42,6|1);
- frame(3,6,13,40,yellow | blue_back);
- }
- for (wh_flag=0;wh_flag<flag;wh_flag++)
- print(3+wh_flag,8,yellow | blue_back,"%-30s",dl[wh_flag]);
- gen:
- /*cls(9,topcol+8,21,topcol+21,6|1);
- cls(8,topcol+7,20,topcol+21,0|113);*/
- cls(9,topcol+8,21,topcol+25,0);
- frame(9,topcol+7,21,topcol+23,0|30);
- for (j=0;j<11;j++)
- print(9+j,topcol+9,0|30,"%s",program[j].model);
- break;
- }
- print(9+i,topcol+9,0|113,"%s",program[i].model);
- }
- gen_main(pathname);
- if (menuhead->subprog!=0)
- system("cd ..");
- cls(21,0,22,79,0|113);
- return(0);
- }
-
- sare_ware(topcol,count)
- int topcol;
- int count;
- {
- struct process {
- char model[13];
- char pathname[25];
- };
- struct process program[11]={
- {"┬╝╚δ╙δ╬¼╗ñ ","c:\\cdbag4\\get_in"},
- {"▓Θ ╤» ","c:\\cdbag4\\look"},
- {"┼┼ ╨≥ ","c:\\cdbag4\\sort"},
- {"═│╝╞╙δ╝╞╦π ","c:\\cdbag4\\statis"},
- {"╠¿ ╒╩ ▒¿ ▒φ ","c:\\cdbag4\\tetris"},
- {"═│╝╞═╝╨╬╧╘╩╛","c:\\cdbag4\\tjtuxi"},
- {"╩² ╛▌ ┤½ ╡▌ ","c:\\cdbag4\\sjcd"},
- {"═╝╨╬┬╝╚δ▓Θ╤»","c:\\cdbag4\\txlrcx"},
- {"═¿╙├▒¿▒φ┤≥╙í","c:\\cdbag4\\report"},
- {"╚╬╥Γ▒¿▒φ┤≥╙í","c:\\cdbag4\\print"},
- {"└⌐ │Σ │╠ ╨≥ ","c:\\cdbag4\\kccx"},
- };
- int handle;
- strcat(program[count].pathname,".exe");
- if ((handle=_open(program[count].pathname,O_RDONLY))==-1)
- {
- /*cls(9,topcol+6,15,topcol+26,6|1);
- cls(10,topcol+5,14,topcol+27,white | red_back);*/
- frame(11,topcol+5,15,topcol+27,0|75);
- print(11,topcol+7,0|75,"╢╘▓╗╞≡, ─·├╗╙╨╣║┬⌠");
- print(12,topcol+7,0|75,"┤╦─ú┐Θ╡─╔·│╔│╠╨≥. ");
- print(13,topcol+7,0|75,"╝ⁿ╚╬╥╗╝ⁿ╝╠╨° ... ");
- getchb();
- cls(9,topcol+4,15,topcol+27,yellow | blue_back);
- return(0);
- }
- else _close(handle);
- return(1);
- }
-
- gen_main(name)
- char *name;
- {
- struct process {
- char model[30];
- char pathname[25];
- };
- struct process prg[11]={
- {"┬╝╚δ ╙δ ╬¼╗ñ ","get_in.prg"},
- {"▓Θ ╤» ","look.prg"},
- {"┼┼ ╨≥ ","sort.prg"},
- {"═│╝╞ ╙δ ╝╞╦π ","statis.prg"},
- {"╠¿ ╒╩ ▒¿ ▒φ ","tetris.prg"},
- {"═│╝╞═╝╨╬╧╘╩╛ ","tjtuxi.prg"},
- {"╩² ╛▌ ┤½ ╡▌ ","sjcd.prg"},
- {"═╝╨╬┬╝╚δ▓Θ╤» ","txlrcx.prg"},
- {"═¿╙├▒¿▒φ┤≥╙í ","print.prg"},
- {"╚╬╥Γ▒¿▒φ┤≥╙í ","anyprint.prg"},
- {"└⌐ │Σ │╠ ╨≥ ","kccx.prg"},
- };
-
- FILE *fp,*fw;
- int ctc,ctc1;
- fp=fopen("smain.prg","w");
- fprintf(fp,"public pathp\npathp='%s'\nif .not.file('db.dbf')\n",name);
- fprintf(fp," use %s\\db\n",name);
- fprintf(fp," copy to db stru\n use db\n appe from db deli with #\n");
- fprintf(fp," use\nendif\n");
- fprintf(fp,"do while .t.\nset color to W+/W,w+g\nclear\nset color to W+/N\n");
- if ((fw=fopen("code.dbf","r"))!=NULL)
- {
- fprintf(fp,"sele 8\nuse code exclusive\n");
- /* fprintf(fp,"inde on trim(fieldname)+trim(fieldcode) to codeinde\n");*/
- fprintf(fp,"set inde to codeinde\nsele 1\n");
- }
- fclose(fw);
- fprintf(fp,"@7,12 clear to 18,72\nset color to W+/B\n@6,10 clear to 17,70\n");
- ctc=0;ctc1=1;
- while (ctc<11)
- {
- if ((fw=fopen(prg[ctc].pathname,"r"))!=0)
- {
- fprintf(fp,"@%d,20 say ' %2d---%s'\n",7+ctc1,ctc1,prg[ctc].model);
- ctc1++;
- fclose(fw);
- }
- ctc++;
- }
- fprintf(fp,"set color to W+/R\n");
- fprintf(fp,"@20,20 say '╟δ ╩Σ ╚δ ─· ╡─ ╤í ╘±:'\nxujze=' '\n");
- fprintf(fp,"@row(),col() get xujze pict '9'\n");
- fprintf(fp,"read\nset color to W/B\n");
- fprintf(fp,"do case\n");
- ctc=0;ctc1=0;
- while (ctc<11)
- {
- if ((fw=fopen(prg[ctc].pathname,"r"))!=0)
- {
- fprintf(fp," case xujze='%c'\n",0x31+ctc1);
- fprintf(fp," do %s\n",prg[ctc].pathname);
- ctc1++;
- fclose(fw);
- }
- ctc++;
- }
- fprintf(fp," case xujze='0'\n set color to W+/B\n return\n");
- fprintf(fp,"endcase\nenddo\nset color to W+/B\n");
- fprintf(fp,"return\n");
- fclose(fp);
- }
-
- mainprg(name)
- char *name;
- {
- FILE *fp;
- fp=fopen("main.prg","w");
- fprintf(fp,"public path\n");
- fprintf(fp,"set excl on\n");
- fprintf(fp,"set stat off\n");
- fprintf(fp,"set scor off\n");
- fprintf(fp,"clear\n");
- fprintf(fp,"set talk off\n");
- fprintf(fp,"set color to B/W\n");
- fprintf(fp,"@0,0 clea to 24,79\n");
- fprintf(fp,"@10,20 say '╒² ╘┌ ╘ñ ┤ª └φ ... ╟δ ╔╘ ║≥'\n");
- fprintf(fp,"set exact off\n");
- fprintf(fp,"set safety off\nset cons off\n");
- fprintf(fp,"sele 1\n");
- fprintf(fp,"use db\n");
- fprintf(fp,"if eof()\n");
- fprintf(fp," appe from db delimited with #\n");
- fprintf(fp," use db\n");
- fprintf(fp," dbname=space(8)\n");
- fprintf(fp," go top\n");
- fprintf(fp," do while .not.eof()\n");
- fprintf(fp," flag_db=flag\n");
- fprintf(fp," dbname=name\n");
- fprintf(fp," sharep=sharepath\n");
- fprintf(fp," dbfname=trim(sharep)+trim(dbname)\n");
- fprintf(fp," if file(trim(dbfname)+'.dbf')\n");
- fprintf(fp," sele 3\n");
- fprintf(fp," use &dbfname\n");
- fprintf(fp," copy to oztom deli with #\n");
- fprintf(fp," use\n");
- fprintf(fp," run del &dbfname..dbf\n");
- fprintf(fp," endif\n");
- fprintf(fp," sele 2\n");
- fprintf(fp," use dbf_stru\n");
- fprintf(fp," zap\n");
- fprintf(fp," if file(trim(dbname)+'.txt')\n");
- fprintf(fp," appe from &dbname delimited with #\n");
- fprintf(fp," endif\n");
- fprintf(fp," sele 1\n");
- fprintf(fp," if flag_db='Y'\n");
- fprintf(fp," sele 2\n");
- fprintf(fp," creat &dbfname from dbf_stru\n");
- fprintf(fp," if file('oztom.txt')\n");
- fprintf(fp," use &dbfname\n");
- fprintf(fp," appe from oztom deli with #\n");
- fprintf(fp," run del %s\\oztom.txt\n",name);
- fprintf(fp," endif\n");
- fprintf(fp," use\n");
- fprintf(fp," endif\n");
- fprintf(fp," sele 1\n");
- fprintf(fp," skip\n");
- fprintf(fp," enddo\n");
- fprintf(fp," use ndx\n");
- fprintf(fp," if eof()\n");
- fprintf(fp," do ndx\n");
- fprintf(fp," endif\n");
- fprintf(fp," use\n");
- fprintf(fp,"endif\n");
- fprintf(fp,"sele 2\n");
- fprintf(fp,"use\nset cons on\n");
- fprintf(fp,"sele 1\n");
- fprintf(fp,"use menu\n");
- fprintf(fp,"if eof()\n");
- fprintf(fp," appe from menu delimited with #\n");
- fprintf(fp," use\n");
- fprintf(fp,"endif\n");
- fprintf(fp,"use menu\n");
- fprintf(fp,"dirp=space(9)\n");
- fprintf(fp,"startr=star_rec\n");
- fprintf(fp,"endr=end_rec\n");
- fprintf(fp,"midd=startr+1\n");
- fprintf(fp,"do root\n");
- fprintf(fp,"wait\n");
- fprintf(fp,"go top\n");
- fprintf(fp,"if (sub_pro=0)\n");
- fprintf(fp," do smain\n");
- fprintf(fp," return\n");
- fprintf(fp,"endif\n");
- fprintf(fp,"do while .t.\n");
- fprintf(fp," set color to GR+/B\n");
- fprintf(fp," @0,0 clea to 24,79\n");
- fprintf(fp," progname=prog\n");
- fprintf(fp," do &progname\n");
- fprintf(fp," go midd\n");
- fprintf(fp," xuze=0\n");
- fprintf(fp," do while xuze>=endr.or.xuze<0\n");
- fprintf(fp," input ' ╟δ ╩Σ ╚δ ─· ╡─ ╤í ╘±:' to xuze\n");
- fprintf(fp," enddo\n");
- fprintf(fp," if xuze=0.and.startr=0\n");
- fprintf(fp," return\n");
- fprintf(fp," endif\n");
- fprintf(fp," if xuze=0\n");
- fprintf(fp," go xuze+midd\n");
- fprintf(fp," startr=star_rec\n");
- fprintf(fp," endr=end_rec\n");
- fprintf(fp," midd=startr+1\n");
- fprintf(fp," m_len=len(dirp)\n");
- fprintf(fp," dirp=substr(dirp,1,m_len-1)\n");
- fprintf(fp," loop\n");
- fprintf(fp," endif\n");
- fprintf(fp," dirp=trim(dirp)+chr(xuze+64)\n");
- fprintf(fp," go xuze+midd\n");
- fprintf(fp," if sub_pro=0\n");
- fprintf(fp," run cd %s\\&dirp\n",name);
- fprintf(fp," do smain\n");
- fprintf(fp," run cd %s\n",name);
- fprintf(fp," m_len=len(dirp)\n");
- fprintf(fp," dirp=substr(dirp,1,m_len-1)\n");
- fprintf(fp," m_len=m_len-1\n");
- fprintf(fp," if m_len=0\n");
- fprintf(fp," ctc=0\n");
- fprintf(fp," else\n");
- fprintf(fp," ctc=asc(substr(dirp,m_len,1))-64\n");
- fprintf(fp," endif\n");
- fprintf(fp," sele 1\n");
- fprintf(fp," use menu\n");
- fprintf(fp," go midd\n");
- fprintf(fp," go star_rec+1+ctc\n");
- fprintf(fp," else\n");
- fprintf(fp," startr=star_rec\n");
- fprintf(fp," endr=end_rec\n");
- fprintf(fp," midd=startr+1\n");
- fprintf(fp," endif\n");
- fprintf(fp,"enddo\n");
- fprintf(fp,"return\n");
-
- fclose(fp);
- }
- o\n");
- fprintf(fp,"return\n");
-
- fclose(fp);
- }