Path: utzoo!attcan!uunet!tank!ncar!unmvax!tut.cis.ohio-state.edu!rutgers!apple!claris!drc From: drc@claris.com (Dennis Cohen) Newsgroups: comp.sys.mac.programmer Subject: Re: GetIndString, where is the reverse? Keywords: GetIndString C ToolBox Message-ID: <7010@claris.com> Date: 22 Nov 88 15:39:13 GMT References: <1012@ccnysci.UUCP> Reply-To: drc@claris.com (Dennis Cohen) Distribution: comp.sys.mac.programmer Organization: Claris Corporation, Mountain View CA Lines: 29 In article <1012@ccnysci.UUCP> cpyang@ccnysci.UUCP (Chao Ping Yang) writes: > > I am keeping a lot of strings in resources and I need to update >them when running my program, but how do I change resource data? >Or how do I do the reverse of GetIndString? All I can find from >the Toolbox routines are handles to the resource and the structures >of the resource files, but that look like a lot of work. > One way to do this is to call GetResource, DetachResource, RmveResource, AddResource, and UpdateResFile with the appropriate arguments. You recognize correctly that it is a lot of work. You don't need to know the structures of the resource files, but you do need, occasionally, to know the structures of the resource types to modify them correctly. For example, if you are modifying a string somewhere in the middle of an STR#, be sure that you move everything after it to correctly adjust to the new length. The safest method is to create a handle to a new item, build your resource in it, and then add it to the resource file (after removing the one that it replaces). Be sure to check your error returns at all points through this process. Best of luck, Dennis Cohen Claris Corp. ------------ Disclaimer: Any opinions expressed above are _MINE_!