Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uakari.primate.wisc.edu!dali.cs.montana.edu!ogicse!emory!gatech!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!ruuinf!ruunsa!boogaard From: boogaard@ruunsa.fys.ruu.nl (Martin vdBoogaard) Newsgroups: comp.lang.pascal Subject: Re: Reuqest : Help with Enumeration Types Keywords: enumeration type Message-ID: <1827@ruunsa.fys.ruu.nl> Date: 10 Dec 90 13:32:03 GMT References: <3983@uniol.UUCP> Organization: University of Utrecht, Dept. of Physics Lines: 39 In <3983@uniol.UUCP> Arne.Gehlhaar@arbi.informatik.uni-oldenburg.de (Arne Gehlhaar) writes: % I have a problem with enumeration types. I want to declare a type "measures" % as a list of measurements: (g,kg,lb,oz, etc.) the actual type declaration is % no problem, but I am not allowed to do input/output with them (says the % Turbo Pascal 4.0 compiler) So what is the use of those types. They make your programs (more) readable. Supposing you're not able to use enumerated types, you would have to use e.g. 0 for g, 1 for kg, 2 for lb etc. What looks better: type Measures = ( g, kg, lb, oz ); type Measures = 0..3; var Weight_unit: Measures; var Weight_unit: Measures; case Weight_unit of case Weight_unit of g: ; 0: ; kg: ; or: 1: ; lb: ; 2: ; oz: 3: end; end; I'd prefer the first version. I/O is a problem on most machines (and according to the ISO standard), though. You'll have to read/write strings and convert them into a value, valid for your enumerated type, using a case statement like the first one in the above example. Martin J. van den Boogaard | Dept. of Atomic & Interface Physics | Debye Institute--Utrecht University boogaard@fys.ruu.nl | P.O. Box 80.000, NL-3508 TA Utrecht boogaard@hutruu51.bitnet | the Netherlands, +31 30 532904 ------------------------------------------------------------------------ "I feel that if a person can't communicate, the very least he can do is to shut up." -- Tom Lehrer ------------------------------------------------------------------------