UnDim
UnDim ArrayName()
 
Parameters:

    ArrayName() = The Array you wish to UnDim.
Returns: NONE
 

      UnDim will completely free any memory that an array might be using. Freeing arrays memory that we're no longer using is a good programming habit to get into!

      Once the array has been UnDimmed, it will be empty of all information. So before it can used again, PlayBASIC expects that you'll DIMension it again.




FACTS:


      * When you UnDIM an array, you return (free) this memory back to the computer.

      * If you UnDim an array that contains information, that information will be lost.

      * The array name following the UnDim command does not require any array indexes, just a pair of closed brackets. i.e UnDim MyArray()

      * An UnDim'd array can't be used again, until it's been created (allocated) using the DIM command.




Mini Tutorial:


      Most commonly we'll only need to use UnDim to free an array that was created for temporary use. So in that case we'd dimension our temp array, perform our calculations upon it, and once were done, Undim it.

  
; Use DIM to Create an array called "MyTempArray"
  Dim MyTempArray(1000)
  
; Here you would do some calculations using the temp array..
  
; Once your finnished,  use UnDIM to Free the memory that "MyTempArray" is was using.
  UnDim MyTempArray()
  
  




 
Example Source: Download This Example
; ================================
; UNDIM EXAMPLE by Kevin Picone
; ================================
  
; Create an Integer Array called "MyArray" containing 100 elements
  Dim MyArray(100)
  
; Call a function to Display some messages about the current
; Status of MyArray
  MyArrayStatus()
  
  
; Now UNDIM (delete the information within) this array.
  UnDim MyArray()
  
; Call a function to Display some messages about the current
; Status of MYARRAY after it's been Undimmed
  MyArrayStatus()
  
  
; Display the Screen and and wait for input
  Print "Press any Key To End"
  Sync
  WaitKey
  
; end this program
  End
  
  
  
  
  
Function MyArrayStatus()
  Print "Checking MYARRAY() status"
  Print "-------------------------"
; Check the Status of this array
  If GetArrayStatus(MyArray())=true
   ; If the array has been Dimmed, display a message sayig so
     Print "Yes MyArray() has been dimmed and is ready for use"
     Print "MyArray() currently has space for ("+Str$(GetArrayElements(Myarray(),1))+") elements within it"
  Else
   ; If the array has not been dimmed or has been UNDIMMED, then it's empty
   ; so we'll display as message
     Print "No MyArray() is currently EMPTY and must be Dimmed before it can be used again"
  EndIf
  Print ""
EndFunction
  
  
  
  
  
  
  
  
 
Related Info: DeleteArray | Dim | GetArrayDimensions | GetArrayElements | GetArrayStatus | MakeArray | ReDim | UnDimAll :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com