Xbasic

PREVIOUS Function

Syntax

Field_Value as A = PREVIOUS(C fieldname[,C tagname])

Arguments

fieldname

The name of a field.

tagname

Optional. Default = Current primary index. The name of a different index for the table.

Description

Returns a value from a field in the previous record.

Discussion

PREVIOUS() returns the Field_Value of a field, referenced by its Field_Name, from the previous record in the current primary index order. If an optional index is specified ( Index_Name ), then the value from the previous record in the specified index order is returned. The Field_Name must contain the name of a field either from the current table or from the primary table of a set. Note : If you are working with a set, PREVIOUS() returns field values only from the previous record in the primary table.

Example 

Assume that the following table is indexed on the CUST_ID field, CUST_ID is the current primary index, and "C103" is the current record:

CUSTOMER
CUST_ID NAME
C100 InSync
C101 ACE Software
C102 Friendlies
C103 Sunstar
C104 Progress Inc.
C105 Adventure Holidays
previous("NAME") -> "Friendlies"
previous(Field_Name) -> "C102", assuming that the variable, Field_Name, contains the value "CUST_ID"

See Also