FindListPosition |
Top Previous Next |
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:
- 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.
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 Let’s 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:
|