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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatted text output from dBase 5

Status
Not open for further replies.

willyw

Programmer
Jul 21, 2005
5
0
0
GB
Does anyone know of any way of improving the formatting capability of dbase? For example, I want to print a report with numeric columns aligned on decimal point, but I also want to use proportional spacing. As far as I know, dbase cannot do this, but maybe I can feed a tagged text file into something that can.
 
you can I think say ? 12345.67 picture "##,###.##"

ChaZ

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
In addition to the PICTURE clause referenced above to line up the decimal, you can send the printer control codes to your printer to establish the font- and I believe proportional spacing. Use the CHR()function and concatenate the codes together to establish the printer control string as a single expression, and send it to the printer.
 
Thanks for the tips. Is PICTURE '##.##' supposed to work with proportional spacing? I don't see how it can, because you would have to position the number vertically with {ESC}&a##C. Then how would the dec point fall under the one in the line above? I would love to solve this one!
 
CHR(13) ... Carriage return
CHR(10) ... Line feed

I wonder if you could set proportional, print your proportional line, send a CHR(13) to reset back to the lefthand column of the same line, then switch to fixed, print spaces out to where you need the numeric column. Then this time send CrLf (CHR(13)+CHR(10) to go to a new line. You'd have to do that for each "mixed" proportional/fixed line, very code intensive, but I wonder if that'll work...

dbMark
 
I am confused.

If you have two numbers, say 50.22 and 117,246.18 and you print them using

? 50.22 picture '###,###.##'
? 117246.18 picture '###,###.##'

You get
50.22
117,246.18

The extra numbers force the spacing, with no need for the cr lf.

Of course, the ? followed by ?? will keep items on the same line, so you can get your cr lf by using that.

There must be something I don't understand here.

ChaZ

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
That would be fine with non-proportional spacing, but with proportional the 1s will close up and move the point to the left, assuming the start position is the same.
 
Not sure anything could do that. I see what you're saying now. Printing:

1,111,111.11
9,999,999.99

will never line up on the decimal because of the difference in the widths of the 1's and the 9's in proportional fonts. I don't know personally of anything that's going to do this for you.

dbMark's approach is the likely the one alternative. I.e. resetting the printer fonts for the numeric output to be non-proportional font and then switching back to proportional for text.

dennis
 
Here's an HP-compatible example of what I was describing. You can add additional PCL commands to use other styles and fonts too. Test and see what works for you.
Code:
SET PRINTER TO LPT1  && local printer
SET PRINT ON

??? CHR(27)+"E"   && Reset printer

??? CHR(27)+"(s1P"  && Proportional spacing
??? "This is proportional text. How do I look?"
??? CHR(13)
??? CHR(27)+"(s0P"  && Fixed spacing
??? SPACE(40)+"$123,456.78"

??? CHR(27)+"E"  && Reset printer
SET PRINT OFF
SET PRINTER TO
RETURN
 
I've added extra lines to show how you can have a proportional column on the left and fixed column on the right. Test and see what works for you.
Code:
SET PRINTER TO LPT1  && local printer
SET PRINT ON

??? CHR(27)+"E"   && Reset printer

??? CHR(27)+"(s1P"  && Proportional spacing
??? "This is proportional text. How do I look?"
??? CHR(13)
??? CHR(27)+"(s0P"  && Fixed spacing
??? SPACE(40)+"$123,456.78"
?
??? CHR(27)+"(s1P"  && Proportional spacing
??? "What is my net worth?"
??? CHR(13)
??? CHR(27)+"(s0P"  && Fixed spacing
??? SPACE(40)+"$      1.23"
?
??? CHR(27)+"(s1P"  && Proportional spacing
??? "How much will my new computer cost?"
??? CHR(13)
??? CHR(27)+"(s0P"  && Fixed spacing
??? SPACE(40)+"$  1,234.56"

??? CHR(27)+"E"  && Reset printer
SET PRINT OFF
SET PRINTER TO
RETURN
 
Neat stuff.

When I did my dbase programming, very early ninties, I ran in dos only, and never even had to consider any of this.

I am pleased the thing is still alive though. I truely enjoyed working with it.

ChaZ

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top