purcell@sciences.sdsu.edu (Guy B. Purcell) (06/13/90)
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. Guy (purcell@zeus.sdsu.edu)
purcell@sciences.tmc.edu (Guy B. Purcell) (06/13/90)
Thanks to those who replied. Of all the suggestions I got, the best were: 1) Use SetHandleSize() (can you say duh, thought so) 2) Use Munger() (I like this best, cause it allocates the space *and* copies the string) Guy (purcell@zeus.sdsu.edu)
hawley@adobe.COM (Steve Hawley) (06/13/90)
In article <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. > Gary -- You might want to consider this: If you are putting configuration information INTO THE APPLICATION ITSELF, it will not function correctly on a read only file server. If you are writing this application for yourself, fine, but if write for "the rest of us" please keep this in mind: Configuration files should go in the system folder of the startup disk. As to your real question, I'll punt --my copies of IM are in a box and being held by a moving company until I have a place to live... Steve Hawley hawley@adobe.com -- "A blow on the head is... ...worth two in the bush." -Basil Fawlty
aries@rhi.hi.is (Reynir Hugason) (06/13/90)
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.