Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!apple!motcsd!dms!rotberg From: rotberg@dms.UUCP (Ed Rotberg) Newsgroups: comp.sys.mac.programmer Subject: Re: Think C programming Message-ID: <1007@dms.UUCP> Date: 9 Mar 90 18:21:10 GMT References: <2967@dciem.dciem.dnd.ca> Organization: Atari Games Inc., Milpitas, CA Lines: 45 From article <2967@dciem.dciem.dnd.ca>, by juana@dciem.dciem.dnd.ca (Juana Chang): > > I am trying to produce a DIALOG BOX with editable items. And I want to: > > 1. Get the text in the dialog item. > 2. Convert the text to an integer. > 3. Edit check this integer. > > Therefore, I use: > > GetDItem( theDialog, ITEM, &i_itemType, &hdl_item, &rect_item ); > /* in order to get the item handle */ > > GetIText( &hdl_item, str_item ); > /* in order to get the text */ > > This is where I get stuck... > > I print the contents of str_item and get GARBAGE! (pretty little symbols). > I printed the contents out of curiosity and to make sure I was getting the > actual contents that the user places in the editable text box. > I used the DrawString function to print the text onto the screen. > > Why am I getting GARBAGE?? This is something I do all the time. Your first problem is that the call to GetIText is wrong -- it should be GetIText( hdl_item, &str_item ); Note the ampersand (&) before str_item, and none before the handle. This may be the problem if for some reason you were not passing the address of the string, and were passing the address of the handle instead of the handle itself. The actual code snippet from my working program is: GetDItem( Dptr, COUNT_ID, &Itype, &ItmHndl, &box ); GetIText( ItmHndl, &val ); PtCstr(val); Then use either sscanf or strtod to convert the string to numeric data. I hope this helps. Good Luck. - Ed Rotberg -