4D v16.3

Filter and format codes

Home

 
4D v16.3
Filter and format codes

Filter and format codes  


 

 

Preliminary note: This section describes the characters used to set Alpha entry filters and display formats. The characters used for Number display formats are described in Display formats.

An entry filter code has three parts, in this order:

initiator "argument" placeholders

  • The initiator informs 4D that the subsequent argument is to be used as a filter during data entry in the field.
  • The argument defines the characters to be allowed.
  • The placeholders set the places available for the characters.

For example, the following entry filter allows only the letters “a,” “b,” “c,” or “g” to be entered in two places:

&"a;b;c;g"##

In this example, the ampersand (&) is the initiator; the “a;b;c;g” is the argument; and the number signs (#) are the placeholders. The filter can be read as, “Allow the letters ‘a’, ‘b’, ‘c’, or ‘g’ in two places.” Thus the user may enter “ag,” “gc,” “ba,” “ab,” “aa,” “ac,” or any other combination of the four allowed characters.

Entry filters can be combined. The following entry filter allows only the letters “a,” “b,” “c,” or “g” to be entered in two places, followed by the numbers 1, 3, or 8 in one place:

&"a;b;c;g"#,#&"1;3;8"#

The user must use two of the allowed letters, followed by one of the allowed numbers.

A display format combines placeholders and standard characters.

Two characters initiate a filter: the ampersand (&) and the tilde (~). These characters instruct 4D to use the argument that follows immediately as the filter for the subsequent placeholders.

In addition, the tilde (~) also instructs 4D to make any letters uppercase. It does not prevent a lowercase letter from being typed; it simply changes it to an uppercase letter.

Take a look at the following filters:

&"P"#
~"P"#

The difference between them is that the filter initiated with the ampersand (&) does not accept a lowercase “p.” The filter initiated with the tilde (~) accepts the lowercase “p” but converts it to uppercase.

Because no letters are involved, the following entry filters are equivalent:

&"1;5;8"#
~"1;5;8"#

A filter argument follows the initiator and defines the characters that are allowed in the subsequent placeholders. To create a filter argument, surround the characters to be allowed with quotation marks.

Arguments are made up of lowercase letters, uppercase letters, numbers, punctuation marks, and special characters (!@#$%^&*(){}[]":';?><,./`~). If you use a lowercase letter in the argument, only the lowercase form of the letter can be typed by the user. If you use an uppercase letter in the argument, only the uppercase form of the letter can be typed by the user.

  • An argument may be a single character (a letter or a number), for example, “j,” “J,” or “6.”
  • An argument may be a set of characters separated by semicolons, for example, “a;r;t” or “1;5.”
  • An argument may include ranges of characters. A range is defined by the first character, a hyphen, and the last character. Examples are, “a-c” and “1-5.” The “a-c” argument is equivalent to “a;b;c” and “1-5” is equivalent to “1;2;3;4;5.”
  • An argument may include single letters, single numbers, and one or more ranges, for example, “a;m-z;3;5-9.”

The following table shows useful shorthand versions of arguments. They are used in filters without quotation marks:

CharacterMeaningEquivalent
9Allow numbers"0-9"
aAllow lowercase and uppercase"a-z;A-Z"
AAllow uppercase"A-Z"
@Allow alphanumeric"a-z;A-Z;0-9"

The following entry filters are equivalent:

&9#
&"0-9"#
&"1;2;3;4;5;6;7;8;9;0"#

The following entry filters are equivalent:

&a#
&"a-z;A-Z"#

The following entry filters are equivalent:

&A#
&"A-Z"#

The number sign (#) is the only placeholder for Alpha filters and formats (other characters are available for Number filters and formats). You use one number sign for each character the user can enter in the field.

For example, the following entry filter allows the user to enter letters in four places:

&a####

The following entry filter allows the user to enter uppercase letters in three places, followed by numbers in two places:

&A###&9##

If you show no placeholders, the filter code allows any number of characters. The following entry filter allows the user to enter only numbers, but it does not limit the length of the entry:

&9

Note: You can set the maximum number of characters allowed in an Alpha field in the Structure editor (see 4D field types).

When a field with an entry filter is selected for data entry, 4D displays an underline (_) for each placeholder. As the user types a valid character, each underline is highlighted and replaced with the typed character.
You instruct 4D which character to substitute for the underline by beginning the entry filter with an exclamation point (!) and the character you want. 

You can substitute any character for the underline. For example, if you display “XXXX” and the user types only two of the allowed characters (say they are “AA”), the field will contain “AAXX” when the record is saved.

The following illustration shows a selected field displaying underlines and zeros.

Any characters, punctuation marks, and spaces can be used as dead characters. Dead characters are displayed during data entry, but they are skipped over by the insertion point and are not entered as part of the data.

The characters you want to use as dead characters are placed before, after, and between placeholders. They are displayed during data entry for clarity.

The phone number entry filter (&9(###) ###-####) uses parentheses, a space, and a dash as dead characters. After you enter a digit immediately preceding a dead character, the insertion point moves directly to the first character following the dead character.

 
PROPERTIES 

Product: 4D
Theme: Filters and formats

 
HISTORY 

 
ARTICLE USAGE

4D Design Reference ( 4D v16)
4D Design Reference ( 4D v16.1)
4D Design Reference ( 4D v16.3)