Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!ncar!ncar.ucar.edu!hpoppe From: hpoppe@ncar.ucar.edu (Herb Poppe) Newsgroups: comp.sys.mac.programmer Subject: Type cast problem in TP 3.0 Message-ID: <11271@ncar.ucar.edu> Date: 2 May 91 22:00:41 GMT Sender: news@ncar.ucar.edu Distribution: na Organization: National Center for Atmospheric Research Lines: 38 The TP 3.0 program below illustrates a problem I am having with type casting that is driving me nuts. A set of 0..7 has a size of 1. A SignedByte has a size of 1. Yet when I type cast the set of 0..7 to a SignedByte the compiler complains that: "Expression can't be cast to the specified type." How do I interpret the bits in a set of 0..7 as a byte? ----------------- program SetTest; type EightBits = (bit0, bit1, bit2, bit3, bit4, bit5, bit6, bit7); Port = set of EightBits; var dataSize: Integer; byteSize: Integer; portData: Port; portByte: SignedByte; begin dataSize := sizeof(portData); { = 1 } byteSize := sizeof(portByte); { = 1 } portData := [bit0, bit7]; portByte := SignedByte(portData); {Expression can't be cast to the specified type.} end. Herb Poppe hpoppe@ncar.ucar.edu NCAR (303) 497-1296 1850 Table Mesa Dr. Boulder, CO 80307-3000