[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 @...BUTTON
 Create a Get object as a BUTTON and display it.
------------------------------------------------------------------------------

 Syntax:

     @ <nRow>, <nCol>
        [SAY <exp>
           [PICTURE <cSayPicture>]
           [COLOR <cColorString>]]
        BUTTON <cExp>
           [COLOR <cColorString>]
           [WHEN <lPreCondition>]
           [ACTION <lAction>]
           [HIDDEN]
           [MESSAGE <cSayMessage>]

 Arguments:

     <nRow> and <nCol> specify the row and column coordinates for
     the operation.  If the SAY clause is present, <nRow> and <nCol> specify
     the coordinates for the SAY, and the GET is displayed to the right of
     the SAY output.  If the SAY clause is not present, <nRow> and <nCol>
     directly specify the coordinates for the GET.  In either case, output
     which extends beyond the visible extent of the display is clipped and
     does not appear.

     SAY <exp> displays the value of <exp> at the specified
     coordinates.  If the PICTURE <cSayPicture> clause is specified, <exp>
     is formatted according to the rules of SAY pictures.

     <cColorString> specifies the colors to use for the button.  Three color
     combinations are required.  The first is the color used to display the
     button when it is available, the second is the color used to display
     the button when the highlight bar is on it and the third is used to
     display the button when it is unavailable.

     HIDDEN is flag used to indicate the data is to be hidden when the
     <lPreCondition> evaluates to FALSE.  (see the WHEN clause explanation).

     MESSAGE <cSayMessage> attaches the <cSayMessage> to the get so it
     may be displayed whenever the GET is infocus and the SET MESSAGE TO has
     been set to a number greater than 0.

     WHEN <lPreCondition> specifies an expression that must be satisfied
     before the cursor will be allowed to enter the GET during a READ.

     ACTION <lAction> specifies an expression that will be executed if the
     button is selected.



 Example:

 #INCLUDE "CUACLIP.CH"

 FUNCTION Demo( lAppend )

 LOCAL GetList      := {}
 STATIC cName       := "                    "
 STATIC nSalutation := 0
 STATIC cCity       := "                    "
 STATIC cPhone      := "          "
 STATIC lModem      := .F.
 STATIC nBaudRate   := 0
 LOCAL aSalutations := {{{1,"Mr."},{2,"Mrs."},{3,"Miss"},{4,"Ms."}}}
 LOCAL aBaudRates := {{{ 3,"300  "},{12,"1200 "},{24,"2400 "},{48,"4800 "}},;
                      {{96,"9600 "},{19,"19200"},{38,"38400"},{57,"57600"}}}
 LOCAL aCities      := {"Ottawa              ",;
                        "Toronto             ",;
                        "Montreal            ",;
                        "Vancouver           ",;
                        "Winnipeg            ",;
                        "Calgary             ",;
                        "Edmonton            ",;
                        "Hamilton            ",;
                        "Regina              ",;
                        "Saskitoon           ",;
                        "St. John's          ",;
                        "Halifax             "}
 LOCAL cOldColor    := SETCOLOR("W/RB,RB/W,,,+W/RB")
 LOCAL cOldMenu     := SetMenuColor("+W/BG,B/BG,N+/BG,W/BG")
 LOCAL cOldGet      := SetGetColor("+W/RB,RB/W,W/RB")
 LOCAL cOldPop      := SetPopColor("+W/R,R/W,W/R")
 LOCAL cOldScreen   := ShadowBox( 9, 12, 22, 67, 2, "+W/RB")
 LOCAL lOldUpdate   := Updated( FALSE )
 DEFAULT lAppend TO FALSE

 /* The radio button array structure is an array containing another array
    for each row of buttons to be displayed.  Each one of these "row" arrays
    contain an array for each button on that row.  Each one of the "button"
    arrays contain two elements, 1 - a value for the variable and
    2 - the corresponding character prompt for that value.  The vartype() of
    the first element must match that of the variable being represented by
    the radio button.
    {
      { <xValue1>, <cPrompt1> } [,{ <xValue#>, <cPrompt#> }, ... ] }
    [,{ <xValue#>, <cPrompt#> } [,{ <xValue#>, <cPrompt#> }, ... ] }, ... ]
    }
 */

 IF lAppend
    cName       := "                    "
    nSalutation := 0
    cCity       := "                    "
    cPhone      := "          "
    lModem      := .F.
    nBaudRate   := 0
 ENDIF

 @ 10,16 SAY "Name:  "     GET cName DBLIST {"employee",,,{||field->name}};
    MESSAGE "What is the name of the person..."
 @ 11,16 SAY "Salutation:" GET nSalutation USING Radio WITH aSalutations ;
    MESSAGE "Salutation please..."
 @ 12,16 SAY "City:  "     GET cCity LIST aCities ;
    MESSAGE "The city in which the person lives.."
 @ 13,16 SAY "Phone: "     GET cPhone PICTURE "@R (999) 999-9999" ;
    WHEN !EMPTY(cName) HIDDEN MESSAGE "Telephone number please..."
 @ 14,16 SAY "Modem?:"     GET lModem USING Check ;
    VALID (IIF(!lModem,nBaudRate:=0,NIL),TRUE) ;
    MESSAGE "Does the person have a modem?..."
            // Notice the trick to clear the baudrate field.
 @ 15,16 TO 18,63  //draw a box to contain the baud rates
 @ 15,16 SAY "Baud Rate"
 @ 16,19 GET nBaudRate USING Radio WITH aBaudRates WHEN lModem ;
    MESSAGE "What baud rate does their modem function at?..."

 @ 20,16 BUTTON "Save" WHEN UpDated() ACTION ;
    IIF(ValidGets() == 0,OrigChanged(),FALSE) ;
    MESSAGE "Save the work and continue..."

 @ 20,COL()+3 BUTTON "Save/Exit" WHEN UpDated() ACTION ;
    IIF(ValidGets() == 0,!OrigChanged(),FALSE)  ;
    MESSAGE "Save the work and exit..."

 @ 20,COL()+3 BUTTON "Abort" ACTION UndoGets() ;
    MESSAGE "Abort your work and exit..."
 READ

 SETCOLOR( cOldColor )
 SetMenuColor( cOldMenu )
 SetGetColor( cOldGet )
 SetPopColor( cOldPop )
 KillBox( cOldScreen )
 Updated( lOldUpdated )

 RETURN NIL

 Files:  Library is CUACLIP.LIB.

See Also: @...GET READ SetMessColor() EX3.PRG EX5.PRG
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson