613-518-1166 info@zimdatabases.com

Selected Topics and White Papers

Masking

< All Topics

The Purpose of Masking Patterns

Masking patterns are used to format data values in a manner appropriate to the type of information they represent.

For example, in Zim, dates are stored as a special type of numerical value, in which the first four digits represent the year, the next two represent the month and the last two stand for the day.

As such, the date January 01, 2020 is stored numerically as 20200101. This allows for mathematical operations to be performed on dates, but this format is not intuitive for presentation.

By using a masking pattern, such as “DD/MM/YYYY”, this date value will now be presented as the string “01/01/2020”, which is instantly recognized as a date.

The same masking pattern is also used to format the input of data into a date entry field. Instead of typing 20200101, the end-user can type 01012020, because the separator character / is only presented between the yearmonth and day values, but is not actually part of the date value itself.

The same principle can be applied to separator characters in currency values, postal codes, phone numbers, etc.

Situations in Which Masking Patterns Are Used

Zim offers the possibility of applying data masking patterns in different situations, each with a specific set of fixed and masking characters, as summarized in the table below (follow the links in the first columns for more information):

Masking Definined as Purpose Remarks
Data Mask Entry field property
(DataMask)
Input
Display
  • Defines the expected format of the data value while it is being typed
  • Displayed as the mask pattern before any data is entered into an entry field
  • Formats the display of a data values after it is typed into an entry field
Field Mask Field property
(FieldMask)
Zim Reports
list
output
  • Defines the expected format of the field’s data value when it is printed or listed in Zim Reports,
    or by the list or output commands
MASK Format option i n
Zim Reports
Zim Reports
  • Defines the expected format of the field’s data value when it is printed or listed in Zim Reports
  • When used, overrides the FieldMask property of all fields
$mask Function list
output
  • Defines the expected format of a field or a data value when printed or listed by the list or output commands
  • When applied to a field, overrides its FieldMask property

Masking Characters According to Data Types

The set of available masking characters is different according to the Data Type property (DT) of the entity set field or the entry field.

The following sections describe the available masking characters for each data type:

Alphanumeric Masking

Alphanumeric masking is used to format generic text data. It is particularly useful when data is entered in shortened form but displayed in full form.

In the output value, each question mark is replaced by one character from the current value of the report item, in order from left to right.

When no more characters remain in the value, any remaining question marks become spaces.

Alphanumeric Masking Characters

Masking Character Purpose DataMask FieldMask MASK $mask
? Placeholder for any alphanumeric character
\\? the question mark character ?
<fixed character> Displayed as is

Examples

 

Field Mask      MASK      $mask

Leading or trailing spaces are indicated by / in the Output column.

Mask Pattern Field Value Printed, Listed or Reported Data Value
‘?epartment ??’ D04 Department 04
‘SIN no.: ???-???-???’ 987654321 SIN no.: 987-654-321
‘Part No \\?xyz???\\? 466 Part No ?xyz466?
‘???’ ABCD ABC
‘????’ ABC ABC/

Data Mask

Mask Pattern Presented Typed Data Stored Entry Field Value Displayed Data
??? ABC ABC
(???) ???-???? 2123459786 (212) 345-9786
?epartment ?? D01 Department 01
?epartment ?? D01 abc Department 01 abc

Note:

If the CM (compress status) attribute of a form field is N, the value of the form field is the same as the displayed data. Otherwise, the value of the form field is the same as the input data vlue.

lf the mask pattern is shorter than the field length, then the mask is assumed to contain ? characters in the missing positions (See the last example above).

Non-Digit Masking

Non-digit mask patterns are nearly identical to alphanumeric ones, with the exception that digits (0, 1, …, 9) are not accepted as valid input.

Date Masking

Date masks are composed of three types of character groups, representing the yearmonth and day, which can be combined in any order.

Between each group there may be an optional fixed separator character, such as /., or blank space, which appear in the display or output as is.

For date entry fields, the default masking pattern is MM/DD/YY.

Date Masking Characters

Masking Character Purpose DataMask FieldMask MASK $mask
DD Placeholder for the day (2 digits)
MM Placeholder for the month (2 digits)
YY Placeholder for the year (2 digits)
YYYY Placeholder for the year (4 digits)
<separator> Represents a fixed separator character, usually /., or blank space

Examples

 

Field Mask      MASK      $mask

Leading or trailing spaces are indicated by / in the Output column.

Mask Pattern Entity Set Field Value Printed, Listed or Reported Data Value
DD/MM/YY 20200101 01/01/20
YYYY-MM-DD 20200101 2020-01-01
MM DD YYYY 20200101 01 01 2020

Data Mask

Mask Pattern Presented Typed Data Stored Entry Field Value Displayed Data
MM/DD/YYYY 05231492 14920523 05/23/1492
YYYY-MM-DD 14920523 14920523 1492-05-23
YY/MM/DD 910523 19910523 91/05/23
DD-MM-YY 230591 19910523 23-05-91
MM/DD/YY 052391 19910523 05/23/91

Numeric Masking

 

When the data item contains decimals, the decimal point in the mask pattern is aligned with the decimal point in the value, and digit substitutions are made from right to left for the mask characters to the left of the decimal point, and from left to right for the mask characters to the right of the decimal point.

A series of 9s can therefore be used to force the printing of non-significant zeros to the right of the decimal point (in dollar values, for example). A 9 would also be used to force the printing of leading zeros in serial numbers: for example, 009876.

Any report item whose current value is too large to fit in the specified mask pattern (including the sign output, if applicable) causes the overflow characters (asterisks) to be displayed.

  • the currency placeholder ($) and sign placeholders: plus (+), minus (-), left and right parentheses (( and )), and the special character strings CR and DB

The currency placeholder inserts the applicable currency symbol into the output value.

Sign placeholders reflect the sign of the number (positive or negative) in the output value. The left parenthesis can be used only on the left-hand side of the mask pattern. The CR, DB and left and right parenthesis can be used only on the right-hand side of the mask pattern. The plus and minus signs can be used on either side of the mask pattern.

The plus and minus signs, left parenthesis, and the dollar sign can be used as float characters. A single plus, minus, dollar sign, or left parenthesis can also “float” ahead of a series of other floating characters.

  • fixed text characters

Typically, in the output value, fixed text characters (e.g., commas) appear as is, provided that there are digits remaining to be substituted into the mask or that the mask character 9 forces the output of zeros.

Numeric Masking Characters

Masking Character Purpose DataMask FieldMask MASK $mask
9 Replaced by a digit when matched in the input or 0 when unmatched
Z Replaced by a digit when matched in the input or a blank space when unmatched
* Replaced by a digit when matched in the input or * when unmatched
$ Replaced by the currency symbol as defined in zimlang.zim
. Placeholder for the decimal point as defined in zimlang.zim
, Placeholder for the comma as defined in zimlang.zim
+ Placeholder for the + (plus) sign
Placeholder for the – (minus) sign
CR Placeholder for the CR (credit) symbol, as defined in zimlang.zim
DB Placeholder for the DB (debit) symbol, as defined in zimlang.zim
( Represents ( to the left of negative values, instead of the negative sign “
) Represents ) to the right of negative values, instead of the negative sign “
<fixed character> Displayed as is

Examples

 

Field Mask      MASK      $mask

Leading or trailing spaces are indicated by / in the Output column.

Mask Pattern Entity Set Field Value Printed, Listed or Reported Data Value
‘9,999,999’ 7850606 7,850,606
‘9,999,999’ 78506 0,078,506
‘*,***,***’ 7850606 7,850,606
‘*,***,***’ 78506 ***78,506
‘Z,ZZZ,ZZZ’ 7850606 7,850,606
‘Z,ZZZ,ZZZ’ 78506 ///78,506

Data Mask

Mask Pattern Presented Typed Data Stored Entry Field Value Displayed Data
9999 123 123 0123
999.9 123 12.3 012.3
ZZZZ 123 123 123
ZZZ.Z 123 12.3 12.3
ZZZ,ZZZ.ZZ -123456 -1234.56 -1,234.56
$$$,$$$.$$ CR -123456 -1234.56 $1,234.56 CR
Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Table of Contents