[Lazarus] revamping a very old print

2023-01-07 Thread duilio foschi via lazarus
I would like to give a new life to a very old application that was
written in foxplus (a xbase dialect) in 1990 :)

At that time, the display was 80 char per line and the printer was 132
char per line, so data was printed using the logics you will find at
the bottom of this message.

I wonder if I can still use the old code somehow.

My idea is:

1. I get the printer PageWidth in pixel
PageWidth:=Printer.PageWidth;

2. I get the printer PageHeight in pixel
PageHeight:=Printer.PageHeight;

3. I get the height of a line
LineHeight:=Printer.Canvas.TextHeight('M')+5; // I add a few pixels to
prevent text lines to overlap;

4. I get the number of rows in a page
MaxLinesNo:=PageHeight div LineHeight

5. now lets translate line
   @7,87  SAY "CITTA'PARTITA IVA"

"7" --> translates into  yPos:=LineHeight*7
"87" --> translates into xPos:= round (87/132*PageWidth);

so I write
  Printer.Canvas.Textout(XPos, YPos, 'CITTA'PARTITA IVA');

6. how do I set the size of the font? I am expecting not less than 56
lines in a page, so I shrink the font size until I get
LineHeight <=Printer.PageHeight div 60

7. I am surely missing something. Any help?

Thank you

Peppe


SET DEVI TO PRIN
EJECT
GO TOP
TIT=.T.
DO WHIL .NOT. EOF()
   *  if current row >=max, jump to the new page and print header
   IF PROW()>=56
  TIT=.T.
  EJECT
   ENDI
   IF TIT
  *  print header
  @1,2   SAY "___"
  @1,57  SAY "___"
  @1,112 SAY ""
  @2,1   SAY "|"
  @2,132 SAY "|"
  @3,1   SAY "|  "+AZIENDA
  IF TA="C"
 @3,58  SAY "LISTATO  CLIENTI ALLA DATA ;
"+DTOC(DATE())
  ELSE
 @3,58  SAY "LISTATO  FORNITORI   ALLA DATA ;
"+DTOC(DATE())
  ENDI
  @3,132 SAY "|"
  @4,1   SAY "|"
  @4,132 SAY "|"
  @5,1   SAY "|__"
  @5,56  SAY "___"
  @5,111 SAY "_|"
  @7,2   SAY "CODICERAGIONE SOCIALE  SEDE ;
LEG."
  @7,87  SAY "CITTA'PARTITA IVA"
  @8,79
  TIT=.F.
   ENDI * end print header

   @PROW()+1,1  SAY SUBS(COD_CL,1,2)+"."+SUBS(COD_CL,3,2)+"."+SUBS(COD_CL,;
5,5)
   @PROW(),16   SAY DES_CL
   @PROW(),48   SAY SEDE_LEG
   @PROW(),80   SAY CAP_CITTA
   @PROW(),112  SAY PART_IVA
   SKIP
ENDD
@PROW()+1,1 SAY " "
SET DEVI TO SCRE
RETU
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] revamping a very old print

2023-01-07 Thread Mattias Gaertner via lazarus
On Sat, 7 Jan 2023 19:17:36 +0100
duilio foschi via lazarus  wrote:

>[...]
> 6. how do I set the size of the font?

As normal:

Printer.Canvas.Font.Size:=


>[...]

Mattias
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus