Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Aligning, Decimal points in PCL, centering text 3

Status
Not open for further replies.

umpybear

Programmer
Jan 17, 2003
1
US
Is there a way to align a column of numbers with decimal points (dollars) in PCL. I'm a dBase IV programmer/user. I have a couple of sources of PCL, but there is no mention of this procedure.
Also, I'm seeking a way to center text for special cards on a line by line basis with variable lengths (names).
 
Q. Is there a way to align a column of numbers with decimal points (dollars) in PCL?
A. No

You need to ensure that you have selected a fixed-pitch font (most modern LaserJets and clones support Courier, LetterGothic and LinePrinter (the first two are scaleable, the other is not (because it is a bitmap font)). If you do this you shouldn't have any problems with alignment.

But if you select a proportionally-spaced font (most of the standard LaserJet fonts) you could only achieve alignment of decimal points if you positioned each character exactly - which means that you would have to have knowledge of the font metrics (but from where) to determine the width of each character in your chosen pointsize.
 
I suppose you could do pseudo-fixed-pitch printing of proportionally-spaced fonts, as follows:

position cursor for first character
push cursor position
output first character
pop cursor position
move cursor horizontally by a relative amount which equates to your desired 'pitch'
push cursor position
output second character
pop cursor position
etc., etc.

but this is unlikely to look very good, since narrow characters will appear at the left-side of each (fixed-size) cell of the chosen pitch. But your dots should line up.
 
If you are using a proportional font, and you have no negative numbers with a leading "-" sign, you can simply set the horizontal motion index (HMI) to the width of the numeral. When you set the HMI on a proportional font, only the space is affected. This way all characters preceding the decimal are the same width.
Jim Asman
jlasman@telus.net
 
OR...

Investigate the LO command in HP-GL/2.

Jim Asman
jlasman@telus.net
 
Or you can use this pcl code I use to center text.

ESC&f1000Y -- Define the Text Macro's number
ESCf0X -- Start of Macro
Text you want to print goes here
ESC&f1X -- End of Macro
ESC&f9X -- Makes Macro Temporary
ESCa2880H -- Center of page position for standard 8 1/2 X 11 paper
ESC*vo1T -- Sets Text to be Invisible
ESC&a180P -- Print right to left
ESC(s#V -- the # symbol is half the size of the font you want to use, so if you wanted to use arial 12 you put 6 there.
ESC&f1000Y -- Call Macro Number
ESC&f2X -- Print Macro
ESC*v1oT -- Make Text Visible
ESC&a0P -- Print Left to right
ESC(s#V -- the full number of the font your using. would be 12 for arial 12
ESC&f1000Y -- Call Macro Number
ESC&f2X -- Print Macro

Your Text is now centered! You can change the horizontal number (2880) to center the text to diffrent positions.

What this does is print your text backwards while invisible and at half the font size setting the cursor to be at the right spot to print the text centered perfectly.
 
Why not use a fixed font and format the dollars and cents
with a mask. If no format type command/statement is available simply make the number a string, add spaces to the beginning of the string then print the rightmost however many characters.
EC(10U EC(s0p10h12v0s0b0T
for example -- 0p tells it fixed font 10h12v 10CPI
(10U is a PC-8 ascii font that includes the text line
draw characters.
EC of course stands for hex 1b dec 27
0b is medium weight (how dark)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top