Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uunet!world!siegel From: siegel@world.std.com (Rich Siegel) Newsgroups: comp.sys.mac.programmer Subject: Re: Type cast problem in TP 3.0 Message-ID: <1991May3.024115.9562@world.std.com> Date: 3 May 91 02:41:15 GMT References: <11271@ncar.ucar.edu> Distribution: na Organization: Symantec Language Products Group Lines: 25 In article <11271@ncar.ucar.edu> hpoppe@ncar.ucar.edu (Herb Poppe) writes: >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? In standard Pascal, casts to or from set-types are illegal. However, a pointer cast can be used to effect the necessary result: s : set of 0..7; b : SignedByte; b := Ptr(@s)^; { recall that the "Ptr" type points to a SignedByte. } R. -- ----------------------------------------------------------------------- Rich Siegel Internet: siegel@world.std.com Software Engineer Applelink: SIEGEL Symantec Languages Group