Re: [NTLK] How to programatically delete an autopart/package?

From: Paul Guyot (pguyot_at_kallisys.net)
Date: Fri Apr 16 2004 - 06:36:14 PDT


Aux environs du 16/04/04 à 10:22 -0300, sous le titre "[NTLK] How to
programatically delete an autopart/packag", Luiz Petroni prit sa plus
belle plume pour écrire les mots suivants:
>I know that this should be veeeery simple issue for the programmers in
>this list but as a newtonscript newbie I've been unable to realize how
>this can be implemented :(
>
>I found references to SafeRemovePkg(PkgRef) and also
>RemoveSlot(GetRoot(), PkgSym).
>Are these the methods I should use?

You should not use RemoveSlot.
Just use SafeRemovePkg.
For every part in the package, the part handler's remove method will
be called. The form part handler's remove method will call the part's
removeScript and then will remove the slot from the root view.

>For the SafeRemovePkg(), the PkgRef argument is retrieved thru the
>GetPkg(name,store)
>I believe I need to code like:
>
>local the_ref := GetPkg("name_of_package","store_of_package");
>SafeRemovePkg(the_ref);
>
>Does it make sense?

Actually, the method is called GetPkgRef. I don't recall exactly if
it can take NIL as the second parameter, but I think it cannot.

>Now, how do a know in which store is the autopart/package filled?
>Do I need to use GetPackages() and use a foreach loop to search thru
>the packages array for the specific package name and then collect its
>store info?

Yes. You can also loop over GetPackageNames.
You can also use ObjectPkgRef.

>Is there any direct ways to simply get the autopart/package symbol and
>use a method that receives this symbol as an argument and the remove
>it?

You need to loop. The best is probably to loop over GetPackageNames.
GetPackages only tells you about active packages.

It's a simple (double) loop (you need to iterate on stores as well).

Paul

-- 
Philosophie de baignoire - consultations sur rendez-vous.
NPDS/NewtonOS: http://newton.kallisys.net:8080/
Apache/FreeBSD: http://www.kallisys.com/
-- 
This is the NewtonTalk list - http://www.newtontalk.net/ for all inquiries
Official Newton FAQ: http://www.chuma.org/newton/faq/
WikiWikiNewt for all kinds of articles: http://tools.unna.org/wikiwikinewt/


This archive was generated by hypermail 2.1.5 : Fri Apr 16 2004 - 07:00:01 PDT