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

  1.  
  2. /*┬╝╚δ╬¼╗ñ─ú┐Θ*/
  3. #define black  0x0
  4. #define blue   0x10
  5. #define green  0x20
  6. #define cyan   0x30
  7. #define red    0x40
  8. #define white  0x70
  9.  
  10. #define yellow 33
  11. #define ewhite 37
  12. #define blue_back 44
  13. #define green_back 42
  14.  
  15. #define back_black 40
  16. #define back_red  41
  17. #define back_green 42
  18. #define back_yellow 43
  19. #define back_blue 44
  20. #define back_magenta 45
  21. #define back_cyan 46
  22. #define back_white 47
  23. #define fore_black 30
  24. #define fore_red 31
  25. #define fore_green 32
  26. #define fore_yellow 33
  27. #define fore_blue 34
  28. #define fore_magenta 35
  29. #define fore_cyan 36
  30. #define fore_white 37
  31.  
  32. #define UP  6     /* used in edd() */
  33. #define DOWN 7
  34. #define PgUp 18688
  35. #define PgDn 20736
  36. #define NOTHING 0 /* used in edd() */
  37. #define DOUBLE 0  /* using in gframe() */
  38. #define SINGAL 1
  39. #define CLEAR  2  /* used in  gframe   */
  40. #define YES    1  /* using in want_cursor() */
  41. #define NO     0  /* using in want_cursor() */
  42.  
  43.  
  44. #include<stdio.h>
  45. #include<stdlib.h>
  46. #include <alloc.h>
  47. #include <dir.h>
  48. #include <string.h>
  49. #include <dos.h>
  50.  
  51. #define pr(x)  fprintf(fp,x)
  52. typedef struct bb{
  53.          char MEAN[21],DB[9],KEY[4][11],COFLAG,COPATH[11];
  54.          int no;
  55.          struct bb *next;
  56.         }BASE;
  57. BASE *fbase;
  58. int NB,repeat,I,J,II,JJ;
  59. char *ccxx;
  60. main(argc,argv)
  61. int argc;
  62. char *argv[];
  63. {  char p,passwd[10],buff[60],sub[40];
  64.    int choice,i,j,cho[13],cchh[13], currow, curcol    ;
  65.    FILE *fp, *fg    ;
  66.   char *pro[13]={
  67.          ""    ,
  68.          "amd1.prg",
  69.          "amd2.prg",
  70.          "app.prg",
  71.          "modify.prg",
  72.          "delete.prg",
  73.          "setp.prg",
  74.          "pmod.prg",
  75.          "dcopy.prg",
  76.          "lookall.prg",
  77.          "diction.prg",
  78.          "maintain.prg",
  79.          "mcode.prg"
  80.         };
  81.  
  82.    if(argc<2)
  83.      return;
  84.    if (strcmp(argv[2],"wy")!=0) return(0);
  85.    for(i=1;i<13;i++)
  86.    {
  87.      cchh[i]=0;
  88.      cho[i]=0;
  89.    }
  90.    if((fp=fopen("get_in.prg","r"))!=NULL)
  91.    {
  92.      clear_win(0,0,24,79,0)    ;
  93.      color_puts("*** ┬╝ ╚δ ╬¼ ╗ñ ─ú ┐Θ ╥╤ ┤µ ╘┌ ***",14,12,15);
  94.      color_puts("    ╩╟ ╖± ╓╪ ╨┬ ╔· │╔ ( Y / N ) ? ",14,13,15);
  95.      cursor(14,35);
  96.      p=(char)bioskey(0);
  97.      if(p!='Y'&&p!='y')
  98.        {
  99.         for( i=1; i<13; i++)
  100.             if( (fg=fopen(pro[i], "r"))!=NULL )
  101.               {
  102.                 cchh[i]=1    ;
  103.                 cho[i]=1    ;
  104.                 fclose( fg )    ;
  105.               }
  106.        }
  107.      else
  108.        {
  109.         for( i=1; i<13; i++ )
  110.             if( (fg=fopen(pro[i], "r"))!=NULL)
  111.               {
  112.                 strcpy( sub, "del " )    ;
  113.                 strcat( sub, pro[i] )    ;
  114.                 strcat( sub, ">optzom" )    ;
  115.                 fclose( fg )    ;
  116.                 system( sub )    ;
  117.               }
  118.        }
  119.    fclose(fp);
  120.    }
  121.    fp=fopen("word.mem","w");
  122.    fclose(fp);
  123.    system("del word.mem");
  124.    repeat=1;
  125.  
  126.    getbase(argv[1]);
  127.    clear_win( 0, 0, 24, 79, 119 )    ;
  128.    color_puts("****┬╝╚δ╬¼╗ñ****",14,1,1);
  129.    clear_win( 11, 12, 13, 40, 0 )    ;
  130.    clear_win( 10, 10, 12, 38, 52 )    ;
  131.    passwd[0]='\0'    ;
  132.    color_puts( "╚τ╣√▓╗╨Φ╔Φ╓├ , ╟δ╗╪│╡ . ", 75, 24, 0 )    ;
  133.    color_puts("┐┌    ┴ε", 94, 11, 15 )    ;
  134.    color_puts("          ", 96, 11, 27 )    ;
  135.    line_edit( 11, 27, 96, passwd, 9 )    ;
  136.    clear_win( 14, 25, 18, 50, 0 )    ;
  137.    clear_win( 13, 23, 17, 48, 0x10 )    ;
  138.    color_puts( "╩╟╖±╤í╘±┤·┬δ▓┘╫≈", 95, 14, 28 )    ;
  139.    j = selete("╩╟", "╖± ", 16, 30, 37, 56 )    ;
  140.    if ( j == 1 )
  141.       {
  142.       system("copy c:\\cdbag4\\code*.* *.* > oztom");
  143. /*      system("copy c:\\cdbag4\\codep.prg *.* > oztom");*/
  144.       strcpy(sub,"c:\\cdbag4\\sub0 ");
  145.       strcat(sub,argv[1]);
  146.       system(sub); cho[12]=1; cchh[12]=1;
  147.       }
  148.    mkdir("creat");
  149. /*   strcpy(sub,"copy "); strcat(sub,argv[1]); strcat(sub,"*.txt creat > oztom");*/
  150. /*   system(sub);
  151.    system("copy db.txt creat > oztom");*/
  152.    strcpy(sub,"c:\\cdbag4\\");
  153.    strcat(sub,"sub  ");
  154.    j=1;
  155.    while(j)
  156.    {
  157.     printf("\033[2J");
  158.     clear_win(0,0,24,79,white)    ;
  159.     clear_win(5,17,21,59,black)    ;
  160.     clear_win(4,15,20,57,blue);
  161.     color_puts("****┬╝╚δ╬¼╗ñ****",14,1,1);
  162.     color_puts("╧╡ ═│ ╙╨ ╚τ ╧┬ ╣ª ─▄",fore_black,5,28);
  163.     color_puts("╠φ╝╙,▓σ╚δ,╨▐╕─,╔╛│²,▓Θ╤»(╥╗╠σ╗»)",fore_black,7 ,22);
  164.     color_puts("1. ╧╡═│╢¿╥σ╞┴─╗╕±╩╜",fore_black,9,21);
  165.     color_puts("2. ╙├╗º╢¿╥σ╞┴─╗╕±╩╜",fore_black,10,21);
  166.     color_puts("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",fore_black,11,18);
  167.     color_puts("3. ┤╙╞Σ╦ⁿ┐Γ╠⌡╝■╠φ╝╙",fore_black,12,21);
  168.     color_puts("4. ╠⌡╝■╨▐╕─         5. ╠⌡╝■╔╛│²",fore_black,13,21);
  169.     color_puts("6. ╨▐╕─┐┌┴ε         7. ┼·┴┐╕ⁿ╨┬",fore_black,14,21);
  170.     color_puts("8. ▒╕╖▌╩²╛▌         9. ╚½▓┐Σ»└└",fore_black,15,21);
  171.     color_puts("10.╧╡═│╬¼╗ñ╙δ╩²╛▌╫╓╡Σ",fore_black,17,21);
  172.     color_puts("11.╙├╗º└⌐│Σ─ú┐Θ     0. ═╦│÷",fore_black,18,21);
  173.     color_puts("╟δ╩Σ╚δ─π╡─╤í╘±(0--11) [   ]",fore_black,19,21);
  174.     for(choice=1; choice<12; choice++)
  175.       {
  176.     if(cchh[choice]==1)
  177.       {
  178.         position(choice, &currow, &curcol)    ;
  179.         cursor(currow, curcol)    ;
  180.         printf("*")    ;
  181.       }
  182.       }
  183.  loop:
  184.       color_puts(" ",43);
  185.       if((choice=get(0,11,19,44))!=0)
  186.        {
  187.         position(choice, &currow, &curcol)    ;
  188.         cho[choice]=1;
  189.         cursor(currow, curcol)    ;
  190.         printf("*");
  191.        }
  192.           color_puts("─π─▄╚╖╚╧┬≡? (Y/N) [ ]",43,23,15);
  193.           cursor(23,34);
  194.           p=(char)bioskey(0);
  195.           if(p=='y'||p=='Y')
  196.         { cchh[choice]=1;
  197.           switch(choice)
  198.            {
  199.              case 1:
  200.               sub[15]='\0';
  201.               sub[13]='1';
  202.               strcat(sub,argv[1]);
  203.               system(sub);
  204.               break;
  205.              case 2:
  206.                           sub[15]='\0';
  207.               sub[13]='2';
  208.               strcat(sub,argv[1]);
  209.               system(sub);
  210.               break;
  211.              case 3:
  212.                           sub[15]='\0';
  213.               sub[13]='3';
  214.               strcat(sub,argv[1]);
  215.               system(sub);
  216.               break;
  217.              case 4:
  218.                           sub[15]='\0';
  219.               sub[13]='4';
  220.               strcat(sub,argv[1]);
  221.               system(sub);
  222.               break;
  223.              case 5:
  224.                           sub[15]='\0';
  225.               sub[13]='5';
  226.               strcat(sub,argv[1]);
  227.               system(sub);
  228.               break;
  229.              case 6:
  230.               sub[13]='6';
  231.                           sub[15]='\0';
  232.               system(sub);
  233.               break;
  234.              case 7:
  235.                           sub[15]='\0';
  236.               sub[13]='7';
  237.               strcat(sub,argv[1]);
  238.               system(sub);
  239.               break;
  240.             case 8:
  241.               sub[13]='8';
  242.                           sub[15]='\0';
  243.               strcat(sub,argv[1]);
  244.               system(sub);
  245.               break;
  246.             case 9:
  247.               sub[13]='9';
  248.                           sub[15]='\0';
  249.               strcat(sub,argv[1]);
  250.               system(sub);
  251.               break;
  252.             case 10:
  253.               sub[13]='a';
  254.               sub[15]='\0';
  255.               strcat(sub,argv[1]);
  256.               system(sub);
  257.               break;
  258.             case 11:
  259.               sub[13]='b';
  260.               sub[15]='\0';
  261.               strcat(sub,argv[1]);
  262.               system(sub);
  263.               break;
  264.             case 0:
  265.               j=0;
  266.               break;
  267.              }
  268.              }
  269.         else
  270.         {
  271.            if(choice!=0)
  272.            {
  273.                cho[choice]=0;
  274.                cursor(currow, curcol)    ;
  275.                printf(" ")    ;
  276.                goto loop    ;
  277.            }
  278.         }
  279.      }
  280.    m_menu(cchh,argv[1]);
  281.    rrcon();
  282. /*   cr_ndx(argv[1]);*/
  283.    pass(passwd);
  284. /*   system("copy c:\\cdbag4\\code.dbf *.* > oztom");*/
  285.    system("copy c:\\cdbag4\\proced.prg *.* > oztom");
  286.    system("copy c:\\cdbag4\\again.prg  *.* > oztom");
  287.    system("del oztom");
  288.  }
  289.  
  290.  
  291.  getbase(char *nowpath)
  292. {  int i,j,row,col,ctcn;
  293.    char buff[120],coflag[2];
  294.    FILE *fp;
  295.    BASE *mybase;
  296.    fp=fopen("db.txt","r");
  297.    fbase = (BASE *)malloc(sizeof(BASE));
  298.    mybase = fbase;
  299.    mybase->next = NULL;
  300.    mybase->no = 0;
  301.    for(NB=0; fgets(buff,120,fp)!=NULL; NB++)
  302.      {  if(NB!=0)
  303.       {
  304.         mybase->next=(BASE*)malloc(sizeof(BASE));
  305.         mybase=mybase->next;
  306.         mybase->no=NB;
  307.         mybase->next=NULL;
  308.       }
  309.  
  310.     sscanf(buff,"#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#\n",
  311.            mybase->MEAN,mybase->KEY[0],mybase->KEY[1],
  312.            mybase->KEY[2],mybase->KEY[3],mybase->DB,coflag,coflag,mybase->COPATH)    ;
  313.     mybase->COFLAG=coflag[0];
  314.     fflush(fp)    ;
  315.      }
  316.     fclose(fp);
  317.     fp=fopen("dbfmenu.prg","w");
  318.     pr("parameters name, flag, coflag\nset talk off\nset color to /w\nclear\n");
  319.     pr("set color to /n\n")    ;
  320.     fprintf(fp,"@6,17 clear to %d, 65\n", 6+NB/2+NB%2+1)    ;
  321.     pr("set color to W+/B\n");
  322.     fprintf(fp,"@5,15 clear to %d, 63\n", 5+NB/2+NB%2+1)    ;
  323.     pr("@0,0 say '***╠φ╝╙,▓σ╚δ,╨▐╕─,╔╛│²,▓Θ╤»***'\n");
  324.     pr("@2,25 say '─·┐╔╢╘╧┬┴╨┐Γ╜°╨╨▓┘╫≈'\n");
  325.     pr("@3,25 say '~~~~~~~~~~~~~~~~~~~~'\n");
  326.     i=0;row=6;col=15;
  327.     while(i<NB)
  328.       {
  329.        mybase=fbase;
  330.        while(mybase->no!=i)
  331.      mybase=mybase->next;
  332.        if(mybase->COFLAG == 'Y' || mybase->COFLAG == 'y')
  333.        {
  334.        fprintf(fp,"flag%-2d=1\n",i+1)    ;
  335.        fprintf(fp,"path%-2d='%s'\n",i+1,mybase->COPATH)    ;
  336.        }
  337.        else
  338.        {
  339.        fprintf(fp,"flag%-2d=0\n",i+1)    ;
  340.        fprintf(fp,"path%-2d='%s'\n",i+1,nowpath)    ;
  341.        }
  342.        fprintf(fp,"@%d,%d say '%2d--%s'\n",row,col,i+1,mybase->MEAN);
  343.        if(col==15) col=45;
  344.        else {col=15;row++;}
  345.        i++;
  346.       }
  347.       pr("pesl='  '\nset color to w+/B\n");
  348.       pr("@22,10 say '╟δ╩Σ╚δ─·╤í╘±╡─┐Γ╡─╨≥║┼, 0 ▒φ ╩╛ ═╦ │÷' get pesl\n");
  349.       pr("read\nset color to W+/N\n");
  350.       fprintf(fp,"num=%d\n",i);
  351.       pr("if pesl='0'\n");
  352.       pr("name='0'\n");
  353.       pr("return\n");
  354.       pr("endif\n");
  355.       pr("do while val(pesl)>num .or. (pesl<>'0' .and. val(pesl)=0)\n");
  356.       pr("@ 22,0 clear\npesl='  '\n");
  357.       fprintf(fp,"@22,10 say '╩Σ╚δ┤φ!╟δ╓╪╨┬╩Σ╚δ (1--%d),or 0 ═╦│÷ ' get pesl \n",i);
  358.       pr("read\n");
  359.       pr("enddo\n");
  360.       pr("pppp=val(pesl)\n");
  361.       pr("pppp=int(pppp)\n");
  362.       pr("do case\n");
  363.       i=0;
  364.       mybase=fbase;
  365.       while(i<NB)
  366.       {
  367.        fprintf(fp,"case pppp=%d\n",i+1);
  368.        fprintf(fp,"name='%s'\nflag=flag%-2d\ncoflag=path%-2d\n",
  369.              mybase->DB,i+1,i+1);
  370.        mybase=mybase->next;
  371.        i++;
  372.       }
  373.       fprintf(fp,"case pppp=0\nname='0'\nreturn\n");
  374.       pr("endcase\n");
  375.       pr("return\n");
  376.       fclose(fp);
  377.     }
  378.  
  379.  
  380.  
  381.  
  382. dela()
  383. {  int i,j;
  384.    for (i=0;i<10;i++)
  385.       for (j=-30000;j<30000;j++) ;
  386. }
  387.  
  388.  
  389.  
  390. getcc()
  391. {  union REGS r;
  392.    r.h.ah=0;
  393.    int86(0x16,&r,&r);
  394.    if (r.h.al==27) exit(0);
  395.    if (r.h.al) return(r.h.al);
  396.    return(r.x.ax);
  397. }
  398.  
  399.  
  400.  
  401. get(i,j,row,col)
  402. int i,j,row,col;
  403. {  int key,c,n=0;
  404.    cursor(row,col);
  405.    printf("   ");
  406.    cursor(row,col);
  407.    while ((key=getcc())!=0x0D)
  408.      {  switch (key)
  409.       {  case 18432 : return('u');
  410.          case 18688 : return('U');
  411.          case 20480 : return('d');
  412.          case 20736 : return('D');
  413.          case 15104 : return('H');
  414.          case    8  : if (n!=0) n=n/10;
  415.               else  {  error();  cursor(row,col);  }
  416.               break;
  417.          default    : if( key>='0' && key<='9' )
  418.                  printf("%c",key);
  419.               n=10*n+key%256-'0';
  420.               break;
  421.       }
  422.      }
  423.    if ((n>j||n<=i)&&n!=0) {  error();
  424.                  get(i,j,row,col);
  425.               }
  426.    else return(n);
  427.    }
  428.  
  429. cursor(int y, int x)
  430. {
  431.   _DH = (unsigned char)y    ;
  432.   _DL = (unsigned char)x    ;
  433.   _AH = (unsigned char)2    ;
  434.   _BH = (unsigned char)0    ;
  435.   geninterrupt(0x10)    ;
  436. }
  437.  
  438. color_puts(char *string, int  color, int row, int col)
  439. {
  440.   _SI = (unsigned int) string    ;
  441.   _DH = (unsigned char) row    ;
  442.   _DL = (unsigned char) col    ;
  443.   _CX = 1    ;
  444.   while(*(( char * ) _SI))
  445.    {
  446.      _AH = (unsigned char) 2    ;
  447.      _BH = (unsigned char) 0    ;
  448.      __int__(0x10)    ;
  449.      ++_DL    ;
  450.  
  451.      _AH = (unsigned char) 9    ;
  452.      _AL = *((char *)_SI)    ;
  453.      _SI++    ;
  454.      _BH = (unsigned char) 0    ;
  455.      _BL = (unsigned char) color    ;
  456.      __int__(0x10)    ;
  457.    }
  458. }
  459.  
  460.  
  461. clear_win(startrow,startcol,endrow,endcol,attribe)
  462. int startrow,startcol;
  463. int endrow,endcol;
  464. int attribe;
  465. {
  466.   _AH = (unsigned char) 6    ;
  467.   _AL = (unsigned char) 0    ;
  468.   _BH = (unsigned char) attribe    ;
  469.   _CH = (unsigned char) startrow    ;
  470.   _CL = (unsigned char) startcol    ;
  471.   _DH = (unsigned char) endrow    ;
  472.   _DL = (unsigned char) endcol    ;
  473.   geninterrupt(0x10)    ;
  474. }
  475.  
  476.  
  477. now_cursor(x,y)
  478. int *x,*y;
  479. {  union REGS r;
  480.    r.h.ah=3;
  481.    r.h.bh=0;
  482.    int86(0x10,&r,&r);
  483.    *x = r.h.dh;
  484.    *y = r.h.dl;
  485.    return;
  486. }
  487.  
  488.  
  489.  
  490.  
  491.  
  492. movcur()
  493. {  union REGS regs;
  494.    regs.h.ah=19;
  495.    regs.h.al=0;
  496.    int86(0x10,®s,®s);
  497. }
  498.  
  499.  
  500.  
  501.  
  502. setcur()
  503. {  union REGS regs;
  504.    regs.h.ah=19;
  505.    regs.h.al=1;
  506.    int86(0x10,®s,®s);
  507. }
  508.  
  509.  
  510.  
  511. error()
  512. {  color_puts("###### ╩Σ╚δ┤φ╬≤! ╟δ╓╪╨┬╘┘╩Σ ######",12,23,15);
  513.    dela();
  514.    color_puts("                                   ",10,23,15);
  515. }
  516.  
  517.  
  518.  
  519.  
  520.  
  521. pass(char *passwd)
  522.  {
  523.   FILE *fp;
  524.   fp=fopen("check.prg","w");
  525.   pr("parameters in\n");
  526.   pr("clear\nset color to w+/B\n");
  527.   fprintf(fp,"password='%s'\n",passwd);
  528.   pr("if len(trim(password))=0 .AND. .not. file('word.mem')\n");
  529.   pr("return\n");
  530.   pr("endif\n");
  531.   pr("if file('word.mem')\n");
  532.   pr("restore from word addi\n");
  533.   pr("endif\n");
  534.   pr("@2,2 say '***┬╝╚δ╬¼╗ñ***'\n");
  535.   pr("cc=0\n");
  536.   pr("do while cc <3\nset color to w+/B\n");
  537.   pr("@9,20 say '╬¼ ╗ñ ╣ª ─▄ ╙ª ╙╔ ╧╡ ═│ │╠ ╨≥ ╘▒ ╩╣ ╙├'\n");
  538.   pr("set color to w+/b\n@11,20 say '╟δ ╩Σ ╚δ ┐┌ ┴ε'\n");
  539.   pr("set color to W+/b\nset cons off\n");
  540.   pr("accept to ppaa\n");
  541.   pr("set cons on\n");
  542.   pr("l1=len(ppaa)\n");
  543.   pr("l2=len(password)\n");
  544.   pr("if l1=l2 .AND. ppaa=password\n");
  545.   pr("@4,0 clear to 20,79\n");
  546.   pr("exit\n");
  547.   pr("endif\n");
  548.   pr("if cc<2\n");
  549.   pr("@17,20 say '┐┌ ┴ε ┤φ ╬≤, ▓╗ ─▄ ╜° ╚δ, ╟δ ╓╪ ╨┬ ╩Σ ╚δ!'\n");
  550.   pr("wait\n");
  551.   pr("set color to W+/b\n@4,0 clear to 21,79\n");
  552.   pr("cc=cc+1\n");
  553.   pr("else\n");
  554.   pr("in=.F.\n");
  555.   pr("return\n");
  556.   pr("endif\n");
  557.   pr("enddo\n");
  558.   pr("return\n");
  559.   fclose(fp);
  560. }
  561.  
  562. m_menu(int *cho,char *aarr)
  563. {
  564.   FILE *fp,*fw,*codef;
  565.   int i,j,k=0,row,col;
  566.   BASE *mybase;
  567.   char *expl[13]={
  568.                   "═╦│÷",
  569.                   "╧╡═│╢¿╥Γ╞┴─╗╕±╩╜",
  570.                   "╙├╗º╢¿╥Γ╞┴─╗╕±╩╜",
  571.                   "┤╙╞Σ╦ⁿ┐Γ╠φ╝╙",
  572.                   "╠⌡╝■╨▐╕─",
  573.                   "╠⌡╝■╔╛│²",
  574.                   "╨▐╕─┐┌┴ε",
  575.                   "┼·┴┐╕ⁿ╨┬",
  576.                   "╩²╛▌▒╕╖▌",
  577.           "╚½▓┐Σ»└└",
  578.                   "╧╡═│╬¼╗ñ╙δ╩²╛▌╫╓╡Σ",
  579.           "╙├╗º└⌐│Σ─ú┐Θ",
  580.           "┤·┬δ╬¼╗ñ"
  581.                 };
  582.   char *pro[13]={
  583.                  " ",
  584.          "amd1.prg",
  585.          "amd2.prg",
  586.          "app.prg",
  587.          "modify.prg",
  588.          "delete.prg",
  589.          "setp.prg",
  590.          "pmod.prg",
  591.          "dcopy.prg",
  592.          "lookall.prg",
  593.          "diction.prg",
  594.          "maintain.prg",
  595.          "mcode.prg"
  596.         };
  597.    fp=fopen("get_in.prg","w");
  598.    pr("set talk off\nset safe off\nset exclusive off\n");
  599.    pr("sele 9\n");
  600.    pr("use\n");
  601. /*   if ((codef=fopen("code.dbf","r"))!=NULL)
  602.       {
  603.       fprintf(fp,"use code exclusive\n");
  604.       fprintf(fp,"inde on trim(fieldname)+trim(fieldcode) to codeinde\n");
  605.       fprintf(fp,"set inde to codeinde\n");
  606.       }
  607.    fclose(codef);*/
  608.    pr("sele 10\n");
  609.    pr("use\n");
  610.    pr("in=.T.\n");
  611.    pr("do check with in\n");
  612.    pr("do while in\n");
  613.    pr("set color to /W\n")    ;
  614.    pr("clear\n");
  615.    for( i=3,j=0; i<13; i++)
  616.     if( cho[i] == 1 )
  617.       j++    ;
  618.    fprintf(fp,"set color to /N\n")    ;
  619.    fprintf(fp,"@ 6,21 clear to %d,62\n",j+11)    ;
  620.    pr("set color to w+/B\n");
  621.    fprintf(fp,"@5,19 clear to %d,60\n",j+10)    ;
  622.    pr("@2,2 say '***┬╝╚δ╬¼╗ñ***'\n");
  623.    pr("set color to w+/B\n");
  624.    row=6;col=25;j=1;
  625. /*   if ((fw=fopen(pro[1],"r"))!=NULL) cho[1]=1;
  626.    else cho[1]=0;
  627.    fclose(fw);
  628.    if ((fw=fopen(pro[2],"r"))!=NULL) cho[2]=1;
  629.    else cho[2]=0;
  630.    fclose(fw);*/
  631.    if(cho[1]==1||cho[2]==1)
  632.    {
  633.      fprintf(fp,"@%d,%d say '***╠φ╝╙,▓σ╚δ,╨▐╕─,╔╛│²,▓Θ╤» (╥╗╠σ╗») ***'\n",row++,col-5);
  634.      row++;
  635.      col=25;
  636.      if(cho[1]==1)
  637.        fprintf(fp,"@%d,%d say '%d. %s'\n",row++,col,j++,expl[1]);
  638.      if(cho[2]==1)
  639.        fprintf(fp,"@%d,%d say '%d. %s'\n",row++,col,j++,expl[2]);
  640.      fprintf(fp,"@%d,%d say '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'\n",row++,col-5);
  641.    }
  642. /*  if ((fw=fopen(pro[3],"r"))!=NULL) cho[3]=1;
  643.   else cho[3]=0;
  644.   fclose(fw);*/
  645.   if(cho[3]==1)
  646.       fprintf(fp,"@%d,%d say '%d. %s'\n",row++,col,j++,expl[3]);
  647.    for(i=4;i<=12;i++)
  648.     {
  649. /*      if ((fw=fopen(pro[i],"r"))!=NULL) cho[i]=1;
  650.       else cho[i]=0;
  651.       fclose(fw);*/
  652.       if(cho[i]==1)
  653.     {
  654.      if(i==10&&col==45) { col=25; row++;}
  655.      fprintf(fp,"@%d,%d say '%x. %s'\n",row,col,j++,expl[i]);
  656.          if (i==10)  col=45;
  657.      if(col==45)
  658.       { col=25;row++;}
  659.      else
  660.         col+=20;
  661.     }
  662.     }
  663.    fprintf(fp,"@%d,%d say '0. %s'\n",row,col,expl[0]);
  664.    pr("choice=' '\n")    ;
  665.    pr("set color to w+/b\n");
  666.    pr("@22,20 say '╟δ ╩Σ ╚δ ─· ╡─ ╤í ╘±  ' get choice\n");
  667.    pr("read\n");
  668.    pr("set color to W+/b\n");
  669.    pr("choice=trim(choice)\n");
  670.    pr("if choice='0'\n");
  671.    pr("exit\n");
  672.    pr("endif\n");
  673.    pr("do case\n");
  674.    for(j=1;j<13;j++)
  675.        if(cho[j]==1)
  676.     {
  677.      fprintf(fp,"case choice='%x'\n",++k);
  678.      fprintf(fp,"do %s\n",pro[j]);
  679.     }
  680.    pr("endcase\n");
  681.    pr("enddo\n");
  682.    pr("clear\n");
  683.    pr("@10,20 say '╒² ╘┌ ╓╪ ╨┬ ╦≈ ╥² , ╟δ ╔╘ ║≥ !'\n");
  684.    pr("@8,17 to 12,53\n");
  685.    pr("sele 8\nuse\nselect 9\n");
  686.    pr("use\n");
  687.    pr("select 10\n");
  688.    pr("use\n");
  689.    pr("return\n");
  690.    fclose(fp);
  691. }
  692.  
  693.  
  694.  
  695. rrcon()
  696. { FILE *fp;
  697.   fp=fopen("rcon.prg","w");
  698.     pr("parameters renu,cb,condition,cs\n");
  699.     pr("if renu>0\n");
  700.     pr("@5,0 clear to 24,79\n");
  701.     pr("row=5\ncol=10\n");
  702.     pr("b=asc('A')+cb-1\n");
  703.     pr("b=chr(b)\n");
  704.     pr("go renu\n");
  705.     pr("fl=FIELD_LEN\n");
  706.     pr("ft=FIELD_TYPE\n");
  707.     pr("fname=FIELD_NAME\n");
  708.     pr("value=space(fl)\n");
  709.     pr("do case\n");
  710.     pr("case ft='L' .or. ft='C'\n");
  711.     pr("fn=fname+'='\n");
  712.     pr("@row,col say fn get value\n");
  713.     pr("read\n");
  714.     pr("if len(trim(value))<>0\n");
  715.     pr("if cb=0\n");
  716.     pr("condition=condition+trim(fname)+'='+\"'\"+value+\"'\"\n");
  717.     pr("else\n");
  718.     pr("condition=condition+b+'->'+trim(fname)+'='+\"'\"+value+\"'\"\n");
  719.     pr("endif\n");
  720.     pr("endif\n");
  721.     pr("row=row+2\n");
  722.     pr("case ft='N'\n");
  723.     pr("condition=condition+'('\n");
  724.     pr("fn=fname+'>'\n");
  725.     pr("@row,col say fn get value\n");
  726.     pr("read\nr=.f.\nrr=.f.\nif len(trim(value))<>0\n");
  727.     pr("if cb=0\n");
  728.     pr("condition=condition+trim(fname)+'>'+value\nr=.t.\n");
  729.     pr("else\n");
  730.     pr("condition=condition+b+'->'+trim(fname)+'>'+value\nr=.t.\nendif\nendif\n");
  731.     pr("value=space(fl)\n");
  732.     pr("fn=fname+'='\n");
  733.     pr("row=row+3\n");
  734.     pr("@row,col say fn get value\n");
  735.     pr("read\nif len(trim(value))<>0\n");
  736.     pr("if r\ncondition=condition+'.OR.'\n");
  737.     pr("endif\n");
  738.     pr("if cb=0\n");
  739.     pr("condition=condition+trim(fname)+'='+value\n");
  740.     pr("else\ncondition=condition+b+'->'+trim(fname)+'='+value\nendif\nrr=.t.\nendif\n");
  741.     pr("value=space(fl)\n");
  742.     pr("fn=fname+'<'\n");
  743.     pr("row=row+3\n");
  744.     pr("@row,col say fn get value\n");
  745.     pr("read\nif len(trim(value))<>0\n");
  746.     pr("if r\ncondition= condition+'.AND.'\n");
  747.     pr("else\nif rr\ncondition=condition+'.OR.'\n");
  748.     pr("endif\nendif\n");
  749.     pr("if cb=0\n");
  750.     pr("condition=condition+trim(fname)+'<'+value\n");
  751.     pr("else\n");
  752.     pr("condition=condition+b+'->'+trim(fname)+'<'+value\nendif\nendif\n");
  753.     pr("row=row+4\n");
  754.     pr("condition=condition+')'\n");
  755.     pr("case ft='D'\n");
  756.     pr("@row,col say fname \n");
  757.     pr("value='  '\n");
  758.     pr("@row+1,col+5 say '>  /  /'\n");
  759.     pr("@row+1,col+6 get value\n");
  760.     pr("read\nr=.f.\nif len(trim(value))<>0\n");
  761.     pr("date=trim(value)\n");
  762.     pr("value='  '\n");
  763.     pr("@row+1,col+9 get value\n");
  764.     pr("read\n");
  765.     pr("date=date+'/'+trim(value)\n");
  766.     pr("value='  '\n");
  767.     pr("@row+1,col+12 get value\n");
  768.     pr("read\n");
  769.     pr("date=date+'/'+trim(value)\n");
  770.         pr("value='ctod('+'\"'+date+'\"'+')'\n");
  771.     pr("if cb=0\n");
  772.     pr("condition=condition+trim(fname)+'>'+value\nr=.t.\n");
  773.     pr("else\n");
  774.     pr("condition=condition+b+'->'+trim(fname)+'>'+value\nr=.t.\nendif\nendif\n");
  775.         pr("value='  '\n");
  776.     pr("@row+2,col+5 say '=  /  /'\n");
  777.     pr("@row+2,col+6 get value\n");
  778.     pr("read\nr=.f.\nif len(trim(value))<>0\n");
  779.     pr("date=trim(value)\n");
  780.     pr("value='  '\n");
  781.     pr("@row+2,col+9 get value\n");
  782.     pr("read\n");
  783.     pr("date=date+'/'+trim(value)\n");
  784.     pr("value='  '\n");
  785.     pr("@row+2,col+12 get value\n");
  786.     pr("read\n");
  787.     pr("date=date+'/'+trim(value)\n");
  788.     pr("value='ctod('+'\"'+date+'\"'+')'\n");
  789.     pr("if r\n");
  790.     pr("condition=condition+'.AND.'\n");
  791.     pr("endif\n");
  792.     pr("if cb=0\n");
  793.     pr("condition=condition+trim(fname)+'='+value\nr=.t.\n");
  794.     pr("else\n");
  795.     pr("condition=condition+b+'->'+trim(fname)+'='+value\nr=.t.\nendif\nendif\n");
  796.         pr("value='  '\n");
  797.     pr("@row+3,col+5 say '<  /  /'\n");
  798.     pr("@row+3,col+6 get value\n");
  799.     pr("read\nr=.f.\nif len(trim(value))<>0\n");
  800.     pr("date=trim(value)\n");
  801.     pr("value='  '\n");
  802.     pr("@row+3,col+9 get value\n");
  803.     pr("read\n");
  804.     pr("date=date+'/'+trim(value)\n");
  805.     pr("value='  '\n");
  806.     pr("@row+3,col+12 get value\n");
  807.     pr("read\n");
  808.     pr("date=date+'/'+trim(value)\n");
  809.     pr("value='ctod('+'\"'+date+'\"'+')'\n");
  810.     pr("if r\n");
  811.     pr("condition=condition+'.AND.'\n");
  812.     pr("endif\n");
  813.     pr("if cb=0\n");
  814.     pr("condition=condition+trim(fname)+'<'+value\nr=.t.\n");
  815.     pr("else\n");
  816.     pr("condition=condition+b+'->'+trim(fname)+'<'+value\nr=.t.\nendif\nendif\n");
  817.     pr("endcase\n");
  818.     pr("con=' '\n");
  819.     pr("@20,10 say '╟δ ╢¿ ╥σ ╠⌡ ╝■ ╫╓ ╢╬ ╝Σ ╡─ ┴¼ ╜╙ ╣╪ ╧╡ ' get con\n");
  820.     pr("@21,10 say '1.AND  2.OR  3.NOT  4.AND NOT  5.OR NOT  0.═╦ │÷'\n");
  821.     pr("read\n");
  822.     pr("do case\n");
  823.     pr("case con='1'\n");
  824.     pr("condition=condition+'.AND.'\n");
  825.     pr("case con='2'\n");
  826.     pr("condition=condition+'.OR.'\n");
  827.     pr("case con='3'\n");
  828.     pr("condition=condition+'.AND.'\n");
  829.     pr("case con='4'\n");
  830.     pr("condition=condition+'.AND..NOT.'\n");
  831.     pr("case con='5'\n");
  832.     pr("condition=condition+'.OR..NOT.'\n");
  833.     pr("case con='0'\n");
  834.     pr("cs=.f.\n");
  835.     pr("endcase\n");
  836.     pr("@3,0 say condition\n");
  837.     pr("return\n");
  838.     fclose(fp);
  839. }
  840.  
  841.  
  842. /*cr_ndx(char *aarr)
  843. {
  844.   int i=0;
  845.   BASE *mybase;
  846.   FILE *fp;
  847.   fp=fopen("cr_ndx.prg","w");
  848.   while(i<NB)
  849.       {
  850.        mybase=fbase;
  851.        while(mybase->no!=i)
  852.      mybase=mybase->next;
  853.        fprintf(fp,"if .not. file('%si%s.ndx')\n",aarr,mybase->DB);
  854.        fprintf(fp,"select 1\n");
  855.        pr("clear\n");
  856.        pr("set color to w+/b\n");
  857.        pr("@10,20 say '╒² ╘┌ ╜¿ ╦≈ ╥² , ╟δ ╔╘ ║≥ !'\n");
  858.        pr("@8,17 to 12,50\n");
  859.        pr("set color to W+/b\n");
  860.        fprintf(fp,"use %s%s\n",mybase->COPATH,mybase->DB);
  861.        fprintf(fp,"index on %s to %si%s\n",mybase->KEY,mybase->COPATH,mybase->DB);
  862.        pr("endif\n");
  863.        i++;
  864.       }
  865.   fclose(fp);
  866.  }*/
  867.  
  868.  
  869. position(int choice, int *currow, int *curcol)
  870. {
  871.         if(choice==1||choice==2)
  872.            {
  873.         *currow = 8+choice    ;
  874.         *curcol = 20    ;
  875.            }
  876.             if(choice==3)
  877.           {
  878.          *currow = 12    ;
  879.          *curcol = 20    ;
  880.           }
  881.         if(choice>=4&&choice<10)
  882.            {
  883.         *currow = choice/2+11    ;
  884.         *curcol = 20+(choice%2)*20    ;
  885.            }
  886.         if (choice==11||choice==10)
  887.           {
  888.         *currow = 7+choice    ;
  889.         *curcol = 20    ;
  890.           }
  891. }
  892.  
  893. /* --- selete a choice from  two term ----------    */
  894. /*       if selete a return 1                */
  895. /*       else return 2                                  */
  896. /*-----------------------------------------------    */
  897. selete(char *a, char *b, int row, int acol, int bcol, char color)
  898. {
  899.   int in,bb=1    ;
  900.  
  901.   color_puts(a,0|15,row,acol)    ;
  902.   color_puts(b,color,row,bcol)    ;
  903.   for(;;)
  904. {
  905.   in=getcc()    ;
  906.   switch(in)
  907.    {
  908.      case 19712 :
  909.           color_puts(a,color,row,acol)    ;
  910.           color_puts(b,0|15,row,bcol)    ;
  911.           bb=2;
  912.           continue;
  913.      case 19200 :
  914.           color_puts(a,0|15,row,acol)    ;
  915.           color_puts(b,color,row,bcol)    ;
  916.           bb=1    ;
  917.           continue;
  918.      case 13 :
  919.           return(bb);
  920.    }
  921.   }
  922. }
  923.  
  924.  
  925.  
  926. /*---------------- This is a line editer -----------------------*/
  927. /*        row,col     posite the starting cursor         */
  928. /*        color       denote the color of the        */
  929. /*                  blackbord and the  character    */
  930. /*        buff        line-editer's interal denoting    */
  931. /*--------------------------------------------------------------*/
  932. line_edit(int row, int col, int color, char *buff, int len)
  933. {
  934.     int in_number=0, ins=0, i, j, flag=0    ;
  935.     char *str    ;
  936.     union {
  937.         int i;
  938.         char ch[2];
  939.           }key;
  940.  
  941.     len -= 2    ;
  942.     color_puts(buff, color, row, col )    ;
  943.     while(1)
  944.       {
  945.         cursor( row, col+in_number )    ;
  946.         key.i = bioskey(0)    ;
  947.         if ((key.i&0x00ff)==13) key.i=key.i&0x00ff;
  948.         switch(key.i)
  949.           {
  950.             case 15104:    /*    F1    */
  951.                 break    ;
  952.  
  953.             case 19200:    /*    left arrow    */
  954.                 if(in_number)
  955.                     in_number=confirm(buff,in_number-1);
  956.                 cursor( row, col+in_number )    ;
  957.                 break    ;
  958.  
  959.             case 19712:    /*    right arrow    */
  960.                 if( buff[in_number]=='\0' )
  961.                     buff[in_number]=' '    ;
  962.                 if((unsigned)buff[in_number]>128 && (unsigned)buff[in_number]>128)
  963.                     in_number+=2    ;
  964.                 else
  965.                     in_number++    ;
  966.                 if(in_number>len)
  967.                     in_number=0    ;
  968.                 break    ;
  969.  
  970.             case 29440:    /*    Ctrl_left    */
  971.                 in_number=confirm(buff,in_number-8)    ;
  972.                 if( in_number <0 )
  973.                     in_number=0    ;
  974.                 break    ;
  975.  
  976.             case 29696:    /*    ctrl_right    */
  977.                 in_number = confirm(buff, in_number+8)    ;
  978.                 if( in_number>(i=strlen(buff)))
  979.                     in_number = i    ;
  980.                 break    ;
  981.  
  982.             case 18176:    /*    Home    */
  983.                 in_number=0    ;
  984.                 cursor( row, col )    ;
  985.                 break    ;
  986.  
  987.             case 20224:    /*    End    */
  988.                 in_number=strlen(buff)    ;
  989.                 cursor( row, col+in_number )    ;
  990.                 break    ;
  991.  
  992.             case 21248:     /*    Del    */
  993.                 if( in_number==strlen(buff) )
  994. /*                    printf("\007");*/    ;
  995.                 else
  996.                   {
  997.                     if( (unsigned)buff[in_number]>128 && (unsigned)buff[in_number]>128 )
  998.                       {
  999.                         for( i=in_number+2,j=strlen(buff); i<=j; i++ )
  1000.                             buff[i-2]=buff[i]    ;
  1001.                         color_puts( "  ", color, row, col+j-2 )    ;
  1002.                       }
  1003.                     else
  1004.                       {
  1005.                         for( i=in_number+1,j=strlen(buff); i<=j; i++)
  1006.                             buff[i-1] = buff[i]    ;
  1007.                         color_puts( " ", color, row, col+j-1 )    ;
  1008.                       }
  1009.                     str = &buff[in_number]    ;
  1010.                     color_puts(str, color, row, col+in_number)    ;
  1011.                   }
  1012.                 break    ;
  1013.  
  1014.             case 3592:    /*    Backspace    */
  1015.                 if(in_number)
  1016.                   {
  1017.                     if( (unsigned)buff[in_number-1]>128 && (unsigned)buff[in_number-2]>128 && in_number>1 )
  1018.                       {
  1019.                         for( i=in_number,j=strlen(buff); i<=j; i++)
  1020.                             buff[i-2] = buff[i]    ;
  1021.                         in_number-=2    ;
  1022.                         color_puts( "  ", color, row, col+j-2 )    ;
  1023.                       }
  1024.                     else
  1025.                       {
  1026.                         for( i=in_number,j=strlen(buff); i<=j; i++)
  1027.                             buff[i-1] = buff[i]    ;
  1028.                         in_number--    ;
  1029.                         color_puts( " ", color, row, col+j-1 )    ;
  1030.                       }
  1031.                     str = &buff[in_number]    ;
  1032.                     color_puts( str, color, row, col+in_number )    ;
  1033.                   }
  1034.                 else
  1035.                     /*  printf("\007"); */    ;
  1036.                 break    ;
  1037.  
  1038.             case 20992:    /*    Ins    */
  1039.                 ins=(ins?0:1)    ;
  1040.                 break    ;
  1041.  
  1042.             case 13:    /*    7181  Enter    */
  1043.                 for( i=strlen(buff)-1; buff[i]==' '&&i>=0; i--);
  1044.                 buff[i+1]='\0'    ;
  1045.                 return    ;
  1046.  
  1047.             default:
  1048.                 if( ins )
  1049.                   {
  1050.  
  1051.                     if( strlen(buff)>=len || key.ch[0]==0)
  1052.                     /*    printf("\007")    ;    */;
  1053.                     else
  1054.                       {
  1055.                         for( i=strlen(buff); i>in_number; i--)
  1056.                             buff[i] = buff[i-1]    ;
  1057.                         buff[in_number] = key.ch[0]    ;
  1058.                         if( (unsigned)key.ch[0]>128 )
  1059.                            if( flag==0 )    /*    the forehalf of chinese    */
  1060.                              {
  1061.                             flag++    ;
  1062.                             in_number++    ;
  1063.                              }
  1064.                            else
  1065.                              {
  1066.                             flag--    ;
  1067.                             str = &buff[in_number-1]    ;
  1068.                             color_puts( str, color, row, col-1+in_number++ )    ;
  1069.                              }
  1070.                         else
  1071.                           {
  1072.                             str = &buff[in_number]    ;
  1073.                             color_puts( str, color,row, col+in_number++ )    ;
  1074.                           }
  1075.                       }
  1076.                   }
  1077.                 else
  1078.                   {
  1079.                     if( in_number>=len || key.ch[0]==0 )
  1080.                     /*    printf("\007")    ;    */;
  1081.                     else
  1082.                       {
  1083.                         buff[in_number] = key.ch[0]    ;
  1084.                         str = &buff[in_number]    ;
  1085.                         color_puts( str, color, row, col+in_number++ )    ;
  1086.                       }
  1087.                   }
  1088.  
  1089.          }
  1090.     }
  1091. }
  1092.  
  1093.  
  1094. /*-----  if the charater is chinese , and then the cursor must be in the first position----*/
  1095. confirm(char *s, int col)
  1096. {
  1097.     int i    ;
  1098.     if( (unsigned)s[col]<128)
  1099.         return(col)    ;
  1100.     for(i=col; (unsigned)s[i]>128&&i>0; i--)    ;
  1101.     if((col-i)%2!=0)
  1102.         return(col)    ;
  1103.     else
  1104.         return(col-1)    ;
  1105. }
  1106.  
  1107.