FT Menus – Prompts

 A_CHOICE()       Psuedo function to simplify FT_ACH2TB()
 FT_ACH2TB()      Replace ACHOICE() with a Tbrowse object & multiple features.
 FT_ADDER()       Pop up a simple calculator
 FT_BLINK()       Display a blinking message on the screen
 FT_BRWSWHL()     Browse an indexed database limited to a while condition
 FT_CLRSEL()      User Selectable Colour Routine
 FT_DISPMSG()     Display a message and optionally waits for a keypress
 FT_FILL()        Declare menu options for FT_MENU1()
 FT_MENU1()       Pulldown menu system
 FT_MENU2()       Vertical lightbar menu
 FT_MENUTO()      Execute light bar menu using prompts created with @...PROMPT
 FT_PENDING()     Display same-line pending messages after a wait.
 FT_PICKDAY()     Picklist of days of week
 FT_PROMPT()      Define a menu item for use with FT_MenuTo()
 FT_SLEEP()       Wait for a specified amount of time
 FT_XBOX()        Display a self-sizing message box and message

FT_XBOX

FT_XBOX()
 Display a self-sizing message box and message

 Syntax

      FT_XBOX( [ <cJustType> ], [ <cRetWait> ], [ <cBorType> ],   ;
               [ <cBorColor> ], [ <cBoxColor> ], [ <nStartRow> ], ;
               [ <nStartCol> ], <cLine1>,  <cLine2>, <cLine3>,    ;
               <cLine4>, <cLine5>, <cLine6>, <cLine7>, <cLine8> ) -> NIL

 Arguments

     <cJustType> is a character indicating the type of text justification.
     "L" or "l" will cause the text to be left-justified in the box.
     Centered text is the default.

     <cRetWait> is a character which determines if the function will wait
     for a keypress after displaying the box.  "W" or "w" will cause the
     function to wait for a keypress before returning control to the
     calling routine.  Not waiting is the default

     <cBorType> is a character which determines whether a single or double
     border will be displayed.  "D" or "d" will cause a double border to
     be displayed.  A single border is the default.

     <cBorColor> is a character string denoting the border color.  'N/W' is
     the default if this parameter is not a string.

     <cBoxColor> is a character string denoting the text color.  'W/N' is
     the default if this parameter is not a string.

     <nStartRow> is a number denoting the starting row.  If '99' is passed,
     the box is centered vertically.  If necessary, nStartRow is decreased
     so the entire box can be displayed.

     <nStartCol> is a number denoting the starting column.  If '99' is passed,
     the box is centered horizontally.  If necessary, nStartCol is decreased
     so the entire box can be displayed.

     <cLine1> thru <cLine8> are 1 to 8 character strings to be displayed.
     They are truncated to fit on the screen if necessary.

 Returns

     NIL

 Description

     FT_XBOX() allows the programmer to display a message box on the screen
     without needing to calculate the dimensions of the box.  Only the upper
     left corner needs to be defined.  The function will calculate the lower
     right corner based on the number and length of strings passed.

     A maximum of eight strings can be displayed.  If a string is too long
     to fit on the screen it is truncated.

     The first seven parameters are optional.  The default settings are:
        Lines of text are centered.
        Control is returned to the calling routine immediately.
        A single line border is painted.
        The border is black on white.
        The text is white on black.
        The box is centered both vertically and horizontally.

     WARNING:  Shadowing is achieved by a call to FT_SHADOW(), an assembly
               routine not found in this .PRG.  In order to use XBOX,
               SHADOW.OBJ must also be present somewhere (if you are using
               NANFOR.LIB, then it is).

 Examples

     The following displays a two-line box with default settings:

       FT_XBOX(,,,,,,,'This is a test','of the XBOX() function')

     The following uses all optional parameters and displays a three-line
     box.  The box is left-justified with a double border.  It has a yellow
     on red border and white on blue text.  The function will wait for a
     keypress before returning control to the calling routine.

       FT_XBOX('L','W','D','GR+/R','W/B',5,10,'It is so nice',;
                       'to not have to do the messy chore',;
                       'of calculating the box size!')

 Source: XBOX.PRG

 Author: Don Opperthauser

 

FT_SLEEP

