No announcement yet.

xprint using$ alignment problem

  • 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

    Last edited by Willy K. Marti; 16 Dec 2007, 08: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


    • #3
      Or, you can right justify numerics with something like...
      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..

      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.

      Last edited by Michael Mattias; 16 Dec 2007, 10:17 AM.
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]


      • #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"


        • #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


          • #6
            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.


            • #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


              • #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...
                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 (retired)
                Port Washington WI USA
                [email protected]