KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: "WR Direct find" : a useful new 4D Write command
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: May 12, 2000

The command WR Direct find allows you to search a 4D Write BLOB for a string of text directly - without requiring you to access the contents of the BLOB byte by byte using the curly braces syntax. So using this command you could write a simple 4D method such as:

ARRAY LONGINT(myFoundRecs;0)
$string2find:="test"
ALL RECORDS([MyTable])
For ($i;1;Records in selection([MyTable]))
 $result:=WR Direct Find ([MyTable]myWR_BLOB_;$string2find;0;0)
 If ($result>0)
  INSERT ELEMENT(myFoundRecs;1)
  myFoundRecs{1}:=Record number([MyTable])
 End if
 NEXT RECORD([MyTable])
End for
CREATE SELECTION FROM ARRAY([MyTable];myFoundRecs)

This will go through every record in a table looking for BLOB Write fields that contain the text in $string2find, and then add the record numbers for each found record to an array. Finally, the found set is displayed by re-creating a selection from the array of record numbers.