PhantomScript v1.7 Reference - Copyright © 2006 P1 Systems Incorporated. All Rights Reserved.

Prev | Next | Users Guide | PhantomScript Reference | P1 Systems


Lists

FindItem

Syntax

FindItem <listvar> <searchtext>

Description

This function searches a list for an item matching the specified search text. The number of the matching item is returned, or 0 if no match is found.

Parameters

<listvar>

A variable containing the list to be accessed.

<searchtext>

The text to search for. If the first character is an asterisk, the search is for an item ending with the text following the asterisk. If the last character is an asterisk, the search is for an item beginning with the text preceeding the asterisk. If the first and last characters are both asterisks, the search is for an item containing the text between the asterisks.

Remarks

Note that FindItem searches the list forward from the current list position. To search an entire list you should place a ResetList statement before the first FindItem statement as shown in the example.

If the list being searched contains composite variables, the value of the parent variable is used for comparison. This, given the following composite variable:


EmployeeRecord = 12246
EmployeeRecord.LastName = "Jansen"
EmployeeRecord.FirstName = "Eric"
EmployeeRecord.FileNumber = 12246

where the value of the EmployeeRecord is "12246", the entire employee record for the employee whose file number is 12246 could be retrieved from a list containing a number of EmployeeRecord composite variables using the following code:


ResetList EmployeeRecords
If FindItem EmployeeRecords 12246 <> 0 Then
EmployeeRecord = CurrentItem EmployeeRecords
EndIf

Example

ResetList theList
stext = "1832"
i = FindItem theList stext
While i <> 0 Loop
MessageBox text=CurrentItem theList
i = FindItem theList stext
EndLoop

Because the search is started at the next item except after a ResetList, code such as the above can be used to find all matching items within a list.



Prev | Next | Users Guide | PhantomScript Reference | P1 Systems

PhantomScript v1.7 Reference - Copyright © 2006 P1 Systems Incorporated. All Rights Reserved.