Showing posts with label Printer. Show all posts
Showing posts with label Printer. Show all posts

Thursday, April 23, 2020

PRINT.P

[Table of Contents]

PRINT.P is a sample program that resides on the Kyan Pascal 2.x Disk 2. It is a sample program / utility used to output text files from disk to the printer, with the option of including line numbers. Here the sample run uses the utility to print itself.

Source Code


PROGRAM Print;
TYPE
    String15 = ARRAY[1..15] OF Char;
VAR
  n,x: Integer;
    c: Char;
    f,printer: Text;
    s: String15;

BEGIN
 x:=0;
 n:=1;
 Write('FILENAME? '); Readln(s);
 Write('Line numbers(Y/N)? '); Readln(c);
Rewrite(Printer,'P:');
 Reset(f,s);
WHILE NOT EOF(f) DO
 BEGIN
  IF (c='Y') AND (x=0) THEN
   BEGIN
    x:=1;
    IF n<10 THEN Write(printer,'000',n,'  ');
    IF (n>9) AND (n<100) THEN Write(printer,'00',n,'  ');
    IF (n>99) AND (n<1000) THEN Write(printer,'0',n,'  ');
    IF n>999 THEN Write(printer,n,'  ')
 END;
 IF EOLn(f) THEN
            BEGIN
             x:=0;
             n:=n+1;
             Writeln(printer)
            END
    ELSE Write(printer,f^);
 Get(f);
END;
END.

Sample Run (Printer Output)


0001  PROGRAM Print;
0002  TYPE
0003      String15 = ARRAY[1..15] OF Char;
0004  VAR
0005    n,x: Integer;
0006      c: Char;
0007      f,printer: Text;
0008      s: String15;
0009  
0010  BEGIN
0011   x:=0;
0012   n:=1;
0013   Write('FILENAME? '); Readln(s);
0014   Write('Line numbers(Y/N)? '); Readln(c);
0015  Rewrite(Printer,'P:');
0016   Reset(f,s);
0017  WHILE NOT EOF(f) DO
0018   BEGIN
0019    IF (c='Y') AND (x=0) THEN
0020     BEGIN
0021      x:=1;
0022      IF n<10 THEN Write(printer,'000',n,'  ');
0023      IF (n>9) AND (n<100) THEN Write(printer,'00',n,'  ');
0024      IF (n>99) AND (n<1000) THEN Write(printer,'0',n,'  ');
0025      IF n>999 THEN Write(printer,n,'  ')
0026   END;
0027   IF EOLn(f) THEN
0028              BEGIN
0029               x:=0;
0030               n:=n+1;
0031               Writeln(printer)
0032              END
0033      ELSE Write(printer,f^);
0034   Get(f);

0035  END;

Monday, April 6, 2020

CONSTRU2.P

[Table of Contents]
Disk Image

CONSTRU2.P is from the Entering  Formulas section of the Kyan Pascal 2.x manual/tutorial. It is a copy of CONSTRU1.P with modifications to send output to the printer.

To see output to the printer in Altirra 3.20, first add a printer by selecting System > Configure System... > Peripherals > Devices > Add > High-level emulation (HLE) devices > Printer (P:), then before running the program, display the printer output window by selecting View > Printer Output.

What's on the disk?


The disk image includes the various Atari DOS 2.5 files, Kyan Pascal Include files (none of which are used in this program), Kyan Pascal Run-time library, and ...

CONSTRU2.P - Source code file
P.OUT - Kyan Pascal intermediate file
CONSTRU2 - Executable file

Source Code


(* CONSTRU2.P *)
(* Kyan Pascal 2.04 / Atari 8-bit *)

Program Constru2(Input, Output);
(* Dollar units are thousands *)

Const
   Material = 325.00;

Var
   Hours, Rate, Labor, Total : Real;
   Printer : Text;

Begin
   Rewrite(Printer,'P:');
   Write(Chr(125)); (* Clear screen *)
   Writeln('Enter hours worked, and press RETURN');
   Writeln('Then enter Rate Of Pay and press RETURN');
   Readln(Hours);
   Readln(Rate);
   Labor := Hours * Rate;
   Total := Labor + Material;
   Writeln(Printer, 'Labor=$', Labor:8:2, ' Total = $', Total:8:2)

End.

Sample Run