[NTLK] freezing question (script)

From: Filmer, Paul E. (pfilmer_at_nsf.gov)
Date: Tue Aug 13 2002 - 11:06:09 EDT


        From: Jameson Forster <jforstermd_at_mac.com>

        Does anyone know whether there is a way to freeze a group of
packages
        that work together and open them or close them as a group? Such as
        Newtonworks, fonts, writestuff, etc all of which are extensions for
        newton works. Thanks jf

Dashboard is great, here's an example that I found of a script to
freeze/thaw all your Internet related pkgs (w/ some extra housekeeping &
restore state stuff, and an insight into progress status messages also...):

local groupName := "Internet Apps";
local pkgNameList :=
  [
    //add package names one per line
    //enclosed in quotes and
    //separated by commas
    "Newton Internet Enabler",
    "NIE Ethernet Module",
    "NIE LocalTalk Module",
    "NIE Modem & Serial Module",
    "NetHopper:ALLPEN",
    "EnRoute Core",
    "inet Text Encoding",
    "Internet Setup",
    "EnRoute internet",
    "EnRoute Rule Editor",
    "inet Headers",
    etc etc etc
  ];
local extrasWasOpen;
if GetRoot().extrasDrawer.viewCObject then
  begin
    extrasWasOpen := TRUE;
    GetRoot().extrasDrawer:Close();
  end
else
  extrasWasOpen := NIL;

local freezeOrThaw := ModalConfirm("Do you want to freeze all of the
programs in the \"" & groupName & "\" group, or thaw them?", ["Freeze",
"Thaw", "Cancel"];

local statusMessage;
if freezeOrThaw = 0 then
  statusMessage := "Thawing" & groupName & "packages..."
else if freezeOrThaw = 1 then
  statusMessage := "Freezing" & groupName & "packages..."
else if freezeOrThaw =2 then
  return NIL; //quit, user cancelled

local currentPkgRef;
local gaugeNow := 0;
local gaugeTotal := Length(pkgNameList) * Length(GetStores());
local incerementAmount := 100/ gaugeTotal;

local statusSlipOptions :=
  {
    closebox : NIL,
    gauge : 0,
    statusText : statusMessage,
  };

local workFunction := func(statusSlip)
  begin
    foreach store in GetStores() do
      begin
        foreach pkgName in pkgNameList do
          begin
            currentPkgRef := GetPkgRef(pkgName, store);
            if freezeOrThaw = 0 then //freeze
              begin
                if currentPkgRef and IsPackageActive(currentPkgRef) then
                  SafeFreezePackage(currentPkgRef);
              end
            else if freezeOrThaw = 1 then //thaw
              begin
                if currentPkgRef and not IsPackageActive(currentPkgRef) then
                  ThawPackage(currentPkgRef);
              end;
            gaugeNow := Floor(gaugeNow + incrementAmount);
            statusSlip:setStatus('vGauge, {kind:'vGauge, gauge:gaugeNow,
statusText:statusMessage, titleText:pkgName});
          end;
      end:
    end;

DoProgress('vGauge, statusSlipOptions, workFunction);
if extrasWasOpen the GetRoot().extrasDrawer:Open();

Happy scripting!

Paul F.

-- 
Read the List FAQ/Etiquette: http://www.newtontalk.net/faq.html
Read the Newton FAQ: http://www.chuma.org/newton/faq/
This is the NewtonTalk mailing list - http://www.newtontalk.net/



This archive was generated by hypermail 2.1.2 : Thu Sep 05 2002 - 10:03:26 EDT