Baanboard.com

Go Back   Baanboard.com

User login

Frontpage Sponsor

Main

Baanboard at LinkedIn


Poll
What actions do you take to ensure compliance with the sanction/embargo lists published by the EU and the US?
don't know what you are talking about
55%
we are scanning customers, suppliers and employees using own programs on a regular basis
12%
each delivery/purchase adress is checked immediately with own programs
2%
we are using third party software for this purpose
10%
we simply don't bother
20%
Total votes: 49

Reference Content

 
qss.search()
By patvdv at 26 Feb 2008 - 21:57


qss.search()

Syntax

long qss.search( long flag, void search, ref void array, ref long def [, long dept] )

Description

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.

Arguments

flag

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:

  • QSS.SRC.IS.SORTED : Specifies a binary search. The array must previously have been sorted by using qss.sort().
  • QSS.LOOKUP.FOR.STRUCT : 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 array. 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).
  • QSS.SRC.DUPL.ALLOWED : Specifies that the search key can occur more than once in the source array.

search

The value that you want to search for in the specified array. This is the search key.

array

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.

def

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:

    def(3,4)

    but then create only two search fields, you must close the definition with the following call:

    qss.start(def,3,0)

dept

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.

Return values

  • >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 array 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 array 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 array 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

Context

Bshell function.

Related topics


0
No votes yet


All times are GMT +2. The time now is 02:16.


©2001-2008 - Baanboard.com - Baanforums.com