JavaScript Editor js editor     Web development 



Main Page

Returns a numeric value indicating if a field in a table or cursor has been modified or had a record appended, or if the deleted status of the current record has been changed.

GETFLDSTATE(cFieldName | nFieldNumber [, cTableAlias | nWorkArea])

Parameters

cFieldName| nFieldNumber


Specifies the name of the field or the number of the field for which the modification status is returned. The field number nFieldNumber corresponds to the position of the field in the table or cursor structure. DISPLAY STRUCTURE or FIELD( ) can be used to determine a field's number. You can specify –1 for nFieldNumber to return a character string consisting of deletion and modification status values for all fields in the table or cursor. For example, if a table has five fields and only the first field has been changed, GETFLDSTATE( ) returns 121111. The 1 in the first position indicates the deletion status has not been changed. You can also include 0 for nFieldNumber to determine if the deletion status of the current record has changed since the table or cursor was opened.
Note:
Using GETFLDSTATE() only determines if the deletion status of the current record has changed. For example, if you mark a record for deletion and then recall it, GETFLDSTATE() indicates the deletion status has changed even though the record's deletion status has returned to its original state. Use DELETED() to determine the current deletion status of a record.

cTableAlias


Specifies the alias of the table or cursor for which the field modification or record deletion status is returned.
nWorkArea


Specifies the work area of the table or cursor for which the field modification or record deletion status is returned. If you do not specify an alias or work area, GETFLDSTATE(В ) returns a value for a field in the currently selected table or cursor.

Return Value

Numeric, Character, or .NULL.

Remarks

The following table lists the character return values and the corresponding modification or deletion status.

Return value Modification or deletion status

1

Field has not been modified or deletion status has not changed.

2

Field has been modified or deletion status has changed.

3

Field in an appended record has not been modified or deletion status has not changed for the appended record.

4

Field in an appended record has been modified or deletion status has changed for the appended record.

.NULL.

At EOF(В )

Row or table buffering must first be enabled with CURSORSETPROP(В ) for GETFLDSTATE(В ) to operate on local tables.

The modification or deletion status is returned for the table or cursor open in the currently selected work area if GETFLDSTATE(В ) is issued without the optional cTableAlias or nWorkArea arguments.

Any change in a field will cause GETFLDSTATE() to return a value showing that the field has been modified, whether the change is explicit or implicit. An example of an explicit modification would be including the field in a REPLACE or INSERT INTO command. An implicit modification occurs in a field that has a default value when any command is issued that adds a new record.

Example 1

The following example demonstrates how you can use GETFLDSTATE(В ) to determine if the contents of a field have 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).

GETFLDSTATE(В ) is issued to display a value (1) corresponding to the unmodified state of the cust_id field before it is modified. The cust_id field is modified with REPLACE, and GETFLDSTATE(В ) is issued again to display a value (2) corresponding to the modified state of the cust_id field. TABLEREVERT(В ) is used to return the table to its original state, and GETFLDSTATE(В ) is issued again to display a value (1) corresponding to the original state of the cust_id field.

В Copy Code
CLOSE DATABASES
CLEAR

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

* Get field state on original cust_id field and display state
nState=GETFLDSTATE("cust_id")
DO DisplayState WITH nState("Original")

* Change field contents and display state
REPLACE cust_id    WITH "***"
nState=GETFLDSTATE("cust_id")
DO DisplayState WITH nState("After Replace")

* Discard table changes and display state
= TABLEREVERT(.T.)        && Discard all table changes
nState=GETFLDSTATE("cust_id")
DO DisplayState WITH nState("After Revert")

PROCEDURE DisplayState
PARAMETER nState,cOperation
DO CASE
   CASE nState=1
      =MESSAGEBOX("Field has not been modified",0,cOperation)
   OTHERWISE
      =MESSAGEBOX("Field has been modified",0,cOperation)
ENDCASE

Example 2

The following example shows the difference in behavior between fields with and without default values.

В Copy Code
SET MULTILOCKS ON
CREATE DATABASE example
CREATE TABLE customer (cust_id C(6),state C(2) DEFAULT "FL")
CLOSE TABLES
USE customer
=CURSORSETPROP("Buffering",5,"customer")

APPEND BLANK
?GETFLDSTATE("cust_id")     && Returns 3, field in an appended record has
                            && not been modified.

?GETFLDSTATE("state")    && Returns 4, field in an appended record has
                         && been modified.

See Also



JavaScript Editor js editor     Web development