Description

Use this version of Locate when you are dealing with sorted data. This statement returns the location where a specified string should be inserted, according to the specified sorting consideration.

The By clause in the BASIC+ Locate...By statement locates the sorted position (index) of a value.

Syntax

Locate substring In string By seq [Using delim] Setting POS Then | Else statements

Parameters

The Locate...By statement has the following parameters.

ParameterDescription
substringSpecifies the value whose position is to be located in string.
StringDesignates the string that is to be searched.
Seq

Locate...By uses seq to determine placement of substring. The By clause must follow the in clause in this general format. The seq parameter may have any of the following values:

ValueJustification
ALAscending, Left-justified.
ARAscending, Right-justified (numeric).
DLDescending, Left-justified.
DRDescending, Right-justified (numeric).
delimSpecifies the character that is to be used in the search for the substring. It may be any ASCII character. If dynamic arrays

are being searched, delim should be a field mark (@FM), value mark (@VM), or a subvalue mark (@SVM). If a Using clause is not specified, a value mark is assumed. Do not include a delim character in a string expression.

See also

Index()LocateInList()

Example

* This internal subroutine sorts a list.
 
Sort_List:
 
 * LIST is an @FM-delimited list of names.
transfer list to old
* find out how many names
numNames = dcount( old, @fm)
for i = 1 to numNames
  Locate old<i> in list By "AL" Using @fm Setting pos else
   List = Insert(list, pos, 0, 0, OLD<I>)
  end
next i
 
return
  • No labels