FindListPosition

Top  Previous  Next

S

A

W

WS

ü

ü

Syntax -

FindListPosition  <List Name> <Search Value> [<Column Number>] {START|CURRENT|NEXT}] [{EnableWildcard | DisableWildcard}] [{WithTrim | NoTrim}]

       Where:

       <List Name> is the user defined name that is assigned to the list.

       <Search Value> is a literal string or a variable that contains a literal string.

       <Column Number> is an integer.

       [START|CURRENT|NEXT] are keywords.

       If not provided, START is the default value.

               [EnableWildcard | DisableWildcard] are keywords.  If not provided, DisableWildcard is the default

               [WithTrim | NoTrim] are keywords.  If not provided, NoTrim is the default.

 

Description:

This command is used to change the current position in the list with the name defined in <ListName>, to the position of a member in the list that contains the <SearchValue> in the specified data element.
The column that is being searched is identified by its relative position in the list and defined in <Column Number>.  <Column Number> can have a value between 1 and the number of columns in a list.   If <Column Number> is valued with an asterisk (*), all columns of a list will be searched.
The starting point of the search is determined by the use of one of the key words, START, CURRENT, or NEXT.

       -  START searches from the first member of the list and proceeds sequentially through the list.

       -  CURRENT searches forward sequentially starting with the current list position to the end of the list.

       -  NEXT searches forward sequentially from the current list position + 1 to the end of the list.

Wildcards (*, %) can be used when searching for an item in a list, however, in order for EMUE to interpret a wildcard as such, wildcards must be enabled.  Otherwise EMUE will search for the exact string that is supplied.
Using the keyword WithTrim will cause EMUE to temporarily trim the values in the list before performing the comparison.  Values in the list are not altered, they are merely trimmed for the comparison.  Trimming values is especially when working with tables that are extracted from the web because it is difficult to predict whether or not the values will have leading or trailing spaces.  If no value is specified, EMUE will not trim the values before performing the comparison.  This default behavior is equivalent to using the keyword NoTrim.

 

Notes: All data elements are treated as literal strings for the search.  Numeric values are converted to literal strings as they are stored, which means that “0100” is not the same as “100”.

Using an asterisk (*) as the value of the <Column Number> can have a significant impact on the performance of the script.  It is recommended that this option should be used cautiously.

If START is specified for the starting point, this command will always return the first occurrence of a value.  If you want to iterate through a list and find each occurrence of a value, you should use START for the first search and then either CURRENT or NEXT for each subsequent search.

The If EndOfList statement should be used before the GetListMember statement to determine if the end of the list was reached before a match was found.

CURRENT will search the current list member before proceeding to the next member.

NEXT excludes the current list member from the search and searches forward beginning with the next list member.  

 

Note: Please be aware of the fact that the GetListMember command automatically increments the list position.  If the GetListMember command has been used to retrieve the data from a list member, the current position pointer has already been moved to the next record, use of the CURRENT option should be considered to prevent the skipping of members.

 

Sample:

The following segment of a script shows how a list of PatientIDs and Names can be pulled from an access database, and how the script can be coded to find all occurrences of a specific Patient ID and log the associated data to the output file.

Please refer to the GetODBCData command in this manual for information on how this command functions.

REM Allocate and fill the list note that the GetODBCData command wrapped over two lines here, but

REM should be placed on one line in a script

CreateList PATIENTS

GetODBCData PATIENTS "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\PTDB\PTDB.MDB;" "SELECT PTID, [Last Name], [First Name] FROM [PatientList];"

 

REM Find the first occurrence of the desired Patient ID

FindListPosition PATIENTS “123456789” 1 Start

If EndOfList PATIENTS GoTo End

 

:RepeatGet

REM Update progress status

UpdateStatus PATIENTS

REM Retrieve the current values (GetListMember automatically increments the list pointer)

GetListMember PATIENTS PTID LastName FirstName

 

REM The values are now in variables, so we can do what we want with them.

REM Lets log them out in a fixed with format.

LOG PTID:-10 LastName:20 FirstName:20 "\n"

 

REM Find the next occurrence

FindListPosition PATIENTS “123456789” 1 Current

 

REM If we have reached the end of the list, then exit, otherwise repeat

If EndOfList PATIENTS Then

       GoTo End

Else

       GoTo RepeatGet

EndIf

 

:End

Exit

 

 

See Also:

CreateList

DisposeList

ListExists

GetListCount

GetListMember

GetListPosition

PutListMember

SetListPosition