Article View: comp.sys.mac
Article #6949Re: Need help in THINK C
From: rsilverman
Date: Mon, 23 Oct 1989 19:39
Date: Mon, 23 Oct 1989 19:39
29 lines
1940 bytes
1940 bytes
In article <15790@netnews.upenn.edu>, parnes@eniac.seas.upenn.edu (Gary Parnes) writes:
> 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.
Gary,
You have to be careful with dialogs; the items are not always stored as
you think they might be. It's best to use the routines provided for accessing
them. In this case, the problem is probably this: the text for all text items
in a dialog is kept in one big TextEdit record, managed by the Dialog Manager.
Use the GetIText (I think that's it) routine to retrieve the text from an item.
Remember, it will return it as a Pascal string, so you'll have to add the NUL
yourself. It's not suprising that it's locking up on you: the text your
copying, even if it's the right part, will not have a NUL at the end, so strcpy
will happily keep copying for quite a while, overwriting all sorts of stuff --
including your code, perhaps? -- at the destination.
Ah, for a protected-mode operating system...
good luck,
Richard Silverman
arpa: rsilverman@eagle.wesleyan.edu Systems Engineer
bitnet: rsilverman@wesleyan.bitnet AM Computer Products
CIS: [72727,453] Southington, CT 06489
Technical Details
Message-ID:
<2393@eagle.wesleyan.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!uunet!yale!eagle!rsilvermanReferences:
<5306@lindy.Stanford.EDU> <15790@netnews.upenn.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!uunet!yale!eagle!rsilverman From: rsilverman@eagle.wesleyan.edu Newsgroups: comp.sys.mac Subject: Re: Need help in THINK C Message-ID: <2393@eagle.wesleyan.edu> Date: 23 Oct 89 19:39:16 GMT References: <5306@lindy.Stanford.EDU> <15790@netnews.upenn.edu> Lines: 29