[comp.sys.mac.programmer] SetIText -- Does it make a copy?

jverdega@cae.wisc.edu (Jeffrey Verdegan) (06/22/91)

Hi all,

Just a quick question here.  When calling

SetIText(itemHandle, tmpStr);,

does the Str255 that is the item's text point directly to tmpStr, or are
tmpStr's contents copied into the existing Str255, thereby leaving two separate
copies of tmpStr?

Reply here or email jverdega@cae.wisc.edu.
Thanks in advance! :-)

Jeff Verdegan
University of Wisconsin-Madison
Computer-Aided Engineering Center
jverdega@cae.wisc.edu

aep@world.std.com (Andrew E Page) (06/24/91)

In article <1991Jun21.121344.13733@doug.cae.wisc.edu> jverdega@cae.wisc.edu (Jeffrey Verdegan) writes:
>Hi all,
>
>Just a quick question here.  When calling
>
>SetIText(itemHandle, tmpStr);,
>
>does the Str255 that is the item's text point directly to tmpStr, or are
>tmpStr's contents copied into the existing Str255, thereby leaving two separate
>copies of tmpStr?

  I believe the answer here is YES.  It does copy the string.  When setting
the text, remember that static and edit text in dialogs are part of the
item list.  When you call SetIText you are adjusting the contents of the
handle to the item list.  And it is just as well that this is so, since I 
find myself often writing quick subroutines where the string is a local
to contain a converted number from NumToString, as such if that local
where the only container for that string I would loose it, and possibly 
crash later, when the subroutine returned. 



-- 
Andrew E. Page (Warrior Poet)   |   Decision and Effort The Archer and Arrow
Concepts Enginerring            |     The difference between what we are
Macintosh and DSP Technology    |           and what we want to be.