Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!uupsi!sunic!cs.umu.se!delann From: delann@cs.umu.se (Anders Nyman) Newsgroups: comp.sys.mac.programmer Subject: Re: Get Text from a Dialog Message-ID: <1991Feb10.023120.3539@cs.umu.se> Date: 10 Feb 91 02:31:20 GMT References: <1991Feb8.204416.390@ux1.cso.uiuc.edu> Sender: news@cs.umu.se (News Administrator) Organization: Dep. of Info.Proc, Umea Univ., Sweden Lines: 32 In article <1991Feb8.204416.390@ux1.cso.uiuc.edu> dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz) writes: > >I am trying to copy text from an editText item in a Dialog box into a >Str255 variable. I am using Think C 4.0. I did a GetDItem followed >by either the GetIText routine in the toolbox, or GetTextHandle (from >the CStaticText class in the Think Class Library). Either way, I keep >getting a bus error. > >There must be a simple way to get text from an editText item in a >Dialog box either using TCL or toolbox calls. Could someone please >send me a brief explanation of how to do this. HELP!! 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!. Hope this help. Anders Nyman