FT_SLEEP
 Wait for a specified amount of time

 Syntax

      FT_SLEEP( <nSeconds>, [<nInitial>] ) -> nil

 Arguments

    <nSeconds> is the number of seconds to pause

    <nInitial> is an optional clock value (from a call to SECONDS())
               from which the <nSeconds> seconds are to elapse. Useful
               for setting a minimum time between the start of events
               which could take a variable amount of time due to the
               execution of intervening code.

 Returns

     NIL

 Description

     This routine will wait a specified period of time. It provides
     resolution based upon the execution of the SECONDS() function.
     It does not use an input state such as INKEY(). The specified time
     is the minimum time sleeping and will usually be slightly longer.

     The second optional argument allows one to begin timing an event
     prior to executing some operation. This is useful when, for example,
     you input a key or mouse click and wish to do something but still want
     to note if the user double entered (mouse or key) within a certain time
     which in turn may have meaning within your program's context.

     The routine correctly handles passing through midnight but will not
     work for more than 24 hours.

 Examples

     Example 1:
         FT_SLEEP(10.0)    && Sleep for 10.0 seconds
     Example 2:
         nTime=SECONDS()   && usually after some interupt from mouse or
                           && keyboard

         ... intervening code ...

         FT_SLEEP(0.5, nTime) && Sleep until the sytem clock is
                              && nTime+0.5 seconds.

 Source: SLEEP.PRG

 Author: Leo Letendre

 

FT_PROMPT

FT_PROMPT()
 Define a menu item for use with FT_MenuTo()

 Syntax

      #include "FTMENUTO.CH"

      @ <nRow>, <nCol> PROMPT <cPrompt>                     ;
                       [COLOR <cColor>]                     ;
                       [MESSAGE <cMessage>]                 ;
                       [MSGROW <nMsgRow>]                   ;
                       [MSGCOL <nMsgCol>]                   ;
                       [MSGCOLOR <cMsgColor>]               ;
                       [TRIGGER <nTrigger>]                 ;
                       [TRIGGERCOLOR <cTriggerColor>]       ;
                       [HOME <nHome>]                       ;
                       [END <nEnd>]                         ;
                       [UP <nUp>]                           ;
                       [DOWN <nDown>]                       ;
                       [LEFT <nLeft>]                       ;
                       [RIGHT <nRight>]                     ;
                       [EXECUTE <bExec>]                    ;

 Arguments

     <nRow> is the row at which the prompt is to appear.

     <nCol> is the column at which the prompt will appear.

     <cPrompt> is the menu item string.

     <cColor> is optional and is the color attribute of the prompt.  Note
     that two colors are required; one for the standard setting and one
     for the enhanced setting (i.e. the light bar color).  See the example
     below if this isn't clear.  If <cColor> is not specified then the
     current SetColor() value is used by default.

     <cMessage> is optional and is the message associated with the
     prompt. If not specified, then no message will be displayed.

     <nMsgRow> is optional and is the row at which the message, if any,
     will appear.  If not specified, the default is the current setting
     of the SET MESSAGE TO command.

     <nMsgCol> is optional and is the column at which the message, if
     any, will appear.  If not specified, the default is either zero or
     centered, depending on the current setting of the CENTER option of
     the SET MESSAGE TO command.

     <cMsgColor> is optional and is the color attribute of the message.
     If not specified, the default is the same as the prompt color.

     <nTrigger> is optional and is the position within the prompt string
     where the trigger character is located.  If not specified, the
     default is one.

     <cTriggerColor> is optional and is the color attribute of the trigger
     character.  Note that two colors are required; one for the standard
     setting and one for the enhanced setting (i.e. the light bar color).
     See the example below if this isn't clear.  If <cTriggerColor> is not
     specified then the default is the same color as the rest of the
     prompt.

     <nHome> is optional and specifies which prompt becomes active
     when the home key is pressed.  If not specified, the default is
     the first prompt.

     <nEnd> is optional and specifies which prompt becomes active
     when the end key is pressed.  If not specified, the default is
     the last prompt.

     <nUp> is optional and specifies which prompt becomes active
     when the up arrow key is pressed.  If not specified, the
     default is the previous prompt.  The current setting of SET
     WRAP TO is obeyed.

     <nDown> is optional and specifies which prompt becomes
     active when the down arrow key is pressed.  If not
     specified, the default is the next prompt.  The current
     setting of SET WRAP TO is obeyed.

     <nRight> is optional and specifies which prompt becomes
     active when the right arrow key is pressed.  If not
     specified, the default is the next prompt.  The current
     setting of SET WRAP TO is obeyed.

     <nLeft> is optional and specifies which prompt becomes
     active when the left arrow is pressed.  If not specified,
     the default is the previous prompt.  The current setting of
     SET WRAP TO is obeyed.

     <bExec> is optional and is a code block to evaluate whenever
     the menu item to which it belongs is selected.

 Description

     Clipper's @...PROMPT and MENU TO commands are fine as far as
     they go.  But many times you need more flexibility.  As
     you'll no doubt notice if you read the argument list, this
     function is almost completely flexible. You can adjust
     locations and colors for every part of the prompt and its
     associated message.  In addition, since you can control the
     effect of the arrow keys, you can allow both horizontal and
     vertical movement, or even disable certain arrow keys if you
     so desire.  Support for nested menus is also available, since
     the prompts are stored in stack-based static arrays.

     Note that this command can also be called using function-style
     syntax.  See the entry for FT_PROMPT() for further details.

     This enhanced version of @...PROMPT requires the inclusion of
     the header file FTMENUTO.CH in any source file that uses it.
     It is may be used in place of the standard Clipper @...PROMPT
     command.  However, in the interests of functionality it is NOT
     100% compatible.  No whining!  If compatibility is such a big
     deal then use the standard Clipper commands.

 Examples

    #include "FTMENUTO.CH"

    // Simple prompt
    @ 1, 1 PROMPT "Menu choice #1"

    // Prompt with color
    @ 3, 1 PROMPT "Menu choice #2" COLOR "W+/R,W+/B"

    // Prompt with a message
    @ 5, 1 PROMPT "Menu choice #3" MESSAGE "Go to lunch"

    // Prompt with pinpoint message control
    @ 7, 1 PROMPT "Menu choice #4" MESSAGE "Drop Dead" ;
                   MSGROW 22 MSGCOL 4 MSGCOLOR "GR+/N"

    // Prompt with a trigger character ("#" character)
    @11, 1 PROMPT "Menu choice #6" TRIGGER 13

    // Prompt with trigger character color control
    @13, 1 PROMPT "Menu Choice #7" TRIGGER 13 TRIGGERCOLOR "R+/BG,G+/N"

    // Prompt with right and left arrow keys disabled
    @15, 1 PROMPT "Menu Choice #8" RIGHT 8 LEFT 8

 Header File: FTMENUTO.CH

 Source: MENUTO.PRG

 Author: Ted Means

 

