The print output does not appear in the expected position when you try to use raw mode printing with the "@...SAY" command in Visual FoxPro for Windows 3.0 and in FoxPro for Windows 2.6a (156032)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
- Microsoft Visual FoxPro for Windows 3.0b
- Microsoft FoxPro for Windows 2.6a
This article was previously published under Q156032 SYMPTOMS
In both FoxPro for Windows and Visual FoxPro for Windows, when attempting
to use raw mode printing with @...SAYs that changes the formatting of a
word or words on the same line of output, the printed words following the
format changes will not print in the expected position. The text after the
escape codes will be moved to the left one column for each escape code that
is inserted in the @...SAY.
CAUSE
When FoxPro executes a series of @...SAYs, it determines the output column
of the first @...SAY, determines the length of the output text, and then
pads the remaining columns with spaces up to the next @...SAY command.
Therefore, when FoxPro calculates the column position of the @...SAY of the
next word in the line of output, it includes the escape codes as viable
columns. However, when the output is sent to the printer, the printer
removes these escape codes from the line and executes the command. Since
escape codes are printer commands, they are essentially treated as null
characters and the following text is moved to the left one column for each
escape code the printer uses.
WORKAROUND
There are two ways to work around this behavior. Use one of the following
methods:
Method 1
With this method, the second @...SAY command must take into account the
number of escape codes entered, and the column number must be incremented
accordingly. For example, if the name needs to be printed in column 35, the
code would appear as follows:
@1,1 SAY CHR(27)+ '(s3B' + 'Pay to the order of:' &&BOLD on
@1,40 SAY CHR(27)+ '(s30' + 'John Doe' &&BOLD off
Note that the second @...SAY has incremented the column count by five to
offset the five escape codes.
Method 2
This method requires the ability to move the printer head to an exact
column position with an escape code. If this is possible, then the two text
portions of the @...SAY are concatenated along with the escape code that
moves the second text to an exact column number. The following example
demonstrates printing the name in column 35 on a Hewlett-Packard LaserJet:
* Escape code CHR(27)+'&35C' starts the name in column 35
@1,1 SAY CHR(27)+ '(s3B' + 'Pay to the order of:;
'+CHR(27)+'(s0B'+CHR(27)+'&a35C'+'Jack Doe'
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 2/8/2005 |
---|
Keywords: | KB156032 |
---|
|