一半君的总结纸

听话只听一半君

#02 How do I determine which Reference files are currently defined or loaded? How do I load and unload them?

To find out which References exist for the currently loaded file:

string $references[] = `file -q -r`;


To find out which are loaded (ie. not deferred):

proc string[] referencesLoaded()
{
   string $referencesLoaded[];
   int $numLoaded = 0;

   string $refs[] = `file -q -r`;

   for ( $ref in $refs )
   {
      // If Reference is not deferred, then it is loaded
      if ( !`file -q -dr $ref` )
         $referencesLoaded[$numLoaded++] = $ref;
   }
   return $referencesLoaded;
}

To unload all references (this won’t delete them from the Reference Editor):

proc unloadReferences()
{
   string $referencesLoaded[] = referencesLoaded();
   string $refNode;

   for ( $refFile in $referencesLoaded )
   {
      // Need to get node that identifies reference
      $refNode = `file -q -rfn $refFile`;

      // Now you can unload it
      file -ur $refNode $refFile;
   }
}

To physically delete loaded references from the scene and the Reference Editor:

proc deleteLoadedReferences()
{
   string $referencesLoaded[] = referencesLoaded();

   for ( $refFile in $referencesLoaded )
   {
      file -rr $refFile;
   }
}

And finally, to delete all References:

proc deleteAllReferences()
{
   string $references = `file -q -r`;

   for ( $refFile in $references )
   {
      file -rr $refFile;
   }
}
Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: