Author Topic: Quick question about packages  (Read 770 times)

Just a quickie here, is there anyway to tell if a package is active. I do realize I can place code in my package that would tell me if the package is active, I just wanted to know if there was a simple function.


One more question. when I call isBlah() in an 'if' below. It will call the else block. However if I type in the console  echo(isBlah()); it will echo "1".

function deactivateBlah()
{
if(isBlah())
{
deactivatePackage(blah);
}
else
{
echo("no blah to deactivate!");
}
}

package Blah
{
function isBlah()
{
return 1;
}
}

function isBlah()
{
return 0;
}
« Last Edit: April 25, 2014, 07:54:46 PM by swatman64 »

I'm not sure if you can redefine the same command twice. I recall reading in a previous thread that, if many functions are named the same, only the first one will be taken into account. Although I might be wrong, I believe this is your problem.
« Last Edit: April 26, 2014, 12:24:39 AM by Pie Crust »

I dont think there is a way to check if a package is active
« Last Edit: April 26, 2014, 12:35:11 AM by Wrapperup »

I believe there is an isActivePackage(PACKAGEOBJECT); command.

I'm not sure if you can redefine the same command twice. I recall reading in a previous thread that, if many functions are named the same, only the first one will be taken into account. Although I might be wrong, I believe this is your problem.

if you name two functions the same thing the second one that is executed will be valid.

Use this.

function isActivePackage(%package)
{
  if (!isPackage(%package))
    return 0;

  %count = getNumActivePackages();

  for (%i = 0; %i < %count; %i++)
  {
    if (getActivePackage(%i) $= %package)
      return 1;
  }

  return 0;
}


PACKAGEOBJECT

.. what?