- Automatic management of composite keys
- Filter and filtered browse:
- Enabling/Disabling a filter
- Data files not in HFSQL format
<Source>.FilterStartsWith (Function) In french: <Source>.FiltreCommencePar
Not available with this kind of connection
MyKey is string // Selects all the customers living in a city whose name starts with "Mon" MyKey = Customer.FilterStartsWith(City, "Mon") Customer.ReadFirst(MyKey) WHILE NOT Customer.Out() Trace(Customer.CustomerName, Customer.City) Customer.ReadNext(MyKey) END ... // Cancels the filter Customer.DeactivateFilter()
Syntax
<Result> = <Source>.FilterStartWith(<Key item> , <Filter for key component 1> [, <Filter for key component 2> [... [, <Filter for key component N>]]])
<Result>: Character string Browse item. Corresponds to:- the search key of data file if the filter is enabled
- an empty string if the filter cannot be implemented
<Source>: Type corresponding to the specified source Name of HFSQL data file, view or query used. <Key item>: Character string (with or without quotes) Name of key item onto which the filter will be applied. This item can be a simple key (string) or a composite key. Caution: this parameter must only contain letters, underlined characters or digits. Otherwise, the name must be enclosed in quotes. <Filter for key component 1>: Type of first component of search key Value sought for the first component (the 2nd respectively) of composite key. The type of this parameter must correspond to the type of key item component on which the filter is defined. <Filter for key component 2>: Type of second component of search key Value sought for the second component of composite key. The type of this parameter must correspond to the type of key item component on which the filter is defined. <Filter for key component N>: Type of component N of search key Value sought for component N of composite key . The type of this parameter must correspond to the type of key item component on which the filter is defined. Remarks Automatic management of composite keys <Source>.FilterStartsWith automatically manages the filters on the simple keys and on the composite keys. Example 1: Using <Source>.FilterStartsWith with a simple key:
Res = Customer.FilterStartsWith(Name, "A") // Select all the customers whose name starts with A
Example 2: Using <Source>.FilterStartsWith with a key made of two items:
// Example where LastNameFirstname is a key made of: LastName + FirstName // Select all customers whose last name is SMITH // and whose first name starts with a C Res = Customer.FilterStartsWith(LastNameFirstName, "SMITH", "C")
This line of code is equivalent to:
Customer.Filter(LastNameFirstName, ... Customer.BuildKeyValue(LastNameFirstName, "SMITH", "C") + hMinVal, ... Customer.BuildKeyValue(LastNameFirstName, "SMITH", "C") + hMaxVal)
Example 3: Using <Source>.FilterStartsWith with a key made of three items:
// Example with CUSTINV a key made of: CustomerNumber+Date+Time // All the invoices of a customer (sorted by date) Res = Invoice.FilterStartsWith(CUSTINV, Customer.CustNum)
This line of code is equivalent to:
Invoice.Filter(CustInv, ... Invoice.BuildKeyValue(CustInv, Customer.CustNum) + hMinVal, ... Invoice.BuildKeyValue(CustInv, Customer.CustNum) + hMaxVal)
Example 4: Using <Source>.FilterStartsWith with a key made of three items:
// Example with CUSTINV a key made of: CustomerNumber+Date+Time // All the invoices of a customer for today (sorted by date) Res = Invoice.FilterStartsWith(CustInv, Customer.CustNum, Today())
This line of code is equivalent to:
Invoice.Filter(CustInv, ... Invoice.BuildKeyValue(CustInv, Customer.CustNum, Today()) + hMinVal, ... Invoice.BuildKeyValue(CustInv, Customer.CustNum, Today()) + hMaxVal)
Filter and filtered browse: After the call to <Source>.FilterStartsWith, the data file must necessarily be browsed on the item returned by <Source>.FilterStartsWith. The filter will be ignored if another item is used to browse the data file. When a filter is defined and enabled on a data file (view or query), all records read correspond to the filter. If no other record corresponds to the filter during the browse: - <Source>.Out returns True
- the current record corresponds to the last record read with the filter.
For example: | | On a filtered data file, after the function: | the current record is: |
---|
HReadFirst | the first file record corresponding to the filter. | HReadLast | the last file record corresponding to the filter. | HReadNext (or HForward) | the next record (or the next Nth record) corresponding to the filter. | HReadPrevious (or HBackward) | the previous record (or the previous Nth record) corresponding to the filter. |
Enabling/Disabling a filter - <Source>.DeactivateFilter is used to disable a filter.
- <Source>.ActivateFilter is used to re-enable a filter.
- The filter is deleted when the data file (query or view) is closed (<Source>.Close for example).
- A single filter can exist at a given time on a data file (query or view). If <Source>.FilterStartsWith is used several times, only the last filter will be taken into account: the previous filters will be deleted. Similarly, if several filters are used (HFilter* functions), only the last filter will be taken into account.
This page is also available for…
|
|
|