Macros and the IBM CognosScript Language  7.5.0
IBM CognosScript Statements and Functions >

Erase Statement

Description

Reinitializes the contents of a fixed array or frees the storage associated with a dynamic array.

Syntax

Erase Array [, Array ]

where:

is:

Array

The name of the array variable to re-initialize.

Comments

The effect of using Erase on the elements of a fixed array varies with the type of the element:

Element Type

Erase Effect

numeric

Each element set to zero.

variable length string

Each element set to zero length string.

fixed length string

Each element's string is filled with zeros.

Variant

Each element set to Empty.

user-defined type

Members of each element are cleared as if the members were array elements, i.e. numeric members have their value set to zero, etc.

object

Each element is set to the special value Nothing.

Example

This example prompts for a list of item numbers to put into an array and clears array if the user wants to start over.

Sub main
   Dim msgtext
   Dim inum(100) as Integer
   Dim x, count
   Dim newline
   newline=Chr(10)
   x=1
   count=x
   inum(x)=0
   Do
     inum(x)= _
	InputBox("Enter item #" _ 
          & x & " (99=start over;0=end):")
     If inum(x)=99 then
Erase inum()
        x=0
     ElseIf inum(x)=0 then
        Exit Do   
     End If
     x=x+1
  Loop
  count=x-1
  msgtext="You entered the following numbers:" &
newline
  For x=1 to count
     msgtext=msgtext & inum(x) & newline
  Next x
  MsgBox msgtext
End Sub

See Also

Dim Statement

ReDim Statement

LBound Function

UBound Function