How to Right-Justify Numeric Fields with @ ... SAY

Last reviewed: June 26, 1995
Article ID: Q103829
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a
  • Microsoft FoxBASE+ for the Macintosh, version 2.01

If a proportional font is used with @ ... SAY commands to output fields to a printer, the fields will not appear right-justified.

To work around this problem, the following code example could be implemented in a coded report to create right-justified numeric fields with a proportional font.

   USE \foxprow\tutorial\customer.dbf
   SET PRINT FONT "Arial",12  && sets the font for @ ... SAYs to print
   SET DEVICE TO PRINT
   SET PRINT ON
   mrow=5                && the beginning print row

   DO WHILE RECNO()<15   && prints the first 14 records

      * The following line converts the numeric field to a
      * string and adds commas for formatting

      strytd=TRANSFORM(ytdpurch,"999,999.99")
      mslot=LEN(strytd)  && the number of characters in the field
      mcolumn=30         && the position for the rightmost character

      * The following loop prints one character at a time from right
      * to left until the specified position in the field is a space

      DO WHILE SUBSTR(strytd,mslot,1)<>" "

         @mrow,mcolumn SAY SUBSTR(strytd,mslot,1)
         mslot=mslot-1      && decrement position of field to look at
         mcolumn=mcolumn-1  && decrement printer column

      ENDDO

      SKIP               && move to the next record
      mrow=mrow+1        && increment printer row

   ENDDO
   SET DEVICE TO SCREEN
   SET PRINT OFF
   SET PRINT TO


Additional reference words: FoxWin 2.50 2.01 number report justify align
right foxbase+/mac
KBCategory: kbprg kbcode
KBSubcategory: FxprintFont


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 26, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.