Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!haven!uvaarpa!virginia!scl From: scl@virginia.acc.virginia.edu (Steve Losen) Newsgroups: comp.lang.pascal Subject: Re: Enumerated types in TP40 Message-ID: <1909@virginia.acc.virginia.edu> Date: 14 Feb 89 16:24:56 GMT References: <363@lafcol.UUCP> <950016@hpcllmr.HP.COM> <7250@paris.ics.uci.edu> <1667@csuna.UUCP> Reply-To: scl@virginia.acc.Virginia.EDU (Steve Losen) Distribution: usa Organization: University of Va., Charlottesville, VA Lines: 34 >In article <7250@paris.ics.uci.edu> Alastair Milne writes: > ... (text deleted) ... > I have yet to encounter a way dynamically to determine the number of > values in an enumeration, short of having a dialect which provides a > MAX function. Here is a way to do what you want using perfectly legal ISO Standard Pascal (but I'm not saying it's pretty) program prog(output); type enum = (rocky, bullwinckle, boris, natasha, fearless); var junk : array[enum] of integer; i : enum; function maxenum(var array[low..high : enum] of integer) : enum; begin maxenum := high; end; function minenum(var array[low..high : enum] of integer) : enum; begin minenum := low; end; begin for i := minenum(junk) to maxenum(junk) do writeln('nothing up my sleeve'); end. -- Steve Losen scl@virginia.edu University of Virginia Academic Computing Center