home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!microsoft!wingnut!peterbak
- From: peterbak@microsoft.com (Peter Bako)
- Subject: death of a global variable...
- Message-ID: <1992Aug13.191303.17858@microsoft.com>
- Date: 13 Aug 92 19:13:03 GMT
- Organization: Microsoft Corp.
- Keywords: programming help, weird bug?
- Lines: 52
-
-
- I have a really weird bug that has me stumped, and just might do
- the same to some of you as well....
-
- First of all a small background. The program is being written on a
- Mac IIci with 8 megs of memory and running system 7.0. The program
- is being written with Think C 5.0.2.
-
- Now the problem. I have two global variables, one which is an array
- of menu handles, and the other is structure of my own design. During
- an assign of two variables within the structure, the contents (first the
- lo order word, then the high) of the MenuHandle array get overwritten.
- Now for some code - first the structure:
-
- typedef struct
- {
- int FileRefNum;
- long Height, Width;
- int dataPos;
- WindowPtr winPtr;
- } DrawRec;
-
- Ok then I globally declare the following:
-
- MenuHandle theMenus[NumOfMenus];
- DrawRec theImage;
-
- During the setup look the MenuHandle array gets filled in with 4 handles
- to my four menus. So far everything is working perfectly. Now as the
- user selects the draw routine we jump to the setup for that which fills
- in the values of the struct:
-
- /* get line of data into temp */
- StringToNum(temp, &x);
- theImage.Height = x;
- /* get next line of data */
- StringToNum(temp, &x);
- theImage.Width = x;
-
- theImage.FileRefNum = refNum;
-
- Now here is the catch! By watching the value of theMenus[4] (my last menu)
- in the debugging window of Think C, I can watch how the contents of that
- variable are changed as the the value of theImage.Width and theImage.FileRefNum
- are set. My problem is that I cannot figure out why by setting the these
- two variable, it is blowing away the contents of my menuHandle array. Any
- ideas?
-
- Peter
-
- --
- (*)-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\/-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+(*)
- ( UUCP: peterbak@microsoft || Is this all that I am? Is there )
- ( CompuServe: 71170,1426 || nothing more? - V'ger )
- (*)-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-/\-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+(*)
-