Erase: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Add javascript snippet |
||
Line 5: | Line 5: | ||
Erase reinitializes fixed-size arrays, and releases memory allocated for dynamic-array storage. The required component, ''arrays'', is a comma separated list of one or more array variables. | Erase reinitializes fixed-size arrays, and releases memory allocated for dynamic-array storage. The required component, ''arrays'', is a comma separated list of one or more array variables. | ||
== Example == | == Example (Basic) == | ||
<pre> | <pre> | ||
Line 25: | Line 25: | ||
PRINT | PRINT | ||
End Function | End Function | ||
</pre> | |||
== Example (JavaScript) == | |||
<pre> | |||
// Erase Example | |||
/* Erase reinitializes arrays */ | |||
Erase = function(arr) { | |||
var i; | |||
for (i=0; i<arr.length; ++i) { | |||
arr[i]=''; | |||
} | |||
} | |||
PrintArray = function(arr, elements) { | |||
var i; | |||
for (i=0; i<elements; ++i) { | |||
NSB.Print("#" + i + ": (" + arr[i] + ")"); | |||
} | |||
NSB.Print(); | |||
} | |||
var Children=new Array(3); | |||
Children[0] = "Eric"; | |||
Children[1] = "Kenny"; | |||
Children[2] = "Kyle"; | |||
Children[3] = "Stan"; | |||
PrintArray(Children, 4); | |||
Erase(Children); | |||
PrintArray(Children, 4); | |||
</pre> | </pre> | ||
Revision as of 16:20, 19 May 2013
Erase arrays
Description
Erase reinitializes fixed-size arrays, and releases memory allocated for dynamic-array storage. The required component, arrays, is a comma separated list of one or more array variables.
Example (Basic)
Rem Erase Example 'Erase reinitializes arrays Dim Children(3) Children(0) = "Eric" Children(1) = "Kenny" Children(2) = "Kyle" Children(3) = "Stan" PrintArray Children, 4 Erase Children PrintArray Children, 4 Function PrintArray(arr, elements) Dim i For i = 1 to elements Print "#" & i&":","("&arr(i-1)&")" Next PRINT End Function
Example (JavaScript)
// Erase Example /* Erase reinitializes arrays */ Erase = function(arr) { var i; for (i=0; i<arr.length; ++i) { arr[i]=''; } } PrintArray = function(arr, elements) { var i; for (i=0; i<elements; ++i) { NSB.Print("#" + i + ": (" + arr[i] + ")"); } NSB.Print(); } var Children=new Array(3); Children[0] = "Eric"; Children[1] = "Kenny"; Children[2] = "Kyle"; Children[3] = "Stan"; PrintArray(Children, 4); Erase(Children); PrintArray(Children, 4);
Output
#1: (Eric) #2: (Kenny) #3: (Kyle) #4: (Stan) #1: () #2: () #3: () #4: ()