home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / prg_hlp.zip / MENUPROC.PRG < prev    next >
Text File  |  1987-04-07  |  12KB  |  566 lines

  1. **********************************************************************
  2. *                                                                                            *
  3. *                                S. Robert Davidoff                                    *
  4. *                          MENUPROC.PRG                              *
  5. *                                                                                            *
  6. *                                                                                            *
  7. **********************************************************************
  8. *...This is a procedure file
  9. *Banner
  10. *choice
  11. *center
  12. *F1
  13. *Lightbar
  14. *print_set
  15. *first_cap
  16. *no_zero
  17.  
  18. **********************************************************************
  19. *                                                                                            *
  20. *                                LIGHTBAR PROCEDURE                                    *
  21. *      This procedure creates verticle lightbar menus                   *
  22. *                                                                                            *
  23. **********************************************************************
  24. procedure lightbar
  25.   parameters items,x1,y1,width,entry1,entry2,entry3,entry4,entry5,entry6,entry7,entry8,entry9,entry10
  26.   answer = space(1)
  27.   store x1 to x1m
  28.   store y1 to y1m
  29.   store "N/W" to frm_colorm               && Inverse
  30.   store "W/N" to mnu_colorm               && normal
  31.   store "N/W" to bar_colorm               && inverse
  32.  
  33. CALL CURSW WITH "OFF"
  34.   * display menu and process the keys pressed *
  35.   set color to &frm_colorm
  36.   @ x1m,y1m to (x1m+1+items),(y1m+width+1) double
  37.   set color to &mnu_colorm
  38.  
  39.   * Enter menu lines to screen *
  40.   for n=1 to items                                               && FOR-NEXT LOOP
  41.           nstring = iif(n = 10,str(n,2),str(n,1))
  42.         menu_line = iif(entry&nstring = "XXXX",space(width),entry&nstring)
  43.           @ x1+n,y1+1 say menu_line  
  44.   next
  45.   n=x1+1
  46.   k=1
  47.   control= .T.
  48.   do while control=.T.
  49.        kstring = iif(k = 10,str(k,2),str(k,1))
  50.    store entry&kstring to menu_line
  51.  
  52.     * display current inverse lightbar *
  53.     set color to &bar_colorm
  54.     @ n,y1+1 say upper(menu_line)
  55.      
  56.     * wait for key to be pressed *
  57.     selection = 0
  58.     do while selection=0
  59.       selection=inkey()
  60.     enddo
  61.  
  62.     * redisplay hilite area back to normal *
  63.     if selection<>13
  64.       set color to &mnu_colorm
  65.       @ n,y1+1 say upper(menu_line)
  66.     endif
  67.  
  68.     do case
  69.       * down arrow was pressed *
  70.       case selection=24
  71.         k=k+1
  72.         n=n+1
  73.         if k>items
  74.           n=x1+1
  75.           k=1
  76.         endif
  77.           loop
  78.       * up arrow was pressed *
  79.       case selection=5
  80.         k=k-1
  81.         n=n-1
  82.         if k<1
  83.           n=x1+items
  84.           k=items
  85.         endif
  86.           loop
  87.           
  88.           * Home or page up was pressed *
  89.         case selection = 1 .or. selection = 18
  90.         k=1
  91.         n=x1+1
  92.         loop
  93.         
  94.         * End or page down was pressed *
  95.         case selection = 6 .or. selection = 3
  96.         k = items
  97.         n = x1+items
  98.         loop
  99.         
  100.         
  101.         * F1 was pressed *
  102.         case selection = 28
  103.         do help with A, B, C
  104.         loop
  105.         
  106.         * F2 was pressed *
  107.         case selection = -1
  108.         do prg_hlp with A, B, C
  109.         loop
  110.         
  111.         
  112.         
  113.       case selection = 48               && 0 key pressed
  114.             k=0
  115.             control=.F.
  116.         loop
  117.         
  118.         case selection = 49               && 1 key pressed
  119.             k=1
  120.             control=.F.
  121.         loop
  122.           
  123.         case selection = 50               && 2 key pressed
  124.             k=2
  125.             control=.F.
  126.         loop
  127.         
  128.         case selection = 51               && 3 key pressed
  129.             IF 3 > items
  130.                 loop
  131.             endif
  132.             k=3
  133.             control=.F.
  134.         loop
  135.         
  136.         case selection = 52               && 4 key pressed
  137.             IF 4 > items
  138.                 loop
  139.             endif
  140.             k=4
  141.             control=.F.
  142.         loop
  143.         
  144.         case selection = 53               && 5 key pressed
  145.             IF 5 > items
  146.                 loop
  147.             endif
  148.             k=5
  149.             control=.F.
  150.         loop
  151.         
  152.         case selection = 54               && 6 key pressed
  153.             IF 6 > items
  154.                 loop
  155.             endif
  156.             k=6
  157.             control=.F.
  158.         loop
  159.         
  160.         case selection = 55               && 7 key pressed
  161.             IF 7 > items
  162.                 loop
  163.             endif
  164.             k=7
  165.             control=.F.
  166.         loop
  167.         
  168.         case selection = 56               && 8 key pressed
  169.             IF 8 > items
  170.                 loop
  171.             endif
  172.             k=8
  173.             control=.F.
  174.         loop
  175.             
  176.         case selection = 57               && 9 key pressed
  177.             IF 9 > items
  178.                 loop
  179.             endif
  180.             k=9
  181.             control=.F.
  182.         loop
  183.         * <cr> was pressed *
  184.       case selection=13
  185.         control=.F.
  186.         loop
  187.         case (selection = 121) .or. (selection = 89)        && Y key pressed
  188.             answer = "Y"
  189.             exit
  190.         
  191.         case (selection = 110) .or. (selection = 78)        && N key pressed
  192.             answer = "N"
  193.             exit
  194.     endcase  
  195.   enddo
  196.   if k >= items
  197.         selection = 0
  198.   else
  199.          selection=k
  200.   endif
  201.   * return video attributes to normal *
  202.   set color to w/n
  203.   CALL CURSW WITH "ON"
  204.   return
  205.  
  206. **********************************************************************
  207. *                                                                    *
  208. *          This procedure creates horizontal light bar menus         *
  209. *                                                                    *
  210. **********************************************************************
  211. PROCEDURE H_LIGHT
  212.   parameters items,x1,y1,width,entry1,entry2,entry3,entry4,entry5,entry6,entry7,entry8,entry9,entry10,lstring
  213.   answer = space(1)
  214.   width = width + 4
  215.   mlength = items *width
  216.   y1 = (78-mlength)/2
  217.   set color to
  218.   * Enter menu lines to screen *
  219.   CALL CURSW
  220.   N = 1
  221.   DO WHILE N <= items 
  222.           nstring = iif(n = 10,str(n,2),str(n,1))
  223.         menu_line = iif(entry&nstring = "XXXX",space(width),entry&nstring)
  224.           @ x1,y1+(N*WIDTH)-width say menu_line  
  225.         N = N + 1
  226.   ENDDO
  227.   n=1
  228.   k=1
  229.   control= .T.
  230.   do while control
  231.        kstring = iif(k = 10,str(k,2),str(k,1))
  232.    store entry&kstring to menu_line
  233.  
  234.     * display current inverse lightbar *
  235.     set color to I
  236.     @ X1,y1+(N*width)-width say trim(upper(menu_line))
  237.      
  238.     * wait for key to be pressed *
  239.     selection = 0
  240.     do while selection=0
  241.       selection=inkey()
  242.     enddo
  243.  
  244.     * redisplay hilite area back to normal *
  245.     if selection<>13
  246.       set color to
  247.       @ X1,y1+(N*width)-width say trim(upper(menu_line))
  248.     endif
  249.  
  250.     do case
  251.       * right arrow was pressed *
  252.       case selection=4
  253.         k=k+1
  254.         n=n+1
  255.         if k>items
  256.           n=1
  257.           k=1
  258.         endif
  259.           loop
  260.       * left arrow was pressed *
  261.       case selection=19
  262.         k=k-1
  263.         n=n-1
  264.         if k<1
  265.           n=items
  266.           k=items
  267.         endif
  268.           loop
  269.         
  270.         * Home was pressed *
  271.         case selection = 1
  272.         k=1
  273.         n=1
  274.         loop
  275.         
  276.         * End was pressed *
  277.         case selection = 6
  278.         k = items
  279.         n = items
  280.         loop
  281.         
  282.         * F1 was pressed *
  283.         case selection = 28
  284.         do help with A, B, C
  285.         loop
  286.         
  287.         * F2 was pressed *
  288.         case selection = -1
  289.         do prg_hlp with A, B, C
  290.         loop
  291.         
  292.         
  293.       case selection = 48               && 0 key pressed
  294.             k=0
  295.             control=.F.
  296.         loop
  297.         
  298.         case selection = 49               && 1 key pressed
  299.             k=1
  300.             control=.F.
  301.         loop
  302.           
  303.         case selection = 50               && 2 key pressed
  304.             k=2
  305.             control=.F.
  306.         loop
  307.         
  308.         case selection = 51               && 3 key pressed
  309.             IF 3 > items
  310.                 loop
  311.             endif
  312.             k=3
  313.             control=.F.
  314.         loop
  315.         
  316.         case selection = 52               && 4 key pressed
  317.             IF 4 > items
  318.                 loop
  319.             endif
  320.             k=4
  321.             control=.F.
  322.         loop
  323.         
  324.         case selection = 53               && 5 key pressed
  325.             IF 5 > items
  326.                 loop
  327.             endif
  328.             k=5
  329.             control=.F.
  330.         loop
  331.         
  332.         case selection = 54               && 6 key pressed
  333.             IF 6 > items
  334.                 loop
  335.             endif
  336.             k=6
  337.             control=.F.
  338.         loop
  339.         
  340.         case selection = 55               && 7 key pressed
  341.             IF 7 > items
  342.                 loop
  343.             endif
  344.             k=7
  345.             control=.F.
  346.         loop
  347.         
  348.         case selection = 56               && 8 key pressed
  349.             IF 8 > items
  350.                 loop
  351.             endif
  352.             k=8
  353.             control=.F.
  354.         loop
  355.             
  356.         case selection = 57               && 9 key pressed
  357.             IF 9 > items
  358.                 loop
  359.             endif
  360.             k=9
  361.             control=.F.
  362.         loop
  363.         * <cr> was pressed *
  364.       case selection=13
  365.         control=.F.
  366.         loop
  367.         
  368.         case upper(chr(selection)) $ lstring
  369.             mpos = AT((upper(chr(selection))),lstring)
  370.             k = mpos
  371.             exit
  372.  
  373.     endcase  
  374.   enddo
  375.   if k >= items
  376.         selection = 0
  377.   else
  378.          selection=k
  379.   endif
  380.   * return video attributes to normal *
  381.   set color to
  382.   CALL CURSW
  383.   return
  384.  
  385. *********************************************************************
  386.  
  387. Procedure F1                           && help box
  388.     parameter string
  389.     private mlen
  390.     string = "F1- " + string
  391.     mlen = len(trim(string))
  392.     @ 19,(37 - (mlen/2)) to 21,(42 + (mlen/2))
  393.     set color to I
  394.     @ 20,(39-(mlen/2)) say space(mlen+2)
  395.     @ 20,(40-(mlen/2)) say string
  396.     set color to
  397. return
  398.  
  399. **********************************************************************
  400.  
  401. procedure print_set
  402. do clearit with 4,1,23,78
  403. mvar = iif(isprinter(),"ON","OFF")
  404. @ 8,20 to 17,60 double
  405. if mvar = "ON"
  406.     set color to I
  407.     do center with 12, "PRINTER IS ON-LINE  "
  408. else
  409.     set color to I*
  410.     do center with 11, "THE PRINTER IS OFF  "
  411.     do center with 12, "TURN PRINTER ON NOW "
  412. endif
  413. if .not. tof()
  414.     eject
  415. endif
  416. set color to
  417. @ 23,5
  418. wait
  419. return
  420.  
  421. **********************************************************************
  422.  
  423. procedure BANNER
  424.     Parameter BANNER
  425.     clear
  426.     @ 2,2 say cdow(date())
  427.     @ 2,(78-len(banner))/2 say banner
  428.     @ 2,78-len(cdate) say cdate
  429.     @ 3,1 say BAR
  430. return
  431.  
  432. **********************************************************************
  433.  
  434. procedure CENTER
  435.     Parameters row, string
  436.     @ row,(78-len(string))/2 say string
  437. return
  438.         
  439. **********************************************************************
  440.  
  441. procedure CHOICE
  442.     Parameters INSTRUCTION, RANGE
  443.     @ 22,1 SAY BAR
  444.     choice = " "
  445.     do while .not. choice $ RANGE
  446.         @23,2
  447.         wait INSTRUCTION to choice
  448.     enddo
  449. return
  450.  
  451. **********************************************************************
  452.  
  453. function first_cap
  454. parameters fstring
  455. ms_len = len(fstring)
  456. if ms_len = 0
  457.     return(" ")
  458. else
  459.     a = upper(substr(fstring,1,1))
  460.     b = lower(substr(fstring,2,ms_len))
  461.     fstring = a + b
  462. endif
  463. return(fstring)
  464.  
  465. **********************************************************************
  466.  
  467.  
  468. procedure five_dig
  469. parameter mdigit
  470. mdigit = alltrim(mdigit)
  471. do case
  472.     case len(mdigit) = 1
  473.         mdigit = "0000" + mdigit
  474.  
  475.     case len(mdigit) = 2
  476.         mdigit = "000" + mdigit
  477.         
  478.     case len(mdigit) = 3
  479.         mdigit = "00" + mdigit
  480.         
  481.     case len(mdigit) = 4
  482.         mdigit = "0" + mdigit
  483.         
  484.     endcase
  485. return
  486.  
  487. **********************************************************************
  488.  
  489. function no_zero
  490.                         * strips leading zeros off a character string *
  491. parameters mstring
  492. mstring = ltrim(mstring)
  493. mlength = 0
  494. mlength = len(trim(mstring))
  495. if mlength = 0
  496.     return("0")
  497. endif    
  498. counter = 1
  499. do while  counter < mlength
  500. if substr(mstring,1,1) = "0"
  501.     mstring = substr(mstring,2,(mlength-(counter-1)))    
  502.     counter = counter + 1
  503. else
  504.     exit
  505. endif
  506. enddo
  507. return(mstring)
  508.  
  509. **********************************************************************
  510.  
  511. FUNCTION DBF
  512. * Syntax: DBF()
  513. * Return: The alias of the currently selected database.
  514. * Note..: Supposed to return the name of the currently selected database file.
  515. *
  516. RETURN ALIAS()
  517.  
  518. **********************************************************************
  519. FUNCTION ALLTRIM
  520. PARAMETERS cl_string
  521. RETURN LTRIM(TRIM(cl_string))
  522.  
  523. **********************************************************************
  524. procedure print
  525. do clearit with 4,1,23,78
  526. mvar = iif(isprinter(),"ON","OFF")
  527. @ 8,20 to 17,60 double
  528. if mvar = "ON"
  529.     set color to I
  530.     do center with 12, "PRINTER IS ON-LINE  "
  531. else
  532.     set color to I*
  533.     do center with 11, "THE PRINTER IS OFF  "
  534.     do center with 12, "TURN PRINTER ON NOW "
  535. endif
  536. if .not. tof()
  537.     eject
  538. endif
  539. set color to
  540. @ 23,5
  541. wait
  542. return
  543.  
  544. **********************************************************************
  545. function TOF
  546. if pcol() = 0 .and.  prow() = 0
  547.     return(.T.)
  548. else
  549.     return(.F.)
  550. endif
  551.  
  552. procedure hlp_mes
  553. parameters mstring
  554. @ 0,0 clear
  555. do center with 12, mstring
  556. set color to I*
  557. @ 0,0 to 24,79 double
  558. @ 1,1 to 23,78 double
  559. set color to
  560. inkey(7)
  561. return
  562.  
  563.  
  564. **************************** EOF *************************************
  565. **********************************************************************
  566.