sx_Locate

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_Locate

VB Declaration

Declare Function sx_Locate Lib "Apollo9.dll"

(ByVal cpExpression As Any,

ByVal iDirection As Integer,

ByVal bContinue As Integer)

As Long

C Declaration

LONG FAR PASCAL sx_Locate

(BYTE cpExpression,

SHORT iDirection,

BOOL bContinue);

Description

Initializes or continues a record location command.

Parameters

cpExpression: An xBase expression that will evaluate to a logical conclusion that describes the data you are looking for. Such as:

"upper(trim(country)) = 'GERMANY'"

If you wish to clear the locate expression, pass this parameter as a NULL string (0&).

If starting a new locate sequence, the new expression will overwrite the old. It is not necessary to clear it first.

iDirection: Pass this parameter as False if you wish to search in the forward direction from the current record position. Pass it as True if you want to search backwards from the current record position.

bContinue: Pass this parameter as False when the locate sequence is initiated. Pass it as True if you are continuing a search. Note that if you are continuing a search you must not pass cpExpression as a NULL string (0&). A NULL value in cpExpression clears the locate expression contained in the current work area and returns with a zero (not found).

Return Value

The record number of the first record that satisfies the locate expression. If no record is found, a zero is returned and the record pointer in the table is positioned at the record that was active before the locate was attempted.

VB Example

Sub bLocate_Click ()

Dim bContinue As Integer

If Not LocSwitch Then

RecStr$ = InputBox$("Locate condition?", "Locate", "")

If RecStr$ = "" Then Exit Sub

If sx_EvalTest(RecStr$) Then

LocSwitch = True

bContinue = False

bLocate.Caption = "&Again"

Else

MsgBox "Error in expression"

Exit Sub

End If

Else

RecStr$ = " "

bContinue = True

End If

MousePointer = 11

If sx_Locate(RecStr$, 0, bContinue) = 0 Then

MsgBox "Not Found"

j& = sx_Locate(0&, 0, 0)

LocSwitch = False

bLocate.Caption = "&Locate"

Else

sx_Go (sx_RecNo())

End If

MousePointer = 1

End Sub

C Example

if (sx_Locate((BYTEP) cpLocate, 0, 0) == 0L)

{

AfxMessageBox((LPCSTR) "Item not found.");

sx_Locate(NULL, 0, 0);

}

See Also

sx_Query, sx_Seek