Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

xprint using$ alignment problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • xprint using$ alignment problem

    Hi helping mind!

    If I want to print with XPRINT USING$("##,###.##",amount) to a HP-Laserprinter the results are not correctly aligned depending on the size of amount, even if I send the head with XPRINT SET POS /X1,Y1) to the same position.

    "*_##,###.##" would work but looks awful.

    I think it has to do with proportiional spacing, but maybe there is a work around

    Thank you

    Bill
    Last edited by Willy K. Marti; 16 Dec 2007, 07:50 AM.

  • #2
    you need to simulate a right or decimal justified tab setting in word, so you must first decide where in the width of the page you want the column of numbers, ie if your scale is in millimeters then say 50mm
    you then
    xprint text size format$(yournumber, "##,###,###.##") to nWidth!, NHeight
    xprint set pos (50 - nWidth!, currenty!)
    then print the number

    Comment


    • #3
      Or, you can right justify numerics with something like...
      Code:
      Xprint  USING$ ("&", RSET$(Format$(yournumber, "#,.##"), %Column_size))
      With a non-proportional font it may not give you exactly what you want, but with a non-proportional font you'll never get numbers aligned perfectly anyway.

      "Courier New" is a monospaced font guaranteed available on all Windows' systems, so you might want to make your output use that or some other monospaced font.

      GetStockObject (%SYSTEM_FIXED_FONT) is also available, but I've had inconsistent results using the GetStockObject () fonts on printers. (But they work great for display on the screen).

      Must be Christmas time or something..

      Code:
      MACRO fmt_Int(intval)    = RSET$(FORMAT$(intval,"* #,"),7)
      MACRO fmt_Bigint (X)     = RSET$(FORMAT$(X,"#,"),14)
      MACRO fmt_money (curval) = RSET$(FORMAT$(curval, "$#,.00"),12)
      MACRO fmt_money2 (curval)= RSET$(FORMAT$(curval, "$#,.00 ;$#,.00-"),12) ' gives '0' in dollar position
      MACRO fmt_money3 (curval)= RSET$(FORMAT$(curval, "$#,.00 ;$#,.00-; "),12) ' gives 'blank when zero'
      
      MACRO fmt_Int0(intval, fsize)    = RSET$(LTRIM$(STR$(intval)), fsize USING "0")
      Above return strings for numeric variables in various forms of right-justification.

      Ho ho ho.

      MCM
      Last edited by Michael Mattias; 16 Dec 2007, 09:17 AM.
      Michael Mattias
      Tal Systems Inc. (retired)
      Racine WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Quite true Michael but of course if you want the the report to look nice you "RSET" on the page not in a field (like a right tab stop).
        As someone who I always respected said "It's not the paintbrush but the artist"

        Comment


        • #5
          Xprint Using$

          Michael is right,

          As I have to print amounts all the time with my accounting
          and payroll programs, The only way is to use a fixed font like Courier New

          You can always change it after the amounts are printed
          but if you want to keep simple, simply use that font all the time

          Have a nice holiday ( and a nice snow storm for those in the path )
          Old QB45 Programmer

          Comment


          • #6
            Guy
            Whilst no doubt your method works, it is not the only way. If you check you will find that the numbers in most common proportional fonts are crafted to be the same width purposfully so that the method I described can work.
            John

            Comment


            • #7
              Thanks to all of you

              while all suggestions offered some solutions, the easiest way was to change to courier new for printig of the amounts.

              I appreciate your help

              Merry Xmas

              Willy K. Marti
              Amlikon, Switzerland

              Comment


              • #8
                I just looked at help file, and could not find an 'XPRINT' option to set the justification.

                Those who use XPRINT might benefit from something like...
                Code:
                XPRINT SET JUSTIFY  RIGHT
                XPRINT SET POS  xPos, ypos  ' where xpos= the right edge of the text to be printed
                XPRINT X$   ' print the text right-justified
                Maybe someone should send that in as a New Feature Suggestion?
                Michael Mattias
                Tal Systems Inc. (retired)
                Racine WI USA
                [email protected]
                http://www.talsystems.com

                Comment

                Working...
                X