• Pic® Basic


  • Print Blank To

    One of the problems using Pprint and variable width fonts highlighted itself when I wrote a menuing system, I needed to over write what was a line already. Normally I would just count up the spaces needed and add them to the string being printed i.e. 10 characters from the 16 places needing to be overwritten, that’s 6 spaces added to the end.

    Variable width fonts are as it says, variable in width. The Letter “i” is smaller that “W”, now you could count up the number of pixels in each character and then add enough spaces at the end to make up the difference. Spaces though are only 2 pixels wide; to make up the 6 normal spaces required would require 18 variable width spaces. It was to solve this problem I wrote “PBT.INC”

    The PRINT_BLNK_TO macro enables you to define an end point on the currently printed line and print blank spaces to it.

    Syntax: PRINT_BLNK_TO Variable - Variable can be a constant, variable, or expression

    Example:

    INCLUDE "PROTON_G4.INT" ' board defaults
    INCLUDE "PBT.INC" ' THE MACRO
    GLCD_EXTERNAL_PRINT=PPRINT ' FORCE PRINTING VAI PPRINT
    DIM A AS BYTE
    PRINT FONT TIMES_B__9 ' WHAT PRINT TO USE
    CLS
    A = 100
    PRINT INVERSE 1 ' INVERTED PRINTING
    PRINT AT 30, 0,"HELLO" '
    PRINT_BLNK_TO A + 27 ' PRINT TO THE END OF THE LINE
    STOP INCLUDE "TIMES_BOLD_9.FNT"

    contributed by Timothy Box.