Core Function UnsetClass

From Sputnik Wiki
Revision as of 21:40, 11 August 2014 by UberFoX (Talk | contribs)
Jump to: navigation, search
UnsetClass( <class-name> )

Contents

Description

Delete a previous user defined Class from Sputnik.

function-name

The class name to delete.

Return Value

Success: Returns 1.

Failure: Returns 0.

Remarks

This function is used to remove a previous added class to Sputnik for example if you have a plugin system that adds a series of classes you could make the plugin remove all classes when a command is typed.

Then you could load the plugin again basically allowing an update to your programs source code while it is still running.

However any variables that link to your class wont be too happy to find its suddenly disappeared and will cause a crash so make you sure clean up everything that uses the class as you remove it.

Example

// Define a class called MyClass
Class MyClass
{
	Function __construct()
	{
		println("An instance of the class was made");
	}
	Function Hello()
	{
		println("Hello from Class");
	}
};
 
// Try make use of the class
my $Testy = new MyClass();
 
// Now delete the Class from Sputnik
UnsetClass("MyClass");
 
// Try make use of the class AGAIN
// It should crash now since the class no longer exists
my $Testy = new MyClass();
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox