[comp.lang.pascal] TP-5.0 can't do ``write

gm@romeo.cs.duke.edu (Greg McGary) (01/07/89)

Turbo-Pascal 5.0 has troubles compiling some TeXware containing these
fragments:

type byte = 0..255;
var tfmfile: packed file of byte;

{ This won't compile:
  TP complains that it wants to see an identifier, not a constant }
write(tfmfile, 255);

{ This is a successful workaround, but it's gross... }
var xx: byte;
xx := 255; write(tfmfile, xx);

Thanks for all assistance!
-- Greg McGary	
-- 4201 University Drive #102, Durham, NC 27707   (919) 490-6037
-- {decvax,hplabs,seismo,mcnc}!duke!gm
--				    gm@cs.duke.edu

wilker@batcomputer.tn.cornell.edu (Clarence W. Wilkerson Jr.) (01/07/89)

This is not new to version 5.0, and is not special to byte
variables. I think that any typed variable has the same
problem. Of course, you would not be tempted often by non-scalar
variables. I have not seen or noticed this as a constraint
on "write" in the manuals, so you could consider it a bug.
On the other hand the work around is obvious:
... var x : byte;
...   x:=myconstant;
... write(myfile,x);

I have not tried the write with "typed constants" declared by
const x: byte=myconstant;
I suspect that this works, since now the compiler knows the
"type" of x.

murphy@pur-phy (William J. Murphy) (01/08/89)

I don't have my manuals for Turbo 4/5, but you may need to tell
write(tfmfile, 255) that 255 is a byte (short integer). Also,
you could try write(tfmfile, SizeOf(tfmfile));

What you posted was
type byte 0..255;
var tfmfile : packed file of byte;
write(tfmfile, 255); 
 
Did you mean
type byte 0..255;
var tfmfile : byte;
write(tfmfile, 255);

Just a thought.
Bill Murphy
murphy@newton.physics.purdue.edu