Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
Format describes the rules for acceptable characters that can be entered by the user, or the rules used to display fields or memory variables for output. It is the controls’ equivalent of the FORMAT clause used with @… GET input, and recognizes the same options:
Format character |
Meaning |
A |
Alphabetic characters only. |
B |
Left-justifies numeric data. |
D |
Display in the current date format. Used primarily with date variables, but it works with strings and datetimes. No built-in validation for character strings. |
E |
Use British date format: month-day-year, separators determined by SET MARK TO, century display by SET CENTURY. Same behavior as "D" format. |
I |
Center text within the field (try this, if you must, only with non-proportional fonts!). |
J |
Right-justifies text within field. |
K |
Select entire control on entry to field. This one's here for backward compatibility—use the SelectOnEntry property instead |
L |
Display leading zeroes. Useful only with numeric values. |
Mlist |
Multiple-choice box. While a neat idea, we recommend you stay away from this one, and try listboxes and drop-down lists instead. List consists of comma-delimited explicit text, rather than the variables or data-driven lists possible with other controls. Bad things happen if the variable is undefined or of the wrong type. |
R |
Specifies that characters in the InputMask that do not have special meaning (see InputMask) serve as placeholders in the format mask and are not returned as values to the field. |
Sn |
Scrolling region of n characters. A handy way to squeeze too much text into too little space. Use with the SIZE clause to limit the size of the text box. An edit box is recommended as a better and more intuitive alternative. |
T |
Trim both leading and trailing spaces before returning values to field. |
YS |
Display a date using the Short format from the Control Panel. |
YL |
Display a date using the Control Panel's Long format. |
Z |
Display zeroes as blanks. |
! |
Convert alphabetic to uppercase. |
^ |
Display numbers in scientific notation. Lousy for input—it does not allow typing mantissa nor exponent, only a whole number and decimal place. Use for display only. |
$ |
Display the currency symbols specified with SET CURRENCY. |
The FORMAT property needs to be specified only once and applies to the entire field. This is a “global” format for the field, differing from the InputMask property, which is specified on a character-by-character basis. Because Format and InputMask share many of the same letters, this often leads to confusion. When expressed in a single command, such as an @…SAY clause or a TRANSFORM()
function, FORMAT properties are distinguished by being preceded with an @ symbol.
@ 5,5 get lcSSN picture "@R 999-99-9999" && Social Security #
? TRANSFORM(12345.67, "@$ 999,999.99") && yields $ 12,345.67
* Depending on your Control Panel Regional Settings,
* you may see a different output:
? Transform({^1999-06-02},"@YL")
* yields "Wednesday, June 2, 1999"
* The equivalent of the first example above for a VFP control
ThisForm.txtSSN.Format = "R"
ThisForm.txtSSN.Picture = "999-99-999"
@…Get, InputMask, SelectOnEntry, Set Currency, Set Mark To, Set Point, Set Separator, Transform()