GETNEXTMODIFIED( ) Function

Returns the record number for the next modified record in a buffered table or cursor.

GETNEXTMODIFIED(nRecordNumber [, cTableAlias | nWorkArea] [, lNoFire])

Return Values

Numeric

Parameters

  • nRecordNumber
    Specifies the record number after which GETNEXTMODIFIED( ) searches for the next modified record. Specify 0 for nRecordNumber to determine the first record in the table or cursor that has been modified.

  • cTableAlias
    Specifies the alias of the table or cursor for which GETNEXTMODIFIED( ) returns the number of the next modified record.

  • nWorkArea
    Specifies the work area of the table or cursor for which GETNEXTMODIFIED( ) returns the number of the next modified record.

    If you do not specify an alias or work area, GETNEXTMODIFIED( ) returns the record number for the next modified record in the currently selected table or cursor.

  • lNoFire
    Specifies that all firing of rules are suppressed.

Remarks

GETNEXTMODIFIED( ) returns 0 if there are no modified records after the record you specify. Because of this, if you modify only one record, to verify its modification you must first use the GO TOP command to position the cursor before the changed record. A record is considered modified if the contents of any of its fields are changed in any way (even if the original field contents are restored) or the record's deletion status is changed.

GETNEXTMODIFIED( ) can operate only on tables and cursors for which table buffering is enabled. Table buffering is enabled with CURSORSETPROP( ).

Since triggers are unaffected by GETNEXTMODIFIED( ), lNoFire suppresses only field and record rules, and the "Uniqueness of index ID is violated" error. lNoFire prevents the flushing of temporary data, such as data stored in controls, to the underlying cursor.

Example

The following example demonstrates how you can use GETNEXTMODIFIED( ) to determine which records in a table have been changed. MULTILOCKS is set to ON, a requirement for table buffering. The customer table in the testdata database is opened, and CURSORSETPROP( ) is then used to set the buffering mode to optimistic table buffering (5).

SKIP is issued to move the record pointer to the second record, and the cust_id field is modified with REPLACE. GETNEXTMODIFIED(0) is used to display the record number of the next modified record (2, the second record), starting from the beginning of the table. TABLEREVERT( ) is used to return the table to its original state, and GETNEXTMODIFIED(0) is used again to display the record number of the next modified record (0, indicating that no records have been modified).

CLOSE DATABASES
CLEAR

OPEN DATABASE SYS (HOME(2) + 'data\testdata')
SET MULTILOCKS ON  && Allow table buffering
USE Customer     && Open customer table
=CURSORSETPROP("Buffering", 5, "customer")  && Enable table buffering

SKIP  && Move record pointer to the second record

* Change field contents
REPLACE cust_id WITH "***"

* Call MESSAGEBOX function with results of GETNEXTMODIFIED
=MESSAGEBOX("Record " + ALLTRIM(STR(GETNEXTMODIFIED(0))) + ;
   " has changed.",0,"Results")

* Revert table and display results with MESSAGEBOX
=TABLEREVERT(.T.)  && Discard all table changes
nChange=GETNEXTMODIFIED(0)
IF nChange=0
   =MESSAGEBOX("Record(s) have been reverted.",0,"Results")
ELSE
   =MESSAGEBOX("Record " + ALLTRIM(STR(GETNEXTMODIFIED(0))) + ;
    " has changed.",0,"Results")
ENDIF

See Also

CURSORSETPROP( ) | CURVAL( ) | GETFLDSTATE( ) | OLDVAL( )