[comp.lang.postscript] Need help in THINK C

parnes@eniac.seas.upenn.edu (Gary Parnes) (10/23/89)

I've started programming on my Mac, finally.  BTW, thanks to all of you
who pointed me toward the Programmer's Primer... it really helped.

I have a problem...  How do you copy a string from a dialog EditText item
into a character array?  I want to copy it to a new memory location so I can
take it apart and do unspeakable things to it, etc.  But, every time I try
locking down the handle and copying the string using strcpy, the computer
locks.  Even the onboard debugger doesn't offer any useful error messages.

Anyone know what to do?
						Gary

/=============================================================================\
| "You're obviously misinformed... everything  |  Gary Parnes		      |
|  EAST of the San Andreas Fault is going to   |  Computer Science Engineer   |
|  fall into the ATLANTIC Ocean."              |  University of Pennsylvania  |
|   *** parnes@eniac.seas.upenn.edu ***        |  *NOT* Penn State, Dammit!   |
\=============================================================================/

oster@dewey.soe.berkeley.edu (David Phillip Oster) (10/24/89)

Here is how you retrieve the text from an edittext item in a dialog.
Remember to do this _before_ you DisposDialog() the dialog.

First, define a helper routine
/* GetDIHandle - return handle value of dialog item
 */
Handle GetDIHandle(i)short i;{
  short theType;
  Handle theHandle;
  Rect theRect;

  GetDItem(thePort, i, &theType, &theHandle, &theRect);
  return theHandle;
}

Then, you can fetch it like this:
Str255	s;

SetPort(myDialog);
GetIText(GetDIHandle(ITEM), s);