LocateUp (Stringlist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
(No difference)

Revision as of 15:49, 19 January 2011

Locate previous Stringlist item containing string (Stringlist class)


This method locates a specified string in a Stringlist, searching the Stringlist items in reverse order.

Syntax

%itemNum = sl:LocateUp( string, [[Start=] number], [[StartColumn=] number], - [[EndColumn=] number], [[CaseIndependent=] number], - [[ArbitraryQuote=] number])

Syntax terms

%rc A numeric variable set to the item number of the first item in the %sl Stringlist that contains the search string, or it is set to a 0 if no items match the search criterion. items in %sl after the string has been inserted.
sl A Stringlist object.
string The string to be located. This is a required argument, and it must be no longer than 255 bytes.
start A number that indicates the item number at which the search is to begin. If this argument is not specified, searching begins at the last item in the Stringlist.
startcol A number that specifies the starting column of the range of columns within which the specified string is searched for. This is an optional argument, and it defaults to 1.
endcol A number that specifies the ending column of the range of columns within which the specified string is searched for. This is an optional argument, and it defaults to 6124. If caseflag is a non-zero integer, the width of the searched column range is reduced to a maximum of 256.
caseflag An indicator for case-insensitive comparisons. If this argument is a non-zero integer, the string comparisons use Stringlist item data translated to uppercase (so the search string should be passed as an uppercase value). This is an optional argument, and it defaults to zero. If it is 1, the width of the searched column range is reduced to a maximum of 256.

Usage notes

  • LocateUp returns a 0 if the indicated string is not found, and it cancels the request for all other errors.
  • The following code locates a string anywhere in a a Stringlist %list item, searching backwards starting at item 100.
    %num = %list:locateUp('Vietnamerica', 100)
    
  • While, under Sirius Mods Version 6.6 and later, Stringlist items can be longer than 6124 bytes long, the LocateUp method will only look for matches in the first 6124 bytes of any Stringlist item.