[comp.lang.pascal] Using logical device LST: in TP5

Dex@cup.portal.com (Paul Dex Durden) (04/28/89)

Hi,

   I've been programming at UAH using TP3.02a and noticed that in TP5 I
couldn't open a file assigned to the logical device 'LST:' like I could in
TP3.  I know you can use the variable LST in the write statements to send
the output to the printer but below is what I had originaly wrote and would
like to keep, rather than having to double up on code and rewrite it for
output to disk and printer.
   This is similar to the dual ouput message string that went through last
month, but I did not pay attention to that string because I wasn't having a
problem with it in TP3.
   Any help will be greatly appreciated.

   Thanks in advance,
   Paul 'Dex' Durden

         |\   '|\  ' |\         +--------------------------------+
         |/    | |   | |        | E-mail to: Dex@cup.portal.com  |
         |aul  |/ex  |/urden    +--------------------------------+



   In TP3 the below code works but in TP5 I get a 'File not found error'
   when REWRITing Out when out is assigned to LST:

USES TURBO3,CRT,PRINTER;

VAR
   I : INTEGER;
   OUT : TEXT;


BEGIN
   FOR I:=1 TO 2 DO
      BEGIN
         IF I = 1 THEN
            BEGIN
               ASSIGN(OUT,'LST:');     {Direct output to printer}
               REWRITE(OUT);
            END
         ELSE
            BEGIN
               ASSIGN(OUT,'A:FILENAME.TXT'); {Direct output to FILENAME}
               REWRITE(OUT);
            END;

         WRITELN(OUT,'DATA HERE');
         WRITELN(OUT,'More data');
         IF I = 1 THEN
            WRITELN(^L);   {Form feed}

         CLOSE(OUT);

      END; {FOR}
END.

abcscnuk@csuna.csun.edu (Naoto Kimura) (04/29/89)

In article <17691@cup.portal.com> Dex@cup.portal.com (Paul Dex Durden) writes:
]
]Hi,
]
]   I've been programming at UAH using TP3.02a and noticed that in TP5 I
]couldn't open a file assigned to the logical device 'LST:' like I could in
			get rid of the colon ------------^

    I ran into the same problem the first time I wrote code in version
4.0 of the compiler.  You have to make sure that you don't put the colon
on the logical device names.

]... (text and program deleted) ...
]
]   Thanks in advance,
]   Paul 'Dex' Durden

                //-n-\\			 Naoto Kimura
        _____---=======---_____		 (abcscnuk@csuna.csun.edu)
    ====____\   /.. ..\   /____====
  //         ---\__O__/---         \\	Enterprise... Surrender or we'll
  \_\                             /_/	send back your *&^$% tribbles !!

terra@freja.diku.dk (Morten Welinder) (05/01/89)

Dex@cup.portal.com (Paul Dex Durden) writes:


>   I've been programming at UAH using TP3.02a and noticed that in TP5 I
>couldn't open a file assigned to the logical device 'LST:' like I could in
>TP3.....

I have not had the time to check this, but try 'LST' instead of 'LST:'.
(Not taken out of thin air; Unit Printer uses 'LPT1', not 'LPT1:')

Greatings from Morten 'Sally' Welinder

leonard@bucket.UUCP (Leonard Erickson) (05/02/89)

In article <17691@cup.portal.com> Dex@cup.portal.com (Paul Dex Durden) writes:
<   I've been programming at UAH using TP3.02a and noticed that in TP5 I
<couldn't open a file assigned to the logical device 'LST:' like I could in
<TP3.  I know you can use the variable LST in the write statements to send
<the output to the printer but below is what I had originaly wrote and would
<like to keep, rather than having to double up on code and rewrite it for
<output to disk and printer.

<   In TP3 the below code works but in TP5 I get a 'File not found error'
<   when REWRITing Out when out is assigned to LST:
<
<USES TURBO3,CRT,PRINTER;
<
<VAR
<   I : INTEGER;
<   OUT : TEXT;
<
<
<BEGIN
<   FOR I:=1 TO 2 DO
<      BEGIN
<         IF I = 1 THEN
<            BEGIN
<               ASSIGN(OUT,'LST:');     {Direct output to printer}
<               REWRITE(OUT);
<            END
<         ELSE
<            BEGIN
<               ASSIGN(OUT,'A:FILENAME.TXT'); {Direct output to FILENAME}
<               REWRITE(OUT);
<            END;
<
<         WRITELN(OUT,'DATA HERE');
<         WRITELN(OUT,'More data');
<         IF I = 1 THEN
<            WRITELN(^L);   {Form feed}
<
<         CLOSE(OUT);
<
<      END; {FOR}
<END.

 In TP3 'lst' is an *internal* logical device that the compiler maps to
the DOS device PRN: (or possibly LPT1:).

In TP4 and 5 'lst' is a pre-assigned filename that you get by using the
printer unit. (ie writeln(lst,x,y,z) will write x, y, and z to the 
printer.

TP 4 & 5 use the *DOS* logical devices iin assign statements.
Thus you need to ASSIGN(OUT,'PRN:') (or use LPT1:). Note also that in
TP4 lst was opened in 'cooked' mode instead of 'raw' (ie binary) mode.
This meant that tabs got expanded, many control characters got munged,
and ^Z closed the file.... (oops!) I'm not sure if TP 5 kept this
'feature' or not.

-- 
Leonard Erickson		...!tektronix!reed!percival!bucket!leonard
CIS: [70465,203]
"I'm all in favor of keeping dangerous weapons out of the hands of fools.
Let's start with typewriters." -- Solomon Short