Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Grumpfish Library 3.2 - <b>menuv()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
MENUV()

    MENUV() will paint a vertical bounce-bar menu on the screen. It
    requires a bit more programming than the horizontal light-bar menu,
    but is probably worth it.  For one thing, MENUV() will do all of the
    grump-work insofar as centering the box and messages are concerned.

    Secondly, you may also pass it procedure names corresponding to each
    menu option.  When an option is selected, the procedure name tied to
    it will be executed.  After that procedure is finished, control will
    pass back to the menu.  This can really clean up your programs in a
    hurry, because you can kiss a number of DO CASE or IF..ELSEIF code
    blocks goodbye.

    Syntax

    MENUV(<array> [,<title>, <box type>, <box color>, <title color>])

    Required Parameter

    <array> is a character string representing the name of the array
    that contains the menu options.  Optionally, this array may also
    contain messages and procedure names corresponding to each menu
    option.

    Optional Parameters

    <title> is a character string representing the menu title.  If you
    do not pass this parameter, the default title will be "Menu" (wow).

    <box type> is an integer between 1 and 15 corresponding to the type
    of box you wish to use.  Box types 1-5 are listed below:

    Box Number           Box Type

        1                  Double
        2                  Single
        3            Double Horiz., Single Vert.
        4            Single Horiz., Double Vert.
        5                 Thick Line

    Boxes 6-10 and 11-15 are identical to boxes 1-5, except that 6-10
    will have an additional drop shadow (simulating a three-dimensional
    effect) and 11-15 will have two drop shadows for super-duper 3-D.

    <box color> is a character string containing the color to use for
    the box.  The default color is white on black for unselected options
    and inverse (black on white) for the bounce bar.

    <title color> is a character string containing the color to use for
    the menu title.  The default is white on black.

    Return Value

    MENUV() returns a numeric value representing the selected menu
    option.  However, if you have included procedure names in the array,
    this return value will likely be irrelevant.

    Usage

    The first thing you must do is to declare and initialize an array
    containing the desired menu options (and corresponding messages and
    procedure names, if desired). If you wish to have messages, you must
    separate the menu option from the message with a dollar sign ($).
    If you wish to use procedure names, these MUST follow the messages
    and must be separated from them with a karat ().  Failure to use
    these separators will cause inconsistent results!

    When using messages, make sure that you have SET MESSAGE before
    calling MENUV(), or else your messages will be displayed somewhere
    in never-never-land.  You may also wish to SET WRAP ON, so that you
    can go from the bottom option to the top one and vice versa.

    If you pass procedure names, MENUV() will go into an "endless" loop
    that will terminate when you either press Esc, or select the last
    option.  This is based on the assumption that the exit or quit
    option is usually at the bottom of the menu.  However, if you do not
    like this configuration, you have the source code and my blessing to
    change it to suit your needs.

    Sample Usage

    In this example, MENUV() calls all of the procedures directly, thus
    saving you the trouble of writing the DO CASE structure.

    PRIVATE mainmenu[5]        && array to hold menu options/msgs/procs
    mainmenu[1] = '  Data Entry  $Add and edit information^DATA_ENTRY'
    mainmenu[2] = 'Output Reports$Share your information^REPORTS'     
    mainmenu[3] = '  Utilities   $Reindex files etc.^UTILITIES'       
    mainmenu[4] = '  Mastermind  $What a bloody waste of time!!^POPMM'
    mainmenu[5] = '     Quit     $Exit to DOS'                         
    sel = MENUV(mainmenu, 'Main Menu', 11, '+W/RB,+W/N', '+W/B')       
    QUIT                                                               

    FUNCTION data_entry
    |                  
    |                  
    RETURN whatever    

    FUNCTION reports   
    |                  
    |                  
    RETURN whatever    

    FUNCTION utilities 
    |                  
    |                  
    RETURN whatever    

    FUNCTION popmm     
    |                  
    |                  
    RETURN whatever    

    Clipper 5.0 Notes

     MenuV() now expects a multi-dimensional array rather than a messy
     delimited character string.  The 5.0 equivalent of the example
     above is:

     mainmenu := { { 'Data Entry', 'Edit info', 'DATA_ENTRY()'} , ;
                   { 'Reports', 'Hard copies', 'REPORTS()' }  , ;
                   { 'Utilities', 'Miscellaneous', 'UTILITIES()' } , ;
                   { 'Mastermind', 'Waste time', 'POPMM()' } , ;
                   { 'Quit', 'Exit to DOS'} }

     To skip anything, just leave it NIL.  For example:

                   { 'Reports', , }  , ;

     will display Reports as a menu option, but will not display an
     accompaying message nor execute any function upon selection.

See Also: LITE_MENU() MENUH()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson