Maybe I misunderstand what you're trying to do, but this should do the trick:

Code:
ENTITY* toSetInvisibleEnt;

void blah()
{
  ENTITY* currentInvisible;
  while(1)
  {
    if(currentInvisible != toSetInvisibleEnt){
       reset(currentInvisible,INVISIBLE);
       currentInvisible = toSetInvisibleEnt;
       set(currentInvisible,INVISIBLE);
    }
    wait(1);
  }
}

function blahaaa()
{
  while(my)
  {

    //do your stuff
    if(something or other is true)
    toSetInvisibleEnt = my;
    wait(1);
  }
}




~"I never let school interfere with my education"~
-Mark Twain