JavaScript method: SCFile.getPrev()

This method returns the previous record in a record list stored in an SCFile object. You must use of the other SCFile methods to create a record list.

Syntax

SCFile_object.getPrev();

Arguments

There are no arguments for this method.

Return values

An SCFile object containing the previous record and RC_SUCCESS or one of the other global return code values.

The method returns an SCFile object containing the previous record in a record list and a global return code value of RC_SUCCESS or returns one of the error global return code values if the method cannot find the previous record.

Example

This example does the following:

  • Queries the contacts table for any contact name you define in the search variable
  • Displays the first contact in the record list
  • Displays the last record in the record list
  • Displays the previous record in the record list

This example requires the following sample data:

  • A contact query that produces a record list (for example, "H")
var contactQuery;

function findPrevContact( query )
{
 print( "Searching for contacts starting with " + query + "..." );
 var contactFile = new SCFile( "contacts" );
 var findContact = contactFile.doSelect( "contact.name#\""+ query + "\"" );
 if ( findContact == RC_SUCCESS )
 {
  print( "Success. Found contacts starting with " + query + ". The first record is:\n" + contactFile );
  var findLastRecord = contactFile.getLast();
  print( "The last record is:\n" + contactFile );
  var findPrevRecord = contactFile.getPrev();
  print( "The previous record is:\n" + contactFile );
 }
 else
 {
  print( "Could not find contacts starting with " + query + ". " + RCtoString( findContact ) );
  return null
 }
}
contactQuery = "H";
findPrevContact( contactQuery );