25th January 2017, 12:24
Join Date: Apr 2002
Location: Germany, 50.584097,8.544078
Baan: 2.2/3.1/4c4/LN6.1 FP6/FP9/HiDox -
DB: tbase, ms-sql7, oracle10gV1, 11g -
OS: HP-UX, W2K3, SLES
from DEV-Guide !
BaanERP Programmers Guide
Send feedback about the online Help to Baan Development
long qss.search( long flag, void search, ref void tbl, ref long def [, long dept] )
This searches a specified array for a particular value, which is referred to as the search key. By default, it reads the array sequentially until it finds the specified value (that is, it performs a linear search). To perform a binary search instead, you must first sort the data with qss.sort() and then call qss.search() with the flag argument set to QSS.SRC.IS.SORTED.
This specifies which array element is to be retrieved and the type of search to be performed. You can set the argument to one of the following possible values:
QSS.FIRST Find the first record in the array; the search argument is ignored.
QSS.LAST Find the last record in the array; the search argument is ignored.
QSS.GT Find the first record greater than the search key.
QSS.GTEQ Find the first record greater than or equal to the search key.
QSS.LESS Find the first record less than the search key.
QSS.EQLE Find the first record less than or equal to the search key.
QSS.EQUAL Find the first record equal to the search key.
QSS.NE Find the first record not equal to the search key.
You can combine each of these options with one or more of the following options:
Specifies a binary search. The array must previously have been sorted by using qss.sort().
When this flag is set, the function searches the array for a specified record pattern – that is, it searches for an array element that matches both the structure and value of the search key. The search argument must have the same layout and length as the elements in tbl.
When this flag is not set, the search argument is constructed as the concatenation of the key fields defined by the def argument (see Example 2).
Specifies that the search key can occur more than once in the source array.
The value that you want to search for in the specified array. This is the search key.
This specifies the array that must be searched. It can be a string or an array of type string, long, or double, but it is usually an array of strings.
This indicates how the system is to search the array and against what conditions it must test the elements of the array. The argument must be declared as follows:
long def(x,4) | x is the number of search fields
You can define several search fields (1 to x). For each search field, you define the four search properties by using the following functions. In each case, the field_number argument specifies the sequence number (1 to x) of the search field.
void qss.start( ref long def, long field_number, long position )
This indicates the search field's start position in the array element. For example, this allows you to search a string array for a character combination starting at the fourth character of the array element.
void qss.way( ref long def, long field_number, long way )
This defines the search order that must be used if the flag QSS.SRC.IS.SORTED is set. The argument way can be set to QSS.UP (ascending search) or QSS.DOWN (descending search).
void qss.type( ref long def, long field_number, long type )
This specifies the search field's type – for example, DB.LONG, DB.DOUBLE, DB.STRING, DB.DATE, and so on.
void qss.length( ref long def, long field_number, long length )
This specifies the length of the search field. This option is valid only for strings.
If you define fewer search fields than you have declared, you must close the def argument by calling qss.start() with a start position of zero. For example, if you have declared three search fieldss, as follows:
but then create only two search fields, you must close the definition with the following call:
This indicates the number of array elements (starting with the first element) that must be searched if the function is not intended to search the entire array. By default, the function searches the entire array until it finds the required value.
>0 index in the array where the search key was found
-1 error; search argument not found
-11 search argument must be of same type as array;
def is not of type long array or tbl not of type array
-12 search argument not correct; string not expected
-13 dept must be positive
-14 def argument not correctly declared
-15 search argument does not fit in declared array
-16 QSS.TYPE not correct
-17 tbl argument not correct
-18 no definition found in def
-21 flag LOOKUP.FOR.STRUCT is used; search argument must be a string
-22 search argument not correct; probably a size problem – size of search
must match size of an element in tbl if LOOKUP.FOR.STRUCT is set or
(if LOOKUP.FOR.STRUCT is not set) must be at least the sum of lengths
of the key fields (set by qss.length())
-23 search argument not correct; probably a type problem