DEC-Pascal has the ability to initialise a boolean or an enumerated type
from a text file.The text is case insensitive and is read just as any
other variable. Is there a way to do this with GPC? If not, are there
any good ways to emulate this behaviour?
I am currently using GPC v.19991030 based on 2.95.2 19991024 on a LINUX
PC.
The following program shows the functionallity that I am trying to
emulate.
Thanks in advance,
Lee.
---
PROGRAM Read_Enum(input, output);
TYPE
colour = (red, green, blue);
VAR
flag : boolean; { Test boolean }
mycol : colour; { Test enumerated type }
ip_file : TEXT; { input data file }
filename : String(80);
i : integer;
BEGIN
filename := "enum.dat";
open(ip_file, filename, history:=old);
reset(ip_file);
FOR i := 1 to 3 DO
BEGIN
readln(ip_file, flag);
IF (flag) then
writeln("Flag is true")
ELSE
writeln('Flag is false');
END;
FOR i := 1 to 3 DO
BEGIN
readln(ip_file, mycol);
CASE mycol OF
red : writeln("Your colour is red");
green : writeln("Your colour is green");
blue : writeln("Your colour is blue");
END;
END;
close(ip_file);
END.
enum.dat:
========
true
False
TrUE
Red
green
BLUE
output:
======
Flag is true
Flag is false
Flag is true
Your colour is red
Your colour is green
Your colour is blue
--
The Information contained in this E-Mail and any subsequent correspondence
is private and is intended solely for the intended recipient(s).
For those other than the recipient any disclosure, copying, distribution,
or any action taken or omitted to be taken in reliance on such information is
prohibited and may be unlawful.