InputMask

InputMask describes the acceptable characters that can be entered by the user, or formats fields and memory variables for output. It is the controls' equivalent of the PICTURE clause used with @ ... GET input, and recognizes the same options:

InputMask character

Meaning

A

Alphabetic characters only

L

Logical: Allows and displays uppercase and lowercase characters T, F, Y and N

N

Alphabetic and numeric digits only

X

Any character—alphabetic, numeric, symbols

Y

Allows Y,y,N,n for logicals; displays uppercase only

#

Allows digits, signs and spaces

9

For character data: allow entry of digits only. For numeric entry: same as #, above

!

Converts alphabetic to uppercase

$

Displays dollar sign

$$

Floating dollar sign, flush against number

.

Displays correct SET POINT value separating whole number from decimal

,

Displays correct SET SEPARATOR value used to separate thousands


InputMask defines each character of a field; if you want three uppercase characters, you must specify "!!!". This is in contrast to the Format property, which need be specified only once and applies to the entire field. Because Format and InputMask share many of the same letters, this often leads to confusion. When expressed in a single command, such as a SAY clause or the TRANSFORM() function, FORMAT properties are distinguished by being preceded with an @ symbol.

Currency formatting is very handy, but sometimes confusing. The picture clauses to display currency use the USA-specific dollar sign, point and comma, which might cause you to think these were only good for U.S. currency. But, no, Visual FoxPro is an international application—surely Microsoft wouldn't be so America-centric! Well, yes and no. The point and comma are placeholders for the correct currency symbols in your application, as defined with SET POINT and SET SEPARATOR. But the dollar sign is, well, just a dollar sign. To get the proper currency formatting (as specified with SET CURRENCY), you need to use the "$" Format property, not the "$" InputMask.


Example

SET POINT TO ","
SET SEPARATOR TO "."
SET CURRENCY TO " mk"
SET CURRENCY RIGHT
* The next line displays "$ 12.345,00" — wrong!
? TRANSFORM(12345, "$ 999,999.99")
* This next example works correctly using the $ Format.
? TRANSFORM(12345, "@$ 999,999.99")  && DISPLAYS "12.345,00 mk"
 
* An input field for Social Security numbers, and the variable 
* only stores 9 digits, saving the space wasted with the hyphens
ThisForm.txtSSN.Format = "R"
ThisForm.txtSSN.InputMask = "999-99-999"

See Also

@...Get, Format, Transform(), Set Currency, Set Point, Set Separator


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .