Previous

Command groupFlag affectedReversibleExecute on clientPlatform(s)
Finding dataYESYESNOAll

Syntax

Previous
 
on 
field-name
 
 ([
Exact match
][,
Use search
])

Options

Exact matchIf specified,the index value of the field in suitable records must equal the current value
Use searchIf specified,the command uses the current search to select data

Description

This command locates the previous record using the current find table. The Previous command works in the same way as the corresponding option on the Commands menu but with no redraw, allowing you to work through a file. It is usually used after a Find command which creates a find table of records.

If the Index field, Exact match and/or Search option used in the Next is incompatible with the preceding Find, a new table is built. Normally, the parameters in this command are left blank so that the current find table is used.

If the Previous command does not follow a Find, a find table is built for the current main file before doing the Previous.

If an indexed field is specified, Previous on SU_NAME for example, the find table is just the index order for the field. The Use search option creates a table for the current main file in which the search specification is implicitly stored. Thus, changes to the search do not affect the find table once it is created.

Once the previous record is located, the main and connected files are read into the current record buffer and the flag is set, otherwise, the flag is cleared. An error occurs whenever Previous on FIELD is performed on a non-indexed field.

If the Exact match option is chosen, the previous record with the same index value is found, or the flag is cleared if no previous records exist with the same index value.

If you use Previous with a search, it finds the previous record listed on the index table which meets the search criteria.

Example

# Find records in descending order

Find last
 
on 
fAccounts
.
Code

While flag true
  
OK message
 
{
Found account [
fAccounts
.
Code
]
}

  
Update files
  
Previous

End While