Xbasic

BETWEEN_CHAR Function

Syntax

Filter_Expression as C = between_char(C field ,C char1 ,C char2 )

Arguments

Filter_Expression

A character filter expression that evaluates to a logical value and selects records from a table.

field

The name of a field that you wish to write a filter expression against.

char1

A character variable or value that contains the first or lowest value to include in the filter.

char2

A character variable or value that contains the last or highest value to include in the filter.

Description

Creates a string using the Between() function.

Discussion

BETWEEN_CHAR() returns a character filter expression based on the two character values and selects records from the table. This function is only useful in Xbasic scripts. Field_Name is a character field or expression to search on. Low_Value and High_Value are character variables. They are the first and last values in a range of records to find. Frequently in Xbasic scripts, you need to specify a filter expression in quotes. It can get quite tricky to do this if your Low_Value and High_Value values are stored in variables. For example, the following code fragment shows how to specify a filter expression for an Xbasic query:

dim shared First as C 
 dim shared Last as C

t = tbl.open("customer") 
 query.filter = "between(lastname, " + "\"" + First + "\", " + "\"" + Last + "\")" 
 t.query_create()

Assuming that First contains "Jones", and Last contains "Smith", query.filter will contain the following value:

"between(lastname,\"Jones\",\"Smith\")"

This is a valid filter expression. However, it is very cumbersome to write the expression that defines the query.filter variable. The BETWEEN_CHAR() utility function makes it easier to write this filter expression. For example:

query.filter = between_char("Lastname", First, Last)

If you are searching on fields/expressions of other types, use the appropriate utility function. Assuming that lastname, qty, and invoice_date are field names.

Field Type
Function and Example
Character

BETWEEN_CHAR() between_char("lastname", first, last)

Numeric

BETWEEN_NUM() between_num("qty", first, last)

Date

BETWEEN_DATE() between_date("invoice_date", first, last)

Record number

BETWEEN_RECORD() between_record(first, last)

Example

See Also