Tech Tip: Comparing 2 email addresses
PRODUCT: 4D | VERSION: 15.x | PLATFORM: Mac & Win
Published On: August 1, 2017
Comparing 2 email addresses can be a bit tricky due to the fact that the At-Sign character (@) is used as a wildcard character in 4D. The easiest way to deal with this is to enable the Database-text-comparison to consider @ as a wildcard only when it appears at the beginning or ending of the text patterns.
If the application requires a use of the wildcard anywhere in text patterns, use a utility method below to perform the email comparison task.
// Method: compareEmailAddresses // Description // Check if the given 2 email addresses are the same // // Parameters // $1 - Email address // $2 - Email address // // Return // $0 - True is both emails are the same // ---------------------------------------------------- C_BOOLEAN($0) C_TEXT($1;$emailAddress1_t;$2;$emailAddress2_t) If (Count parameters>=2) $emailAddress1_t:=Uppercase($1) $emailAddress2_t:=Uppercase($2) $emailAddress1_t:=Generate digest($emailAddress1_t;4D digest) $emailAddress2_t:=Generate digest($emailAddress2_t;4D digest) If ($emailAddress1_t=$emailAddress2_t) $0:=True End if End if |