[comp.sys.mac.programmer] When you AddResource, does the Handle now point to a resource?

vrm@blackwater.cerc.wvu.wvnet.edu (Vasile R. Montan) (04/27/91)

I am writing a program which installs resources into files. Suppose
I have the following code:

procedure InstallResource;
var
   MyHandle  : Handle;
begin
   MyHandle^^ := {Whatever data to be put in the resource}
   AddResource (MyHandle, rsrcType, rsrcID, rsrcName);
{...etc....}
end;

As I understand it, I use DisposHandle to get rid of one of
my own handles, but I use ReleaseResource to get rid of a
resource.  Assuming that I have written my code as above,
should I now say "DisposHandle(MyHandle)" or "ReleaseResource(MyHandle)"?
If I want to stop treating it as a resource, should I
DetachResource it, or is it already not a resource?

If it is a resource, do I have to explicitly call UpdateResFile
(or WriteResource) before releasing it, or does calling ReleaseResource
automatically write it out?

Thank you!

--Kurisuto
un020070@vaxa.wvnet.edu

ech@cbnewsk.att.com (ned.horvath) (04/27/91)

From article <1648@babcock.cerc.wvu.wvnet.edu>, by vrm@blackwater.cerc.wvu.wvnet.edu (Vasile R. Montan):
> I am writing a program which installs resources into files. Suppose
> I have the following code:
> 
> procedure InstallResource;
> var
>    MyHandle  : Handle;
> begin
>    MyHandle^^ := {Whatever data to be put in the resource}
>    AddResource (MyHandle, rsrcType, rsrcID, rsrcName);
> {...etc....}
> end;
> 
> As I understand it, I use DisposHandle to get rid of one of
> my own handles, but I use ReleaseResource to get rid of a
> resource.  Assuming that I have written my code as above,
> should I now say "DisposHandle(MyHandle)" or "ReleaseResource(MyHandle)"?
> If I want to stop treating it as a resource, should I
> DetachResource it, or is it already not a resource?
> 
> If it is a resource, do I have to explicitly call UpdateResFile
> (or WriteResource) before releasing it, or does calling ReleaseResource
> automatically write it out?

My habit is to wear suspenders, and belt, AND lead-lined undershorts just
in case the first two fail.

Yes, your handle is now a resource handle.  Call WriteResource, and
UpdateResFile.  Then, you can DetachResource if you want your copy back.

=Ned Horvath=
ehorvath@attmail.com