[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
UpDated()
Logical if any currently active get has changed.
------------------------------------------------------------------------------
Syntax:
Updated( [<lNewUpdated>] ) --> <lUpdated>
Arguments:
<lNewUpdated> is an optional logical overriding the current UpDated()
status.
Returns:
UpDate() always returns a logical indicating if the current (or previous
if none is current) READ updated the GETs.
Description:
Updated() returns a logical indicating whether any of the current
GETs have changed from their original value since the beginning of the
READ. If no GETs are pending then the last Updated() value is
returned. Updated() is always set upon the completion of a READ.
To save and restore the Updated() value in nested reads (normally not
required) or to force a new Updated() value <lNewUpdated> can be
passed to Updated(), however be aware that this has no effect if you
are in an active READ as when Update() is called from within an active
READ the current GETs are verified, not a static value.
Example:
This example demonstrates the checking of Updated() to see if
database values should be updated.
@ 10, 10 GET NAME
READ
IF UpDated() .AND. !LastKill()
CLIENT->NAME := NAME
ENDIF
This example uses Updated() as a measure to activate the SAVE button.
#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:
EX3.PRG
EX5.PRG
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson