WR Direct find
version 6.5
WR Direct find (blob; charString; wholeWord; upperCase) Longint
Parameter | Type | Description | |
blob | Blob | Blob containing a 4D Write area | |
charString | Alpha | Character string to be searched for | |
wholeWord | Integer | 0=partial match | |
1=whole word | |||
upperCase | Integer | 0=ignore uppercase | |
1=takes uppercase into account |
Function result Longint Search status
Description
The WR Direct find command allows you to directly search for a character string in a BLOB that contains a 4D Write area. Using this command does not require the BLOB to be opened in a 4D Write area first. This means that this command executes very quickly.
If the character string is found, WR Direct find returns the position of the character string in the text.
If the search was unsuccessful, WR Direct find returns -1.
If blob does not represent the contents of a 4D Write area, WR Direct find returns -2.
wholeWord and upperCase allow you to choose some options for the search.
In the wholeWord parameter, you can pass one of the following constants, found in the WR Parameters theme:
Constants (value) | Description |
wr partial match (0) | The character string can either be a whole word or part of a longer |
word | |
wr whole word (1) | To be found, the word must occur between separator characters |
(spaces, punctuation marks, etc.) |
In the upperCase parameter, you can pass one of the following constants, found in the WR Parameters theme:
Constants (value) | Description |
wr ignore uppercase (0) | The search is not case sensitive and will find both "Hello", "hello" and |
"HELLO"... if you search for "HELLO" | |
wr case sensitive (1) | The search is case sensitive and will not find "Hello" if you are |
searching for "HELLO" |
Example
This example proposes a keyword-based search method that searches in a selection of records. Your database manages cooking recipes. The 4D Write areas are saved in BLOB fields. You want to be able to find all recipes that use a specific ingredient. Here is the corresponding method, which is very fast:
ToFind:=Request("Enter the ingredient(s) to find:")
`Creating an empty set in which all found records will be placed
CREATE EMPTY SET([MyRecipes];"FoundRecords")
ALL RECORDS([MyRecipes]) `Browsing all the table selection
While (Not(End selection([MyRecipes])))
If (WR Direct find ([MyRecipes]BlobRecipe_;ToFind;wr whole word;wr case sensitive)>0)
`If the ingredient is found, the record is added to the set
ADD TO SET([MyRecipes];"FoundRecords")
End if
NEXT RECORD([MyRecipes])
End while
USE SET("FoundRecords")
OUTPUT FORM([MyRecipes];"Output")
MODIFY SELECTION([MyRecipes];*)
See Also