HB_Alert

HB_Alert

Displays a text-mode dialog box with a message.

Syntax

      HB_Alert( <xMessage>, [<aOptions>], [<cColor>], [<nDelay>] ) --> nChoice

Arguments

<xMessage> : The message to display. May be any data type. Character string may be divided display lines by the semicolon

<aOptions> : An array with available response as character strings. Default is { “Ok” }.

<cColor> : A string as color codes. Default color is “W+/R”.

<nDelay> : Number of seconds to wait to user response before abort. Default value is 0, that wait forever.

Returns

A numeric value indicating the ordinal position within <aOption> selected by the user. Zero value means that user pressed escape key.

If <nDelay> is specified and this number of seconds has elapsed without a key press, the return value is 1.

Description

HB_Alert() displays a dialog box and lets the user select an option. The user can move a highlight bar using arrow keys or the TAB key. To select an option, the user can press ENTER, SPACE or the first letter of an option.

HB_Alert() is extended version of Alert() to support all variables types (not just strings) is passed as first parameter.

Example

      // This example displays a message with two line : file name and 'not found' message.
      // After 15 seconds without user response, assumed 'Abort' selected.

      FUNCTION FNFMessage( cFileName )

         LOCAL cMessage, aOptions, nChoice

         aMessage := { cFileName, 'Not found !' }
         aOptions :=  { 'Abort', 'Retry', 'Skip' }

         nChoice := HB_Alert( aMessage, aOptions, , 15 )

      RETURN nChoice // FNFMessage()

Seealso

@…PROMPT, AChoice(), Alert(), DispBox(), DispOut(), MENU TO

ReadVar()

READVAR()

Return variable name of current GET or MENU

Syntax

      READVAR( [<cVarName>] ) --> cOldVarName

Arguments

<cVarName> is a new variable name to set.

Returns

READVAR() return the old variable name. If no variable previously was set, READVAR() return “”.

Description

READVAR() is set inside a READ or MENU TO command to hold the uppercase name of the GET / MENU TO variable, and re-set back to old value when those commands finished. You should not normally set a variable name but rather use it to retrieve the name of a GET variable when executing a VALID or WHEN clause, or during SET KEY execution and you are inside a READ or MENU TO.

Examples

      // display a menu, press F1 to view the MENU TO variable name
      CLS
      @ 1, 10 PROMPT "blood sucking insect that infect beds   "
      @ 2, 10 PROMPT "germ; virus infection                   "
      @ 3, 10 PROMPT "defect; snag; (source of) malfunctioning"
      @ 4, 10 PROMPT "small hidden microphone                 "
      @ 6, 10 SAY "(Press F1 for a hint)"
      SET KEY 28 TO ShowVar
      MENU TO What_Is_Bug

      PROCEDURE ShowVar
         Alert( ReadVar() )     // WHAT_IS_BUG in red ALERT() box

Compliance

READVAR() works exactly like CA-Cl*pper’s READKEY().

Note however, that the <cVarName> parameter is not documented and used internally by CA-Cl*pper.

Platforms

All

Files

Library is rtl

Seealso

@…GET, @…PROMPT, MENU TO, READ, SET KEY, __AtPrompt(), __MenuTo()

SET WRAP

SET WRAP

Toggle wrapping the PROMPTs in a menu.

