udfStrMask
str udfStrMask (str, int, str, int)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfStrMask (strString, intSaveChars, strMaskChar, intDirection)
intLen = StrLen (strString)
If !intlen Then Return ""
intSaveChars = Min (Max (0, intSaveChars), intLen)
If intSaveChars >= intLen Then Return strString
If intDirection == @FWDSCAN Then Return StrOverlay (strString, "", strMaskChar, 1, intLen - intSaveChars)
If intDirection == @BACKSCAN Then Return StrOverlay (strString, "", strMaskChar, intSaveChars + 1, intLen - intSaveChars)
;..........................................................................................................................................
; This UDF "udfStrMask" returns the given string partly overlayed by a given mask character.
; Characters can be saved from masking by setting intSaveChars to a positive value.
; Masking can be done either from the left side of the given string by setting intDirection to @FWDSCAN
; or from the right side by setting intDirection to @BACKSCAN.
;..........................................................................................................................................
; Detlev Dalitz.20091222.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

strMasked100 = udfStrMask ("", 4, "*", @BACKSCAN) ;
strMasked101 = udfStrMask ("1", 4, "*", @BACKSCAN) ; 1
strMasked102 = udfStrMask ("12", 4, "*", @BACKSCAN) ; 12
strMasked103 = udfStrMask ("123", 4, "*", @BACKSCAN) ; 123
strMasked104 = udfStrMask ("1234", 4, "*", @BACKSCAN) ; 1234
strMasked105 = udfStrMask ("12345", 4, "*", @BACKSCAN) ; 1234*
strMasked106 = udfStrMask ("123456", 4, "*", @BACKSCAN) ; 1234**
strMasked107 = udfStrMask ("1234567", 4, "*", @BACKSCAN) ; 1234***
strMasked108 = udfStrMask ("12345678", 4, "*", @BACKSCAN) ; 1234****
strMasked109 = udfStrMask ("123456789", 4, "*", @BACKSCAN) ; 1234*****
strMasked110 = udfStrMask ("1234567890", 4, "*", @BACKSCAN) ; 1234******
strMasked111 = udfStrMask ("12345678901", 4, "*", @BACKSCAN) ; 1234*******
strMasked112 = udfStrMask ("123456789012", 4, "*", @BACKSCAN) ; 1234********
strMasked113 = udfStrMask ("1234567890123", 4, "*", @BACKSCAN) ; 1234*********
strMasked114 = udfStrMask ("12345678901234", 4, "*", @BACKSCAN) ; 1234**********
strMasked115 = udfStrMask ("123456789012345", 4, "*", @BACKSCAN) ; 1234***********
strMasked116 = udfStrMask ("1234567890123456", 4, "*", @BACKSCAN) ; 1234************

strMasked1_1 = udfStrMask ("1234567890", -1, "*", @BACKSCAN)  ; **********
strMasked1_2 = udfStrMask ("1234567890", 0, "*", @BACKSCAN)   ; **********
strMasked1_3 = udfStrMask ("1234567890", 1, "*", @BACKSCAN)   ; 1*********
strMasked1_4 = udfStrMask ("1234567890", 9, "*", @BACKSCAN)   ; 123456789*
strMasked1_5 = udfStrMask ("1234567890", 10, "*", @BACKSCAN)  ; 1234567890
strMasked1_6 = udfStrMask ("1234567890", 11, "*", @BACKSCAN)  ; 1234567890


strMasked200 = udfStrMask ("", 4, "*", @FWDSCAN) ;
strMasked201 = udfStrMask ("1", 4, "*", @FWDSCAN) ; 1
strMasked202 = udfStrMask ("12", 4, "*", @FWDSCAN) ; 12
strMasked203 = udfStrMask ("123", 4, "*", @FWDSCAN) ; 123
strMasked204 = udfStrMask ("1234", 4, "*", @FWDSCAN) ; 1234
strMasked205 = udfStrMask ("12345", 4, "*", @FWDSCAN) ; *2345
strMasked206 = udfStrMask ("123456", 4, "*", @FWDSCAN) ; **3456
strMasked207 = udfStrMask ("1234567", 4, "*", @FWDSCAN) ; ***4567
strMasked208 = udfStrMask ("12345678", 4, "*", @FWDSCAN) ; ****5678
strMasked209 = udfStrMask ("123456789", 4, "*", @FWDSCAN) ; *****6789
strMasked210 = udfStrMask ("1234567890", 4, "*", @FWDSCAN) ; ******7890
strMasked211 = udfStrMask ("12345678901", 4, "*", @FWDSCAN) ; *******8901
strMasked212 = udfStrMask ("123456789012", 4, "*", @FWDSCAN) ; ********9012
strMasked213 = udfStrMask ("1234567890123", 4, "*", @FWDSCAN) ; *********0123
strMasked214 = udfStrMask ("12345678901234", 4, "*", @FWDSCAN) ; **********1234
strMasked215 = udfStrMask ("123456789012345", 4, "*", @FWDSCAN) ; ***********2345
strMasked216 = udfStrMask ("1234567890123456", 4, "*", @FWDSCAN) ; ************3456

strMasked2_1 = udfStrMask ("1234567890", -1, "*", @FWDSCAN)  ; **********
strMasked2_2 = udfStrMask ("1234567890", 0, "*", @FWDSCAN)   ; **********
strMasked2_3 = udfStrMask ("1234567890", 1, "*", @FWDSCAN)   ; *********0
strMasked2_4 = udfStrMask ("1234567890", 9, "*", @FWDSCAN)   ; *234567890
strMasked2_5 = udfStrMask ("1234567890", 10, "*", @FWDSCAN)  ; 1234567890
strMasked2_6 = udfStrMask ("1234567890", 11, "*", @FWDSCAN)  ; 1234567890

Exit