[comp.sys.mac.programmer] Help, writing resource

slavin@GroupW.cns.vt.edu (Scott Slavin) (01/31/91)

I need help rewriting a resource to my application file.

I have a Dialog box that has data in it.  I need to get
that data into the resource fork as resType 'XXXX' and
resID 1003.
I know how to get the data into a Str255 but I don't know
where to go from there.


Thanks in advance

Scott
slavin@ringo.cns.vt.edu

peirce@outpost.UUCP (Michael Peirce) (02/01/91)

In article <1115@vtserf.cc.vt.edu>, slavin@GroupW.cns.vt.edu (Scott Slavin) writes:
> 
> I need help rewriting a resource to my application file.
> 
> I have a Dialog box that has data in it.  I need to get
> that data into the resource fork as resType 'XXXX' and
> resID 1003.
> I know how to get the data into a Str255 but I don't know
> where to go from there.

The following code fragment assumes that the resource already exists
and you are just updating it...

	tHandle := GetResource('Data',kDataRsrcID);

	DataHandle(tHandle)^^ := myData;

	ChangedResource(tHandle);
	IF ResError <> noErr THEN SysBeep(5);

	WriteResource(tHandle);
	IF ResError <> noErr THEN SysBeep(5);

-- michael


--  Michael Peirce         --   outpost!peirce@claris.com
--  Peirce Software        --   Suite 301, 719 Hibiscus Place
--  Macintosh Programming  --   San Jose, California 95117
--           & Consulting  --   (408) 244-6554, AppleLink: PEIRCE