QMLocate()

Top  Previous  Next

 

The QMLocate() function searches a dynamic array for a field, value or subvalue matching a given string.

 

 

Format

 

VBQMLocate(ByVal Item as String, ByVal DynArray as String, ByVal Fno as Integer, ByVal Vno as Integer, ByVal Svno as Integer, ByRef Pos as Integer, ByVal Order as String) as Boolean

 

Cint QMLocate(char * Item, char * DynArray, int Fno, int Vno, int Svno, int * Pos, char * Order)

 

where

 

Itemis the item to find.

 

DynArrayis the dynamic array to be processed.

 

Fnois the number of the field at which the search is to begin. If less than 1, 1 is assumed.

 

Vnois the number of the value at which the search is to begin. If less than 1, the function searches for a field containing Item.

 

Svnois the number of the subvalue at which the search is to begin. If less than 1, the function searches for a value containing Item.

 

Posis an integer variable to receive the position information.

 

Orderidentifies the sort method to the applied. This may be:
ALAscending, left aligned
ARAscending, right aligned
DLDescending, left aligned
DR Descending, right aligned

If omitted, no sort order is applied.

 

 

The QMLocate() function searches a dynamic array at one of three levels:

 

If Vno is less than 1, the function searches the dynamic array for a field matching Item, starting at the field position given by Fno.

 

If Vno is given but Svno is less than 1, the function searches field Fno of the dynamic array for a value matching Item, starting at the value position given by Vno.

 

If Vno and Svno are given, the function searches field Fno, value Vno of the dynamic array for a subvalue matching Item, starting at the value position given by Svno.

 

The Order argument determines the sorting system to be applied during the search:

 

If Order is a null string, no sort rules are applied. The function scans all applicable dynamic array elements for a match against Item. The Pos variable will be returned as the position at which the item was found. If the item is not found, Pos will be returned as the position at which a new element could be appended.

 

If the first character of Order is A, an ascending sort is applied. If the first character of Order is D, a descending sort is applied. In either case, the search terminates if an entry is found that would be beyond the correct position for Item. In this case, if the item is not found, Pos will be returned as the position at which to insert Item to maintain the correct sort order.

 

If the second character of Order is L, a left aligned comparison is performed. Each entry of the dynamic array is compared with Item character by character from the left until a difference is found.

 

If the second character of Order is R, a right aligned comparison is performed. If the two items being compared are of different lengths, spaces are added to the front of the shorter item before comparison.

 

The QMLocate() function returns True if the item is found, False if it is not found.