KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility method to get Initials from a name or any given tokenized text
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: July 26, 2022

The following is a utility method that returns the initials of a given full name or a tokenized text.

// Method: textGetInitials
#DECLARE($data_t : Text)->$initial_t : Text
var $data_c : Collection
var $token_t : Text

$initial_t:=""
$data_c:=Split string($data_t; " ")
For each ($token_t; $data_c)
  If (Length($token_t)>0)
    $initial_t:=$initial_t+Uppercase($token_t[[1]])
  End if
End for each


For example:

$Initials:=textGetInitials("John Williams") // Return "JW"

$Initials:=textGetInitials("Object Relational Data Access") // Return "ORDA"