Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!bin From: bin@primate.wisc.edu (Brain in Neutral) Newsgroups: comp.sys.mac.programmer Subject: Re: Get Text from a Dialog Message-ID: <3897@uakari.primate.wisc.edu> Date: 10 Feb 91 06:07:07 GMT References: <1991Feb10.023120.3539@cs.umu.se> Sender: bin@primate.wisc.edu Reply-To: bin@primate.wisc.edu Lines: 36 From article <1991Feb10.023120.3539@cs.umu.se>, by delann@cs.umu.se (Anders Nyman): > Try to do something like this: > > char *thestring; /* Pointer to the string where you want the answer */ > int item; > Handle theitemhndl; > DialogPtr thedialog; > Rect therect; > > GetDItem(thedialog,itemnumber,&item,&itemhndl,&itemrect); > GetIText(itemhndl,thestring); > PtoCstr(thestring); /* If you want the string to be a c-string */ > > thedialog is your dialogptr from NewDialog or GetNewDialog. > iteitemnumber sould be the items number in the itemlist. > In the int item, you will recieve the itemtype, and in itemrect the rectangle > for the item. Be sure to put all the '&' in right places. I have noticed > that sometimes forgotten '&' will cause BOMB!. Which it should. There are (at least) two other things that could cause bombs in the above code. (1) You're passing thestring to GetIText, but thestring is a pointer to who knows where? thestring should be a Str255, not a char * (or, which is roughly the same, a StringPtr), and you should pass its address. (Of course, in C, that's just "thestring".) (2) Depending on your compiler "int" might be two or four bytes long. If it's 4, and your compiler doesn't check the sizes of the arguments passed to toolbox routines, GetDItem() could crash. Otherwise, it should work wonderfully! :-) -- Paul DuBois dubois@primate.wisc.edu