FT_PICKDAY

FT_PICKDAY()
 Picklist of days of week

 Syntax

      FT_PICKDAY() -> cDayOfWeek

 Arguments

     None

 Returns

     Character string containing day of week

 Description

     This function is ideal if you need the user to select a day.

 Examples

     mday := FT_PICKDAY()

 Source: PICKDAY.PRG

 Author: Greg Lief

 

FT_PENDING

FT_PENDING()
 Display same-line pending messages after a wait.

 Syntax

      FT_PENDING ( <cMsg>, [ <nRow> ], [ <nCol> ], ;
                        [ <nWait> ], [ <cColor> ] ) -> NIL

 Arguments

     <cMsg> is the message string to display.

     <nRow> is an optional screen row for message display, default row 24.

     <nCol> is an optional screen col for message display, default col 0.

     <nWait> is an optional wait (sec) between messages, default 5 sec.

     <cColor> is an optional color string for displayed messages, default
              is white text over red background.

 Returns

     NIL

 Description

     A good way to display information messages during the running
     of an application is to send them all to the SAME line on the
     screen where users are expected to look for them. In order to
     give users a chance to read the current message before the next one
     is displayed we may need to insert a delay after each message.

     FT_PENDING() function displays messages by keeping track of
     the time of the last message and providing a delay ONLY if the next
     pending message is issued much too soon after the current one.

 Examples

     FT_PENDING("Message one",20,0,3,"W+/G") // Displays "Message one."
                                             // sets row to 20, col to 0.
                                             // wait to 3 and color to
                                             // bright white over green.
     FT_PENDING("Message two")   // Displays "Message two", after 5 sec.
     FT_PENDING("Message three") // Displays "Message three", after 5 sec.

     Note that default row, col, wait time and color need to be set only
     once in the very first call to FT_PENDING() and only if the internal
     default values are not appropriate.

 Source: PENDING.PRG

 Author: Isa Asudeh

 

FT_MENUTO

