Path: utzoo!attcan!uunet!mcsun!isgate!krafla!aries From: aries@rhi.hi.is (Reynir Hugason) Newsgroups: comp.sys.mac.programmer Subject: Re: Str255 --> 'STR ' how? Message-ID: <1779@krafla.rhi.hi.is> Date: 13 Jun 90 09:57:52 GMT References: <1990Jun12.174107.29196@ucselx.sdsu.edu> Organization: University of Iceland Lines: 34 In <1990Jun12.174107.29196@ucselx.sdsu.edu> purcell@sciences.sdsu.edu (Guy B. Purcell) writes: >I know this is probably soooo simple, but... How do I save the contents of a >Str255 string in a 'STR ' rsrc? I'm saving config settings, and have managed to >save them if the new string is <= the old one in length (char-by-char). Is >there some standard method of doing this (non-char-by-char so length is not a >factor)? Thanks. It sure is simple ;-) Try: PROCEDURE SaveStrAsSTR(whichStr: Str255; resID: INTEGER); VAR strHdl: StringHandle; resHdl: Handle; BEGIN strHdl:=NewString(whichStr); IF (strHdl = NIL) THEN EXIT(SaveStrAsSTR); resHdl:=GetResource('STR ', resID); { Check if res exists } IF (resHdl <> NIL) THEN { rmve it if it does } BEGIN RmveResource(resHdl); DisposHandle(resHdl); END; AddResource(Handle(strHdl), 'STR ', resID, ''); { now add'em } WriteResource(Handle(strHdl)); ReleaseResource(Handle(strHdl)); END; > Guy (purcell@zeus.sdsu.edu) +++ Mimir (aries@rhi.hi.is) - Aries, Inc.