Switch to: V9V8V7V6V5

VField Class: Search Methods

VField.ValueExists()

Declaration:

ValueExists(
	inValue as Variant, 
	inSelection as VSet = nil,
	inSearchPref as EvSearch = kPreferIndexed ) as Boolean

Parameters:

  • inValue - The value to search.
  • inSelection - Selection of records.
  • inSearchPref - Specifies if the search should use index.

Description:

Checks if the specified value exists in the specified selection of the records. Returns TRUE if at least one record has a value equal to inValue.

If inSelection is absent then it searches all records of the table. Otherwise, it searches only the records of specified selection.

Example:

found = fld.ValueExists( 5 )
found = fld.ValueExists( 5, S )

VField.ValueExists()

Declaration:

ValueExists(
	inValue as Variant, 
	ByRef outCount as Integer, 
	inSelection as VSet = nill,
	inSearchPref as EvSearch = kPreferIndexed ) as boolean

Parameters:

  • inValue - The value to search.
  • outCount - The count of records that match inValue.
  • inSelection - Selection of records.
  • inSearchPref - Specifies if the search should use index.

Description:

Does the same as the above method ValueExists, but also calculates the count of records that match. So this function requires more time.

Example:

dim count as integer
found = fld.ValueExists( 5, count )
found = fld.ValueExists( 5, count, S )

VField.FindValue()

Declaration:

FindValue(
	inValue as Variant, 
	inSelection as VSet = nil,
	inSearchPref as EvSearch = kPreferIndexed ) as VSet

Parameters:

  • inValue - The value to search.
  • inSelection - Selection of records.
  • inSearchPref - Specifies if the search should use index.

Description:

Finds the specified value in the selection of records. Returns a BitSet of found records.

If inSelection is nil then it searches all records of the table. Otherwise, it searches only records within the specified selection.

Note: You should use this function in the case when you expect a large number of found records. Otherwise it is better to use “FindValueAsArraySet()”.

Example:

dim s1, s2 as VSet
s1 = fld1.FindValue(5)
s2 = fld2.FindValue( 7, s1 )

VField.FindRange()

Declaration:

FindRange(
	inLeftInclude as boolean, 
	inLeftValue as Variant, 
	inRightValue as Variant, 
	inRightInclude as boolean, 
	inSelection as VSet = nil,
	inSearchPref as EvSearch = kPreferIndexed ) as VSet

Parameters:

  • inleftInclude - TRUE if the left value of the range must be included.
  • inLeftValue - The left value of the range.
  • inRightValue - TRUE if the right value of the range must be included.
  • inrRightInclude - The right value of the range.
  • inSelection - Selection of records.
  • inSearchPref - Specifies if the search should use index.

Description:

Finds the records which have values that fit into the specified range of values. Returns a BitSet of found records.

The range of values is defined in a mathematical way, e.g. [leftValue, rightValue] or (leftValue, rightValue). Parameters LeftInclude and RightInclude specify if the endpoints of range should be included or excluded.

If inSelection is nil then it searches all records of the table. Otherwise, it searches only records the specified selection.

Note: You should use this function in case you expect a large number of found records. Otherwise it is better to use “FindRangeAsArraySet()”.

Example:

s1 = fld1.FindRange( true , 5, 8, true )      // [5, 8]
s1 = fld1.FindRange( false, 5, 8, true )      // (5, 8]
s1 = fld1.FindRange( true , 5, 8, false )     // [5, 8)
s1 = fld1.FindRange( false, 5, 8, false )     // (5, 8)

VField.FindSingle()

Description:

FindSingle(
	inValue as Variant, 
	inSelection as VSet = nil,
	inSearchPref as EvSearch = kPreferIndexed ) as Integer

Parameters:

  • inValue - The value to search
  • inSelection - Selection of records.
  • inSearchPref - Specifies if the search should use index.

Description:

Finds the specified value in the selection of records. Returns the RecID of the first found record that matches. You should use this function only if you are sure that you will find one record. The advantage of this function is that you avoid the overhead of Sets.

If inSelection is nil then it searches all records of the table. Otherwise it searches only records of the specified selection.

Example:

foundRecID = fld.FindSingle( 5 )

VField.FindDistinct()

Declaration:

FindDistinct( 
	inSelection as VSet = nil,
	inSearchPref as EvSearch = kPreferIndexed ) as VSet