FT_MENUTO()
 Execute light bar menu using prompts created with @...PROMPT

 Syntax

      #include "FTMENUTO.CH"

      MENU TO <var> [COLD]

 Arguments

     <var> is the name of the variable to which the result of the menu
     selection should be assigned.

     [COLD] is optional and if specified indicates that trigger characters
     should be treated as "cold," i.e. rather than causing the menu item
     to be selected it only causes the light bar to move to that selection.

 Description

     This enhanced version of MENU TO requires the inclusion of the header
     file FTMENUTO.CH in any source file that uses it.  It may be used in
     place of the standard Clipper MENU TO command.  However, in the
     interests of functionality it is NOT 100% compatible (in particular,
     you should make sure that the target memvar exists before executing
     the menu -- the Clipper version will create a PRIVATE memvar for you
     if it does not already exist, but this version does not).  No whining!
     If compatibility is such a big deal then use the standard Clipper
     command.

     Note that this command can also be called using function-style
     syntax.  See the entry for FT_MENUTO() for further details.

 Examples

    #include "FTMENUTO.CH"

    // Simple command

    MENU TO memvar

 Header File: FTMENUTO.CH

 Source: MENUTO.PRG

 Author: Ted Means

See Also: @…PROMPT

 

FT_MENU2

FT_MENU2()
 Vertical lightbar menu

 Syntax

      FT_MENU2( <aMenuarray> [, <cColors> ] ) -> NIL

 Arguments

     <aMenuarray> is an array of menu options, messages, and action
      blocks.

     Each element in this array is a nested array with the structure:

        element[x, 1] = menu option
        element[x, 2] = message to be displayed when option is highlighted
        element[x, 3] = code block to be executed when option is selected

     <cColors> is a string containing colors for the prompts, in the same
     format as that returned by Set( _SET_COLOR ).  If not supplied,
     colors default to the current color setting.

 Returns

     NIL

 Description

     This function greatly simplifies the process of displaying light-bar
     menus.  All prompts are padded out with spaces so they are the same
     length, a box is drawn around the prompts, the box is automatically
     centered on the screen, and the underlying screen is restored after
     a menu selection has been made.

     Additionally, because you can tie action blocks to each menu
     option, you can save on a lot of DO CASE or IF..ELSEIF code in your
     main program.  See the test code for a succinct demonstration.

 Examples

      LOCAL mainmenu := ;
          { { "Data Entry", "Enter data",   { || FT_MENU2(datamenu)  } }, ;
            { "Reports",    "Hard copy",    { || FT_MENU2(repmenu)   } }, ;
            { "Maintenance","Reindex files",{ || FT_MENU2(maintmenu) } }, ;
            { "Quit", "See ya later" } }
      FT_MENU2(mainmenu)

 Source: VERTMENU.PRG

 Author: Greg Lief

 

FT_MENU1

