erase - erase array


erase ArrayName[, ArrayName]. . . 


The erase statement erases each array given by ArrayName.  An ArrayName is the name of an array, without the subscripts and parentheses normally used in an array reference.  An array may be static or dynamic (see dim).  The details of the erase statement differ for static and dynamic arrays. 

For a static array, each element of the array is reset.  For a numeric array, each element is set to zero.  For a string array, each element is set to the null string (and any space associated with the old string is deallocated). 

For a dynamic array, the array becomes "un-dimensioned" (and all space associated with the array is deallocated).  The elements of a dynamic array may be used only when the array is dimensioned.  For the elements of an erased dynamic array to be useful, the array must be redimensioned. 

Before an array appears in an erase statement, the array must appear in a statement which dimensions the array.  An array may be erased more than once.  An array which is a formal parameter to a subprogram may not be erased. 


The program fragment
	rem $static
	dim a(100)
	rem $dynamic
	dim b(100, 100)
	erase a, b
demonstrates the use of erase for static and dynamic arrays.  If the static array "a" is sparse, erasing it might be a convenient first step in its reuse.  If the dynamic array "b" is large, erasing it might make needed memory space available. 



from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber