Microsoft KB Archive/103829: Difference between revisions

From BetaArchive Wiki
m (Text replacement - """ to """)
m (Text replacement - "&" to "&")
 
(2 intermediate revisions by the same user not shown)
Line 18: Line 18:


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


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


       * The following line converts the numeric field to a
       * The following line converts the numeric field to a
Line 28: Line 28:


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


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


       DO WHILE SUBSTR(strytd,mslot,1)&lt;&gt;" "
       DO WHILE SUBSTR(strytd,mslot,1)<>" "


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


       ENDDO
       ENDDO


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


   ENDDO
   ENDDO

Latest revision as of 11:25, 21 July 2020

HOWTO: Right-Justify Numeric Fields with @ ... SAY

ID: Q103829

The information in this article applies to:

  • Microsoft Visual FoxPro for Windows, versions 3.0, 5.0, 5.0a, 6.0
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.6
  • Microsoft FoxBASE+ for the Macintosh, version 2.01, 2.6

SUMMARY

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
   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 TO

Additional query words: number report justify align right foxbase+/mac

Keywords          : kbPrinting kbVFp300 kbVFp500 kbVFp600 kbVFP260 kbVFP250 kbVFP250a 
Issue type        : kbhowto

Last Reviewed: January 2, 1999
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.