KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility method that returns a collection of unique keywords from a given text
PRODUCT: 4D | VERSION: 19 R | PLATFORM: Mac & Win
Published On: June 20, 2022

Natively, 4D has a command named GET TEXT KEYWORD that splits individual words from a given text and populates a Text array with unique words. If there is ever a need to acquire unique keywords in the form of collection, the following method can be used to simplify the code.

// Method: getKeyWords
#DECLARE($data_t : Text)->$keyword_c : Collection
$keyword_c:=New collection
If (Count parameters>=1)
   ARRAY TEXT($keywords_at; 0)
   GET TEXT KEYWORDS($data_t; $keywords_at; *)
   ARRAY TO COLLECTION($keyword_c; $keywords_at)
End if
$0:=$keyword_c