Q:

Mask address in Crystal Reports

I am creating a report by Crystal Reports which will mask address field depending upon parameter set to the report. I know this can be done using formula. I can successfully mask with hard coded value. However I need something like password masking. For example, if address is D/302 ABC apartment, it should be displayed as X/XXX XXX XXXXXXXXX. Only characters and numbers to be masked space and special characters not be masked. In addition length of masked data should match actual data.

A:

I think you can use a formula like this:
Local StringVar str := "";
Local NumberVar strLen := Length({User.Address});
Local NumberVar i;
For i := 1 To strLen Do
(
   if (ChrW({User.Address}[i]) in (AscW("A") to AscW("Z"))) or (ChrW({User.Address}[i]) in (AscW("a") to AscW("z"))) or (ChrW({User.Address}[i]) in (AscW("0") to AscW("9"))) Then
       str := str + "X"
   else 
       str := str + {User.Address}[i];
);
str

