The information in this article applies to:
- Microsoft FoxPro for Windows, versions 2.5 and 2.5a
- Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a
SUMMARY
By using report variables as described below, you can eliminate trailing
zeros after the decimal instead of printing a fixed number of characters
after the decimal.
MORE INFORMATION
The following steps create a report that always prints the first decimal
place but does not print trailing zeros beyond the first decimal place:
- Create a database with one numeric field called Number; length=10,
decimals=4.
- Add sample data to the database; some of the numbers should have zeros
at the end; some should not. For example, 1.1000, 1.1200, 1.1230,
1.1234.
- Create a quick report based on this database.
- Create the following report variables (all variables have an initial
value of 0 [zero] and no calculation). The variables should appear in
the variable list in the same order they are given below.
Variable name Value to store
--------------------------------------------------------
place4 IIF(VAL(RIGHT(STR(number,10,4),1))>0,1,0)
place3 IIF(place4=1 OR
VAL(RIGHT(STR(number,10,3),1))>0,1,0)
place2 IIF(place3=1 OR
VAL(RIGHT(STR(number,10,2),1))>0,1,0)
numplaces 1+place2+place3+place4
- Close the Report Variable dialog box and modify the report expression
containing the numeric field so that is left-aligned and contains the
following expression:
STR(number,5+numplaces,numplaces).
To left-align the field in FoxPro for MS-DOS:
- Select the Style check box while in the Report Expression dialog box,
then choose Left Alignment.
To left-align the field in FoxPro for Windows:
- Select the field on the report, then choose Alignment and Left from
the Object menu.
NOTE: "5+numplaces" along with left-aligning the field will ensure that
the decimals are aligned. If this is not important, "5+numplaces" can be
changed to "10" (without the quotation marks)--the full length of the
field.
- From the Report menu, choose Page Preview to see the output without
trailing zeros beyond the first decimal place.
|