No announcement yet.

XPRINT and the extended ASCII character set

  • Filter
  • Time
  • Show
Clear All
new posts

  • XPRINT and the extended ASCII character set

    ' I'm having a bit of a problem with XPRINT and hope somebody
    ' can figure out why. This is related to XPRINTing the extended
    ' ASCII character set.
    ' I do my finances almost exclusively on-line and computer,
    ' but I groove on having a paper backup. Hence, here is my
    ' paper "Register".
    ' On the screen, everything displays perfectly but when it
    ' comes to XPRINTing things get squirrely.
    ' All the extended ASCII characters get changed to something
    ' else. I've tried various fonts and printer settings, all to
    ' no avail.
    ' Anybody?????
    #COMPILE EXE                                            '
    FUNCTION PBMAIN () AS LONG                              '
        LOCAL x AS LONG                                     '
        CONSOLE SCREEN 25,82                                '
        COLOR 14,1                                          '
        CLS                                                 '
              Header$ = " Date   Number  Payee" + SPACE$(24)'
    Header$ = Header$ + "Amount    Deposit   Clr   Balance" '
    TopRow$ = CHR$(201) + STRING$(80,205) + CHR$(187)       '
        MID$(TopRow$, 8,1) = CHR$(203)                      ' Check Number
        MID$(TopRow$,16,1) = CHR$(203)                      ' Date
        MID$(TopRow$,45,1) = CHR$(203)                      ' Payee
        MID$(TopRow$,55,1) = CHR$(203)                      ' Payee amount
        MID$(TopRow$,65,1) = CHR$(203)                      ' Deposit amount
        MID$(TopRow$,68,1) = CHR$(203)                      ' Cleared?
    MidRow$ = CHR$(204) + STRING$(80,205) + CHR$(185)       '
        MID$(MidRow$, 8,1) = CHR$(206)                      '
        MID$(MidRow$,16,1) = CHR$(206)                      '
        MID$(MidRow$,45,1) = CHR$(206)                      '
        MID$(MidRow$,55,1) = CHR$(206)                      '
        MID$(MidRow$,65,1) = CHR$(206)                      '
        MID$(MidRow$,68,1) = CHR$(206)                      '
    BotRow$ = CHR$(200) + STRING$(80,205) + CHR$(188)       '
        MID$(BotRow$, 8,1) = CHR$(202)                      '
        MID$(BotRow$,16,1) = CHR$(202)                      '
        MID$(BotRow$,45,1) = CHR$(202)                      '
        MID$(BotRow$,55,1) = CHR$(202)                      '
        MID$(BotRow$,65,1) = CHR$(202)                      '
        MID$(BotRow$,68,1) = CHR$(202)                      '
    MidSep$ = CHR$(186) + STRING$(80, 32) + CHR$(186)       '
        MID$(MidSep$, 8,1) = CHR$(186)                      '
        MID$(MidSep$,16,1) = CHR$(186)                      '
        MID$(MidSep$,45,1) = CHR$(186)                      '
        MID$(MidSep$,55,1) = CHR$(186)                      '
        MID$(MidSep$,65,1) = CHR$(186)                      '
        MID$(MidSep$,68,1) = CHR$(186)                      '
        LOCATE 1,1 : PRINT;Header$                          '
        LOCATE 2,1 : PRINT;TopRow$                          '
        FOR x = 4 TO 22 STEP 2                              '
        LOCATE x,1                                          '
        PRINT;MidRow$;                                      '
        NEXT x                                              '
        FOR x = 3 TO 23 STEP 2                              '
        LOCATE x,1                                          '
        PRINT;MidSep$;                                      '
        NEXT x                                              '
        LOCATE 24,1                                         '
        PRINT;BotRow$;                                      '
        IF WAITKEY$ = CHR$(27) THEN EXIT FUNCTION           ' Abort printout
        XPRINT ATTACH CHOOSE                                '
        XPRINT FONT "courier new", 10, 0                    '
        XPRINT Header$                                      '
        XPRINT TopRow$                                      '
        FOR x = 1 TO 30                                     '
        XPRINT MidSep$                                      '
        XPRINT Midrow$                                      '
        NEXT x                                              '
        XPRINT MidSep$                                      '
        XPRINT;BotRow$                                      '
        XPRINT FORMFEED                                     '
        XPRINT CLOSE                                        '
    END FUNCTION                                            '
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

  • #2
    I found that the "Terminal" font displays those graphic characters.
    I used Hagsten's Charmap to find it.


    • #3
      MS Linedraw and Generic DOS fonts also will display the extended character set if you mean the line drawing characters.
      Client Writeup for the CPA

      Links Page


      • #4
        If moving to XPRINT format, why not 'do it right' and start using XPRINT LINE?

        Besides, the use of the old line-draw characters will produce the output wanted ONLY with monospaced (non-proportional) fonts.

        Surely you can come up with a couple of little functions you call instead of doing an "XPRINT TopRow$"

        e.g (off the top of my head)
        ' param: y = veritical location of the line.
        FUNCTION PrintTopRow (Y AS SINGLE)
         LOCAL Width AS SINGLE, Height As SINGLE
         LOCAL nLeft  AS SINGLE, nRight AS SINGLE, nTOp AS SINGLE, nBottom AS SINGLE 
         XPRINT GET SIZE TO Width, Height 
         XPRINT GET MARGIN TO nLeft, nRight, nTop, nBottom
         XPRINT LINE  (nLeft, Y) - (Width - nRight, Y) 
        Something close to that, anyway. For that matter, there's an XPRINT BOX printing function you could use. That would require you keep track of where the 'boxed' text begins but that's not such a big deal is it?

        Your old MS-DOS code is 'thinking' in lines... with Windows printing you need to learn to think in "pages". It's kind of like an Etch-a-Sketch except you CAN pick up the stylus and move it around the page without drawing.

        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]


        • #5

          Michael is right,

          The BOX command is very eazy to use and you can also
          have round corners.
          If you also use color, your output will look like it is coming
          from a printer shop !
          You will forget very quickly about drawing old style caracter
          based boxes.
          Those are good only if you still LPRINT with old matrix printers.
          To test my XPRINT outputs, I use a virtual PDF printer that print your report on screen in full color without wasting any paper. Google FreePrimoPDF32Setup.exe to get it free
          You will love it and you can save all your accounting in PDF
          Old QB45 Programmer


          • #6
            I agree with Michael and Guy. Line and Box is the way to go.

            For one thing, Line takes up only the width that u set. Whereas the
            line draw characters take up a whole line and character space.
            Client Writeup for the CPA


            Links Page


            • #7
              Mel, From the behaviour that you describe I think the problem may arrise from your ASCII-encoded text being interpreted by the printer as though it were ANSI-encoded. If this is so what you have to do is to make the text undergo a ASCII-ANSI conversion before you print it.There is almost certainly an API to do this, but I know neither its name nor its syntax. Howeveit it is very easy to write your own FUNCTION to do this. As I am sure you know Characters 0-127 are (almost) the same in all flavours of ASCII and ANSI, but characters 128-255 are quite different in ANSI from what they are in ASCII. Thus a lower case e with an acute accent is character 130 in ASCII (usually) but character 233 in ANSI. What you should do first is obtain a listing of characters 128 to 255 of the version of ASCII that your computer is using. This is most easily done by writing a simple program like FOR I& = 128 to 255: PRINT I&, CHR$(I&):NEXT I& or by finding what is the active code page on your computer and looking it up in a book or on the WEB. To find what is the active code page type chcp at the Command Prompt. You then have to obtain a listingof Characters 128 to 255 in ANSI code and see how a character's number changes on going from ASCII to ANSI.Then write a FUNCTION which has lots of lines like REPLACE CHR$(130) WITH CHR$(233) IN MYTEXT$ However, you must be very careful about the order and not have, for example, the line above followed by REPLACE CHR$(233) WITH CHR$(218) IN MYTEXT$You then call this function ever time that you want to print.Even if your printer is not interpreting your text as though it were ANSI-encoded you can still use this approach provided there is a 1-to-1 relationship between what you want to be printed and what is printed. Best wishes Brian
              Last edited by Brian Capon; 7 Feb 2008, 10:50 AM.