Parameters:

  • inSelection - Selection of records.
  • inSearchPref - Specifies if the search should use index.

Description:

Returns selection that contains only distinct values.

If inSelection is nil then it searches all records of the table. Otherwise it searches only records of the specified selection.

Example:

dim bset as VSet
bset = fld.FindDistinct()

VField.FindNulls()

Declaration:

FindNulls( 
	inSelection as VSet = nil,
	inSearchPref as EvSearch = kPreferIndexed ) as VSet

Parameters:

  • inSelection - Selection of records.
  • inSearchPref - Specifies if the search should use index.

Description:

Returns all records of the specified selection that have NULL values.

If inSelection is nil then it searches all records of the table. Otherwise it searches only records of the specified selection.

Example:

dim bset as VSet
bset = fld.FindNulls()

VField.FindNotNulls()

Declaration:

FindNotNulls( 
	inSelection as VSet = nil,
	inSearchPref as EvSearch = kPreferIndexed ) as VSet

Parameters:

  • inSelection - Selection of records.
  • inSearchPref - Specifies if the search should use index.

Description:

Returns all records of the specified selection with NOT NULL values.

If inSelection is nil then it searches all records of the table. Otherwise it searches only records of the specified selection.

Example:

dim bset as VSet
bset = fld.FindNotNulls()

String Search Methods

The following methods perform String searches on field values. These functions work for any field type that can convert its value to a String. The result of a comparison depends on the current Collation settings for this field.

All these functions have the optional parameter inSelection. If it is nil then all records of table are searched. Otherwise only records of the specified selection are searched.

VField.FindStartsWith()

FindStartsWith( 
	inValue as String, 
	inSelection as VSet = nil,
	inSearchPref as EvSearch = kPreferIndexed ) as VSet

Parameters:

  • inValue - The search String.
  • inSelection - Selection of records.
  • inSearchPref - Specifies if the search should use index.

Description:

Returns all records of the specified selection which have field value that starts with the specified String.

Note: see additional description at the start of this paragraph.

Example:

dim bset as VSet
bset = fld.FindStartsWith( "Jo" )

VField.FindContains()

Declaration:

FindContains( 
	inValue as String, 
	inSelection as VSet = nil,
	inSearchPref as EvSearch = kPreferIndexed ) as VSet

Parameters:

  • inValue - The search String.
  • inSelection - Selection of records.
  • inSearchPref - Specifies if the search should use index.

Description:

Returns all records of the specified selection which have a field value that contains the specified String.

Note: see additional description at the start of this paragraph.

Example:

dim bset as VSet
bset = fld.FindContains( "Jo" )

VField.FindEndsWith()

Declaration:

FindEndsWith( 
	inValue as String, 
	inSelection as VSet = nil,
	inSearchPref as EvSearch = kPreferIndexed ) as VSet

Parameters: inValue The search String. inSelection Selection of records. inSearchPref Specifies if the search should use index.

Description:

Returns all records of the specified selection which have a field value that ends with the specified String.

Note: see additional description at the start of this paragraph.

Example:

dim bset as VSet
bset = fld.FindEndsWith( "hn" )

VField.FindLike()

Declaration:

FindLike( 
	inValue as String,
	inEscapeChar as String = "\", 
	inSelection as VSet = nil,
	inSearchPref as EvSearch = kPreferIndexed ) as VSet

Parameters:

  • inValue - The search String.
  • inEscapeChar - The character to be used as escape character.
  • inSelection - Selection of records.
  • inSearchPref - Specifies if the search should use index.

Description:

Returns all records of the specified selection which have a field value that matches the SQL search WHERE fld LIKE 'str'.

Note: see additional description at the start of this paragraph.

Example:

dim bset as VSet
bset = fld.FindLike( "%eter" )

VField.FindRegEx()

Declaration:

FindRegEx ( 
	inValue as String, 
	inSelection as VSet = nil
	inSearchPref as EvSearch = kPreferIndexed ) as VSet

Parameters:

  • inValue - The search String.
  • inSelection - Selection of records.
  • inSearchPref - Specifies if the search should use index.

Description:

Returns all records of the specified selection which have a field value that matches the SQL search WHERE fld REGEX 'str'.

Note: see additional description at the beginning of this paragraph.

Example:

dim bset as VSet
bset = fld.FindRegEx( "Pe?" )