4D Write v16

WR Direct find

Home

 
4D Write v16
WR Direct find

WR Direct find 


 

WR Direct find ( blob ; charString ; wholeWord ; upperCase ) -> Function result 
Parameter Type   Description
blob  BLOB in Blob containing a 4D Write area
charString  Alpha in Character string to be searched for
wholeWord  Integer in 0=partial match 1=whole word
upperCase  Integer in 0=ignore uppercase 1=takes uppercase into account
Function result  Longint in Search status

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:

Constant Type Value Comment
wr partial match Longint 0 The character string can either be a whole word or part of a longer word
wr whole word Longint 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:

Constant Type Value Comment
wr ignore uppercase Longint 0 The search is not case sensitive and will find both “Hello”, “hello” and “HELLO“... if you search for “HELLO”
wr case sensitive Longint 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 

WR Find

 
PROPERTIES 

Product: 4D Write
Theme: WR Text Manipulation
Number: 89494

 
HISTORY 

Created: 4D Write 6.5

 
ARTICLE USAGE

4D Write Language ( 4D Write v16)