Core Function Unset

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Example)
(Example)
Line 37: Line 37:
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
 
my $test = 100;
 
my $test = 100;
Global $link = &$test;
+
my $link = &$test;
 
$link++;
 
$link++;
 
Unset('link'); // If you just do Unset($link)
 
Unset('link'); // If you just do Unset($link)

Revision as of 11:28, 27 January 2013

Unset( $variable )

Contents

Description

Delete a variable

Parameters

$variable

A variable to delete.

OR a string containing the variables name

Return Value

None

Remarks

This can be used to delete DLLStructs, GUI objects and Classes.

Its worth noting to delete from an array you must use the array directly example unset( $a[400] ) you cannot place that element into a variable then expect to unset it and remove it from the array it will not instead it will simple set the element int the array to zero.

Example

unset( $a ); // Delete single variable
unset( $a[500] ); // Delete variable from array
unset( $a["test"] ); // Delete variable from hash

Sometimes you need to delete a variable without deleting the variable its linked to via a reference to do that you enter the variable name as a string example:

my $test = 100;
my $link = &$test;
$link++;
Unset('link'); // If you just do Unset($link)
               // it will kill $test too since they are
			   // linked together so we must kill it by name
			   // instead
println("Test $test");
println("Link " . $link);
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox