martinew@p2.f55.n105.z1.FIDONET.ORG (Martine Wedlake) (10/18/88)
> I need to be able to read strings from text files in order to do some > work. Most commercial pc-based pascal products support this. Unfortun- > ately, Berkeley pascal (a reasonable enhancement over Standard Pascal) > manual clearly states that this is not allowed. The environment is > a VAX running Ultrix V2.2. I wonder if anyone knows of a way to get > around this problem. There is no such thing as "string" in Berkely pascal. To create something similar you must define your own data type to do that. I tend to use a type similar to Turbo Pascal.... Type String=Array[0..128] of Char; And then set StringVar[0] to the chr of the length of the string. Also note--- I've noticed in Berkely pascal the Ord function returns back negative numbers if larger than 128. Ie it seems to be a signed byte. Very strange, but that's the way it is.... :-) Anyways, to read a "string" in you must do something like this.... Procedure ReadLine(var Str:String); {assumed from standard input, but can be from any text file...} var pointer:integer; begin Str[0]:=chr(0); {set length=0} pointer:=0; while not Eoln and not eof do begin pointer:=pointer+1; read(str[pointer]); end; str[0]:=chr(pointer); end; This would read a line of input from the standard input. NOTE: you will probably have to play with the Eoln and Eof parameters...In the version I use there is an annoying error that says "EOLN is undefined when EOF is true" which is total garbage. But, it does a core dump regardless... So you may have to watch out for that... Later, Martine -- Sent By: Martine Wedlake From: Casper's Place UFGATE, Portland, OR USA (Fido-Net Node 1:105/55) UUCP: ...!{tektronix, sun!nosun}!percival!casper!55.2!martinew ARPA: martinew@p2.f55.n105.z1.FIDONET.ORG