Core Function UnsetFunction
From Sputnik Wiki
(Difference between revisions)
UberFoX (Talk | contribs)
(Created page with "<pre> UnsetFunction( <function-name> ) </pre> === Description === Delete a previous user defined function from Sputnik. ==== function-name ==== The function name to delete. ...")
Newer edit →
(Created page with "<pre> UnsetFunction( <function-name> ) </pre> === Description === Delete a previous user defined function from Sputnik. ==== function-name ==== The function name to delete. ...")
Newer edit →
Revision as of 16:12, 19 April 2012
UnsetFunction( <function-name> )
Contents |
Description
Delete a previous user defined function from Sputnik.
function-name
The function name to delete.
Return Value
Success: Returns 1.
Failure: Returns 0.
Remarks
This function is used to remove a previous added function to Sputnik for example if you have a plugin system that adds a series of functions you could make the plugin remove all functions 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.
Example
// Make a string containing text of a FUNCTION to load this string as Sputnik code later my $Function = @" Function Add2($a, $b) { return $a + $b; } "; // Load the function for the first time // This will view the string as a peice of Sputnik code (same as include()) Eval($Function); // Bascially it will add the funciton "Add2" to Sputnik // Call the function println("1+2 Is: " . Add2(1, 2) ); // Now delete the function from Sputnik UnsetFunction("Add2"); // Try call the function again println("Lets try call it again"); println("1+2 Is: " . Add2(1, 2) ); // Notice the crash here? // It crashes above because the funciton "Add2" no longer exists within Sputnik