Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!stanford.edu!agate!e260-1c.berkeley.edu!labc-1ic From: labc-1ic@e260-1c.berkeley.edu (Willy S. Liao) Newsgroups: comp.sys.mac.programmer Subject: What am I doing wrong?--modal dialog use crashes Message-ID: <1991May7.234354.26431@agate.berkeley.edu> Date: 7 May 91 23:43:54 GMT Sender: root@agate.berkeley.edu (Charlie Root) Organization: University of California, Berkeley Lines: 48 OK dokee, I have a problem that's driving me nuts. I'm sure I'm doing something wrong, but I don't know what it is...I'm using THINK C 4.04 with System 7.0f4 and the Think Class Library. The following function is invoked by my document initialization method (it gets an integer for the size of the game board). Whenever this function gets run with NO other windows on the screen, it works fine. However, if there is another window open in the application layer (i.e. another instance of a document is in memory), this function chokes with a syserr 28 (stack has moved into heap) error on the call to ModalDialog(). Can anyone suggest anything? Boosting the memory partition up to larger sizes doesn't help (although the crash sometimes turns into an error 25, out of memory). My function: static short GetBoardsize(void) { Str255 req, answer; DialogPtr dptr; short temp; long size; Rect rect; Handle ihandle; DialogRecord dRec; GetIndString(req, GAME_MSGS, GET_SIZE_STR); ParamText(req, "\p","\p","\p"); dptr = GetNewDialog(GENERAL_REQ_DIALOG, &dRec, NULL); GetDItem(dptr, GENERAL_ETEXT_NUM, &temp, &ihandle, &rect); do { NumToString((long) DEFAULT_BSIZE, answer); SetIText(ihandle, answer); SelIText(dptr, GENERAL_ETEXT_NUM, 0, (short) answer[0]); ShowWindow(dptr); ModalDialog(NULL, &temp); GetDItem(dptr, GENERAL_ETEXT_NUM, &temp, &ihandle, &rect); GetIText(ihandle, answer); StringToNum(answer, &size); } while (size < MIN_BOARDSIZE || size > MAX_BOARDSIZE); CloseDialog(dptr); DisposHandle(dRec.items); return (short) size; } All of the all-caps identifiers are #define's. Willy Liao labc-1ic@web.berkeley.edu