Path: utzoo!attcan!uunet!bonnie.concordia.ca!ccu.umanitoba.ca!eeserv.ee.umanitoba.ca!yackob From: yackob@eeserv.ee.umanitoba.ca (Zaifu Kerry Yackoboski) Newsgroups: comp.lang.pascal Subject: Re: Turbo Pascal typecasting and the Mem array. Summary: Ignore the first article, please. Keywords: Turbo Pascal typecasting integer word Message-ID: <1991Feb27.160413.29411@ccu.umanitoba.ca> Date: 27 Feb 91 16:04:13 GMT References: <1991Feb27.033001.2520@ccu.umanitoba.ca> Sender: news@ccu.umanitoba.ca Organization: Dept. Electrical Engineering, U of Manitoba Lines: 34 After solving my problem I tried to cancel the article explaining it, but "rn" told me I couldn't cancel someone else's article. Sorry about that, but since I have cleared up my problem, here is the solution. In article <1991Feb27.033001.2520@ccu.umanitoba.ca> I wrote : > I'm having trouble casting an integer type variable to >a word type. Basically, I just don't understand what's going on >in the TP Reference Guide (Version 5.0, pages 42, 64, and 208). >Hopefully some net.god can clear a few things up for me. > > I'm reading in integers (i.e., signed 16 bit) from a file >and trying to store them in memory using the Mem[segment:offset] >array. My dilemma is that Mem expects a byte (unsigned 8 bit), >so I tried to use the MemW[..] array, except this expects a word >(i.e., unsigned 16 bit). >Kerry Yackoboski The solution is to do a type cast when I USE the value in the MemW array. e.g., if temp_value is an integer, temp_value := integer (MemW[seg:offset]); works. I also have to increment the offset twice to advance to the next data value, as I suspected. sorry if I've wasted bandwidth on a well-known concept, Kerry -- Kerry Yackoboski The Scanning Tunneling Microscopy Laboratory in the Cellar U of Manitoba, Winnipeg, Canada