There should be a command like ClearArray() to clear all array contents without re-dimming it, and without looping through all items and setting them to null.
I know we can use FreeArray(), but then we need to re-dim, which means dimming it twice for Global arrays:
Code: Select all
Global Dim a$(100) ; Initial first dim. Needed in case user never calls ClearMyData().
Procedure ClearMyData()
FreeArray(a$())
Global Dim a$(100) ; Second dim. Shouldn't be needed. Why not just ClearArray() instead of this procedure?
EndProcedure
Procedure SetMyData()
For n=1 To 100
a$(n)=Str(Random(100))
Next
EndProcedure
SetMyData()
Debug a$(1)
ClearMyData() ; Optional in my app, user might not ever need it!
Debug a$(1)
SetMyData()
Debug a$(1)
Code: Select all
Global Dim a$(100)
Procedure SetMyData()
For n=1 To 100
a$(n)=Str(Random(100))
Next
EndProcedure
SetMyData()
Debug a$(1)
ClearArray(a$()) ; Doesn't free it, just sets a$(1)="", a$(2)="", etc.
Debug a$(1)
SetMyData()
Debug a$(1)