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:
If wholeWord equals 1, only the whole word will be searched for. For a string to be found using this option, it must occur between punctuation characters (space, comma and so on). If wholeWord does not equal 1, the character string can either be a whole word or part of a longer word.
If upperCase equals 1, the search will look for a character string whose case matches the case of the original string.
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;1;1)>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