Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!dartvax!eleazar.dartmouth.edu!xxiaoye From: xxiaoye@eleazar.dartmouth.edu (Xiaoxia Ye) Newsgroups: comp.sys.mac.programmer Subject: Integer Size problem Message-ID: <15141@dartvax.Dartmouth.EDU> Date: 21 Aug 89 21:55:47 GMT Sender: news@dartvax.Dartmouth.EDU Reply-To: xxiaoye@eleazar.dartmouth.edu (Xiaoxia Ye) Organization: Dartmouth College, Hanover, NH Lines: 45 Would someone explain the following weirdness? the WIND resource' first 8 bytes are its positions on the screen: top, left, bottom and right. I tried to save the window postions and so to write to the first 8 bytes of the WIND resource. I have my rectange declared as (it's in THINK C): Rect myRect; and I get a handle to the WIND resource: myHandle=GetResource('WIND',MY_WIND_RES_ID); after I lock the Handle and do the following to assignment to the resource: **myHandle=myRect.top; **myHandle+=2; **myHandle=myRect.left ... blah blah and did this for all four coordinates. and do a ChangedResource, and UpdateResFile, etc ... What happened was: say that I have the following eight bytes in my WIND resource (in Hex): 0044 0043 0056 0098 and say that myRect.top = 0x60, myRect.left=0x60, myRect.bottom=0x80 and myRect.right=0x80. and when I examined what was written to the resource, I found out that first 8 bytes of WIND resource became: 6044 6043 8056 8098 in another words, if I just do an integer assignment, I don't get 00 padding and have the proper alignment. Why?? And if I write a 0x132 to '0044', those two bytes will become '1324' instead of '0132'. Why ?? Well, eventually, I gave up and wrote a little routine to copy the bytes myself (actually the THINK C inline assembly would do the job). Much thanks. ________________________________________________________________________ Xiaoxia Ye INTERNET/BITNET/UUCP: xxiaoye@eleazar.dartmouth.edu Dartmouth College For more info: finger xxiaoye@eleazar.dartmouth.edu