Syntax

      SET WRAP on | OFF | (<lWrap>

Arguments

<lWrap> Logical expression for toggle

Description

This command toggles the highlighted bars in a @…PROMPT command to wrap around in a bottom-to-top and top-to-bottom manner. If the value of the logical expression <lWrap> is a logical false (.F.), the wrapping mode is set OFF; otherwise, it is set ON.

Examples

      See tests/menutest.prg

Compliance

Clipper

Seealso

@…PROMPT, MENU TO

SET MESSAGE

SET MESSAGE

Establishes a message row for @…PROMPT command

Syntax

      SET MESSAGE TO [<nRow> [CENTER]]

Arguments

<nRow> Row number to display the message

Description

This command is designed to work in conjunction with the MENU TO and @…PROMPT commands. With this command, a row number between 0 and MaxRow() may be specified in <nRow>. This establishes the row on witch any message associated with an @…PROMPT command will appear.

If the value of <nRow> is 0, all messages will be suppressed. All messaged will be left-justifies unless the CENTER clause is used. In this case, the individual messages in each @…PROMPT command will be centered at the designated row (unless <nRow> is 0). All messages are independent; therefore, the screen area is cleared out by the centered message will vary based on the length of each individual message.

Specifying no parameters with this command set the row value to 0, witch suppresses all messages output. The British spelling of CENTRE is also supported.

Examples

      See tests/menutest.prg

Compliance

Clipper

Seealso

Set(), SET WRAP, @…PROMPT, MENU TO

SET INTENSITY

SET INTENSITY

Toggles the enhanced display of PROMPT’s and GETs.

Syntax

      SET INTENSITY  ON | off | (<lInte>)

Arguments

<lInte> Logical expression for toggle command

Description

This command set the field input color and @…PROMPT menu color to either highlighted (inverse video) or normal color. The default condition is ON (highlighted).

Examples

      SET INTENSITY ON

Compliance

Clipper

Seealso

@…GET, @…PROMPT, @…SAY, Set()

MENU TO

MENU TO

Invoked a menu defined by set of @…PROMPT

Syntax

      MENU TO <cVariable>

Arguments

<cVariable> is a character string that contain the name of the variable to hold the menu choices, if this variable does not exist a PRIVATE variable with the name <cVariable> would be created to hold the result.

Description

Menu To() invoked the menu define by previous __AtPrompt() call and display a highlight bar that the user can move to select an option from the menu. If <cVariable> does not exist or not visible, a PRIVATE variable named <cVariable> is created and hold the current menu selection. If there is a variable named <cVariable>, its value is used to select the first highlighted item.

Menu prompts and messages are displayed in current Standard color, highlighted bar is displayed using current Enhanced color.

Pressing the arrow keys move the highlighted bar. When a menu item is highlighted the message associated with it is displayed on the line specified with SET MESSAGE. If SET WRAP is ON and the user press UP arrow while on the first selection the last menu item is highlighted, if the user press Down arrow while on the last item, the first item is highlighted.

Following are active keys that handled by Menu To:

       key            Meaning
       -------------- ---------------------------------
       Up             Move to previous item
       Down           Move to next item
       Left           Move to previous item
       Right          Move to next item
       Home           Move to the first item
       End            Move to the last item
       Page-Up        Select menu item, return position
       Page-Down      Select menu item, return position
       Enter          Select menu item, return position
       Esc            Abort selection, return 0
       First letter   Select next menu with the same first letter,
                      return this item position.

Upon exit the cursor is placed at MaxRow()-1, 0 Menu To can be nested without loosing the previous prompts.

MENU TO command is preprocessed into __MenuTo() function during compile time.

Examples

      // display menu item on each screen corner and let user select one
      CLS
      SET MESSAGE TO MaxRow() / 2 CENTER
      SET WRAP ON
      @ 0           , 0             PROMPT "1. Upper left"   MESSAGE " One "
      @ 0           , MaxCol() - 16 PROMPT "2. Upper right"  MESSAGE " Two "
      @ MaxRow() - 1, MaxCol() - 16 PROMPT "3. Bottom right" MESSAGE "Three"
      @ MaxRow() - 1, 0             PROMPT "4. Bottom left"  MESSAGE "Four "
      MENU TO nChoice
      SetPos( MaxRow() / 2, MaxCol() / 2 - 10 )
      IF nChoice == 0
         ?? "Esc was pressed"
      ELSE
         ?? "Selected option is", nChoice
      ENDIF

Compliance

Clipper

Seealso

@…PROMPT, ACHOICE(), SET MESSAGE, SET INTENSITY, SET WRAP, __ATPROMPT()

__MenuTo()

Template

Function

Name

__MenuTo()

Category

API

Subcategory

User interface

Oneliner

Invoked a menu defined by set of @…PROMPT

Syntax

      __MenuTo( <bBlock>,  <cVariable> ) --> nChoice

Arguments

<bBlock> is a set/get code block for variable named <cVariable>.

<cVariable> is a character string that contain the name of the variable to hold the menu choices, if this variable does not exist a PRIVATE variable with the name <cVariable> would be created to hold the result.

Returns

__MenuTo() return the number of select menu item, or 0 if there was no item to select from or if the user pressed the Esc key.

Description

__MenuTo() invoked the menu define by previous __AtPrompt() call and display a highlight bar that the user can move to select an option from the menu. If <cVariable> does not exist or not visible, a PRIVATE variable named <cVariable> is created and hold the current menu selection. If there is a variable named <cVariable>, its value is used to select the first highlighted item.

Menu prompts and messages are displayed in current Standard color, highlighted bar is displayed using current Enhanced color.

Pressing the arrow keys move the highlighted bar. When a menu item is highlighted the message associated with it is displayed on the line specified with SET MESSAGE. If SET WRAP is ON and the user press UP arrow while on the first selection the last menu item is highlighted, if the user press Down arrow while on the last item, the first item is highlighted.

Following are active keys that handled by __MenuTo():

       key            Meaning
       -------------  ---------------------------------
       Up             Move to previous item
       Down           Move to next item
       Left           Move to previous item
       Right          Move to next item
       Home           Move to the first item
       End            Move to the last item
       Page-Up        Select menu item,  return position
       Page-Down      Select menu item,  return position
       Enter          Select menu item,  return position
       Esc            Abort selection,  return 0
       First letter   Select next menu with the same first letter, |return this item position.

Upon exit the cursor is placed at MaxRow()-1, 0 __MenuTo() can be nested without loosing the previous  prompts.

MENU TO command is preprocessed into __MenuTo() function during compile time.

Examples

      // display menu item on each screen corner and let user select one
      CLS
      SET MESSAGE TO MaxRow() / 2 CENTER
      SET WRAP ON
      @ 0           ,  0             PROMPT "1. Upper left"   MESSAGE " One "
      @ 0           ,  MaxCol() - 16 PROMPT "2. Upper right"  MESSAGE " Two "
      @ MaxRow() - 1,  MaxCol() - 16 PROMPT "3. Bottom right" MESSAGE "Three"
      @ MaxRow() - 1,  0             PROMPT "4. Bottom left"  MESSAGE "Four "
      MENU TO nChoice
      SetPos( MaxRow() / 2,  MaxCol() / 2 - 10 )
      IF nChoice == 0
         ?? "Esc was pressed"
      ELSE
         ?? "Selected option is",  nChoice
      ENDIF

Compliance

Clipper

Files

Library is core

Seealso

@…PROMPT, AChoice(), SET MESSAGE, SET INTENSITY, SET WRAP, __AtPrompt()

@…PROMPT

@…PROMPT

Display a menu item on screen and define a message

Syntax

      @ <nRow>, <nCol> PROMPT <cPrompt> [MESSAGE <xMsg>]

Arguments

<nRow> is the row number to display the menu <cPrompt>. Value could range from zero to MaxRow().

<nCol> is the column number to display the menu <cPrompt>. Value could range from zero to MaxCol().

<cPrompt> is the menu item character string to display.

<xMsg> define a message to display each time this menu item is highlighted. <xMsg> could be a character string or code block that is evaluated to a character string. If <xMsg> is not specified or of the wrong type, an empty string (“”) would be used.

Description

With @…Prompt you define and display a menu item, each call to @…Prompt add another item to the menu, to start the menu itself you should call the __MenuTo() function (MENU TO command). You can define any row and column combination and they will be displayed at the order of definition. After each call to @…Prompt, the cursor is placed one column to the right of the last text displayed, and ROW() and COL() are updated.

@…PROMPT command is preprocessed into __AtPrompt() function during compile time.

Examples

      // display a two line menu with status line at the bottom
      // let the user select favorite day
      SET MESSAGE TO 24 CENTER
      @ 10, 2 PROMPT "Sunday" MESSAGE "This is the 1st item"
      @ 11, 2 PROMPT "Monday" MESSAGE "Now we're on the 2nd item"
      MENU TO nChoice
      DO CASE
      CASE nChoice == 0           // user press Esc key
         QUIT
      CASE nChoice == 1           // user select 1st menu item
         ? "Guess you don't like Mondays"
      CASE nChoice == 2           // user select 2nd menu item
         ? "Just another day for some"
      ENDCASE

Compliance

Clipper (menu)

Seealso

ACHOICE(), MENU TO, SET MESSAGE, SET INTENSITY, SET WRAP, __MENUTO()

Alert()

ALERT()

Display a dialog box with a message

Syntax

      ALERT( <xMessage>, [<aOptions>], [<cColorNorm>], [<nDelay>] ) --> nChoice or NIL

Arguments

<xMessage> Message to display in the dialog box. <xMessage> can be of any Harbour type. If <xMessage> is an array of Character strings, each element would be displayed in a new line. If <xMessage> is a Character string, you could split the message to several lines by placing a semicolon (;) in the desired places.

<aOptions> Array with available response. Each element should be Character string. If omitted, default is { “Ok” }.

<cColorNorm> Color string to paint the dialog box with. If omitted, default color is “W+/R”.

<nDelay> Number of seconds to wait to user response before abort. Default value is 0, that wait forever.

Returns

ALERT() return Numeric value representing option number chosen.

If ESC was pressed, return value is zero.

The return value is NIL if ALERT() is called with no parameters, or if <xMessage> type is not Character and HB_CLP_STRICT option was used. If <nDelay> seconds had passed without user response, the return value is 1.

Description

ALERT() display simple dialog box on screen and let the user select one option. The user can move the highlight bar using arrow keys or TAB key. To select an option the user can press ENTER, SPACE or the first letter of the option.

If the program is executed with the //NOALERT command line switch, nothing is displayed and it simply returns NIL. This switch could be overridden with __NONOALERT().

If the GT system is linked in, ALERT() display the message using the full screen I/O system, if not, the information is printed to the standard output using OUTSTD().

Examples

      LOCAL cMessage, aOptions, nChoice

      // harmless message
      cMessage := "Major Database Corruption Detected!;" +  ;
                  "(deadline in few hours);;"             +  ;
                  "where DO you want to go today?"

      // define response option
      aOptions := { "Ok", "www.jobs.com", "Oops" }

      // show message and let end user select panic level
      nChoice := ALERT( cMessage, aOptions )
      DO CASE
      CASE nChoice == 0
         // do nothing, blame it on some one else
      CASE nChoice == 1
         ? "Please call home and tell them you're gonn'a be late"
      CASE nChoice == 2
         // make sure your resume is up to date
      CASE nChoice == 3
         ? "Oops mode is not working in this version"
      ENDCASE

Compliance

This function is sensitive to HB_CLP_STRICT settings during the compilation of src/rtl/alert.prg

defined : <xMessage> accept Character values only and return NIL if other types are passed.

undefined : <xMessage> could be any type, and internally converted to Character string. If type is Array, multi-line message is displayed.

defined : Only the first four valid <aOptions> are taken.

undefined : <aOptions> could contain as many as needed options.

If HB_COMPAT_C53 was define during compilation of src/rtl/alert.prg the Left-Mouse button could be used to select an option.

The interpretation of the //NOALERT command line switch is done only if HB_CLP_UNDOC was define during compilation of src/rtl/alert.prg

<cColorNorm> is a Harbour extension, or at least un-documented in Clipper 5.2 NG.

<nDelay> is a Harbour extension.

Files

Library is rtl

Seealso

@…PROMPT, MENU TO, OUTSTD(), __NONOALERT()

SP_MESSYN

MESSYN()

  Short:
  ------
  MESSYN() Popup YesNo prompt box

  Returns:
  --------
  <lYes> => True for yes, False for No

  Syntax:
  -------
  MESSYN(cQuestion,[cYes],[cNo],[nTop],[nLeft])

  Description:
  ------------
  Pops up a box and displays a question <cQuestion>
  and two prompts.

  [cYes] ,[cNo] are optional prompts 1 and 2. Default
  is YES/NO.

  [nTop] and [nLeft] are optional box top and left
  coordinates. Default is centered.

  Examples:
  ---------
   if messyn("Are you done")

   if messyn("Are you done","Not yet","Almost",10,10)

   if messyn("Are you done","Not Yet","Almost")

  Source:
  -------
  S_MESSYN.PRG