FT_MENU1()
 Pulldown menu system

 Syntax

      FT_MENU1( <acBarNames>, <acOptions>, <acAction>,
                <acColors> [, <nTopRow> ], [ <lShadow> ] ) -> NIL

 Arguments

     <acBarNames> is a character array containing the names to appear
     on the menu bar.

     <acOptions> is a multi-dimensional array with one element for each
     selection to appear on the pulldown menus.

     <acColors> is an array containing the colors for the menu groups.

     <nTopRow> is a numeric value that determines the row for the menu
     bar.  If omitted, it defaults to 0.

     <lShadow> is a logical variable.  If true (.T.) or omitted, it
     uses FT_SHADOW() to add a transparent shadow to the each
     pulldown menu.  If false (.F.), the menu is drawn without
     the shadow.

     All arguments except nTopRow and lShadow are required.

 Returns

     NIL

 Description

     FT_MENU1() is a function that displays a pulldown menu for each item
     on the menu bar and executes the corresponding function for the item
     selected.  When a called function returns false, FT_MENU1 returns
     control to the calling program.

     Valid keystrokes and their corresponding actions:

     Home             -  Activates Pulldown for first item on the menu bar
     End              -  Activates Pulldown for last item on the menu bar
     Left Arrow       -  Activates next Pulldown to the left
     Right Arrow      -  Activates next Pulldown to the right
     Tab              -  Same as Right Arrow
     Shift-Tab        -  Same as Left Arrow
     Page Up          -  Top item on current Pulldown menu
     Page Down        -  Bottom item on current Pulldown menu
     Enter            -  Selects current item
     Alpha Character  -  Moves to closest match and selects
     Alt-<Key>        -  Moves to corresponding menu bar item
     Escape           -  Prompts for confirmation and either returns to
                         the calling routine or resumes

 Examples

     // Declare arrays
     LOCAL aColors  := {}
     LOCAL aBar     := { " ENTER/EDIT ", " REPORTS ", " DISPLAY " }

     // Include the following two lines of code in your program, as is.
     // The first creates aOptions with the same length as aBar.  The
     // second assigns a three-element array to each element of aOptions.
     LOCAL aOptions[ LEN( aBar ) ]
     AEVAL( aBar, { |x,i| aOptions[i] := { {},{},{} } } )

     // fill color array
     // Box Border, Menu Options, Menu Bar, Current Selection, Unselected
     aColors := IF( lColor, {"W+/G", "N/G", "N/G", "N/W", "N+/G"}, ;
                            {"W+/N", "W+/N", "W/N", "N/W","W/N"} )

  // array for first pulldown menu
  FT_FILL( aOptions[1], 'A. Execute A Dummy Procedure' , {|| fubar()}, .t. )
  FT_FILL( aOptions[1], 'B. Enter Daily Charges'       , {|| .t.},     .f. )
  FT_FILL( aOptions[1], 'C. Enter Payments On Accounts', {|| .t.},     .t. )

  // array for second pulldown menu
  FT_FILL( aOptions[2], 'A. Print Member List'         , {|| .t.},     .t. )
  FT_FILL( aOptions[2], 'B. Print Active Auto Charges' , {|| .t.},     .t. )

  // array for third pulldown menu
  FT_FILL( aOptions[3], 'A. Transaction Totals Display', {|| .t.},     .t. )
  FT_FILL( aOptions[3], 'B. Display Invoice Totals'    , {|| .t.},     .t. )
  FT_FILL( aOptions[3], 'C. Exit To DOS'               , {|| .f.},     .t. )

     Call FT_FILL() once for each item on each pulldown menu, passing it
     three parameters:

        FT_FILL( <cMenuSelection>, <bCodeBlock>, <lSelectable>

     <cMenuSelection> is a character string which will be displayed on
      the pulldown menu.

     <bCodeBlock> should contain one of the following:

        A function name to execute, which in turn should return .T. or .F.
        FT_MENU1 WILL RETURN CONTROL TO THE CALLING PROGRAM IF .F. IS
        RETURNED OR CONTINUE IF .T. IS RETURNED.

        .F. WHICH WILL CAUSE FT_MENU1 TO RETURN CONTROL TO THE CALLING
        PROGRAM.

        .T. WHICH WILL DO NOTHING.  THIS ALLOWS THE DEVELOPER TO DESIGN A
        SKELETON MENU STRUCTURE PRIOR TO COMPLETING ALL OF THE SUBROUTINES.

     // CALL FT_MENU1
     FT_MENU1( aBar, aOptions, aColors, 0 )

     NOTE: FT_MENU1() disables Alt-C and Alt-D in order to make them
           available for the menu bar.  It enables Alt-D and resets
           Alt-C to its previous state prior to calling each function.

 Source: MENU1.PRG

 Author: Paul Ferrara

See Also: FT_FILL()

 

FT_FILL

FT_FILL()
 Declare menu options for FT_MENU1()

 Syntax

      FT_FILL( <aSubArrayName>, <cMenuSelection>, <bFunction>,
               <lSelectable> ) -> NIL

 Arguments

     <aSubArrayName> is a sub-array of <acOptions> in FT_MENU1()
     denoting the group in which to include the selection --
     e.g., acOptions[1]

     <cMenuSelection> is the character string that will appear on
     the menu.

     <bFunction> is the code block to be executed when that menu
     option is selected.  i.e. {|| MyFunction() } would execute
     the function called MyFunction().  {|| .f.} would exit the
     FT_MENU1 and return to the calling routine.   {|| .T.} would
     do nothing.

     <lSelectable> is a logical variable that determines whether
     the corresponding menu option is selectable or not.

 Returns

     NIL

 Description

     FT_FILL() is a function used to set up the menu options prior
     to calling FT_MENU1().

 Examples

  FT_FILL( aOptions[1], 'A. Execute A Dummy Procedure', {|| fubar()}, .t. )

  The above would be added to the sub-menu associated with the first menu
  bar item, would execute the function FUBAR() when that option was
  selected, and would be selectable.

  FT_FILL( aOptions[3], 'B. Enter Daily Charges', {|| .t.}, .f. )

  The above would be added to the sub-menu associated with the third menu
  bar item, and would be unselectable.

  FT_FILL( aOptions[2], 'C. Enter Payments On Accounts', {|| .t.},     .t. )

  The above would be added to the sub-menu associated with the second menu
  bar item, and would be selectable, but would do nothing when selected.

  FT_FILL( aOptions[4], 'C. Exit', {|| .f.},     .t. )

  The above would be added to the sub-menu associated with the fourth menu
  bar item, and would be selectable, and would exit FT_MENU1() when chosen.

 Source: MENU1.PRG

 Author: Paul Ferrara

See Also: FT_MENU1()