Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!maverick.ksu.ksu.edu!kincaid From: kincaid@mpccl.ksu.edu (Joe Kincaid) Newsgroups: comp.lang.pascal Subject: Re: Enumeration Inverse- was Request : Help with E Types Message-ID: <1990Dec13.033609.15385@maverick.ksu.ksu.edu> Date: 13 Dec 90 03:36:09 GMT References: <3983@uniol.UUCP> <1990Dec10.180345.31492@wpi.WPI.EDU> <357.27648291@vger.nsu.edu> Sender: news@maverick.ksu.ksu.edu (The News Guru) Organization: Kansas State University Math-Physics Computer Classroom Laboratory Lines: 50 In article <357.27648291@vger.nsu.edu> g_harrison@vger.nsu.edu writes: >In article <1990Dec10.180345.31492@wpi.WPI.EDU>, kamal@wpi.WPI.EDU (Kamal Z Zamli) writes: >> In article <3983@uniol.UUCP> Arne.Gehlhaar@arbi.informatik.uni-oldenburg.de (Arne Gehlhaar) writes: > >I am familiar with several versions of Pascal extensions and believe that those >with enumeration IO facilities are providing important functionality. I have a >different "complaint." > >When working with CHAR type we have CHR as the inverse of ORD. With general >enumerated types we don't. > >For example in Ada there is > > [...] > >We can certainly find the Nth (N = 0...) element in an enumerated type in >Pascal by searching for it, but are there some tricks (Machine-Dependent or >otherwise) to provide an inverse to ORD that do not involve searching? > >George.... > I usually use typecasting to achieve this. It works in Turbo anyway and you should probably check to be sure the '0' element lines up where you think it does. Here's an example from pg 528 of the Turbo Pascal 4.0 manual: "In version 3.0, you had to use the _Move_ function to copy data from one data structure to another if the structures were not assignment-compatible: [...Example omitted...] "The exception was for ordinal data types (char, byte, integer, boolean, enumerated types), in which case you use retyping (typecasting): IntVar := byte('a'); MonthVar := Month(3); "In version 4.0, typecasting has been extended to all types, with the requirement that the source and destination be exactly the same size: [...Example (and the rest) omitted...] -- Joseph Kincaid | All the views contained herein are my own. kincaid@einstein.mpccl.ksu.edu | Everything else I share with my wife. KSU - Mathematics Department | Come to think, those are probably hers, too.