Repository navigation
Erase
Home › Array Functions › Erase
Frees a variable-length array's elements, or resets those of a fixed-length array.
Declare Sub Erase ( array As Any [, ... ] )array
Using Erase on a fixed-length array resets all elements without freeing the allocated memory.
In case of objects, there is destruction then re-construction.
Using Erase on a variable-length array (array already sized) frees the memory allocated for the array elements, but the array remains declared at its same scope level (with the same datatype and number of dimensions), only the high/low bounds values of each dimension are reset (-1/0).
In case of objects, there is destruction before freeing memory.
Erase( array0 [, array1 ... arrayN ] )
- None
Dim MyArray1(1 To 10) As Integer
ReDim MyArray2(1 To 10) As Integer
Erase MyArray1, MyArray2Example showing the before and after results of single-dimension arrays:
Dim MyArray1(1 To 10) As Integer
ReDim MyArray2(1 To 10) As Integer
Print "MyArray1", LBound( MyArray1 ), UBound( MyArray1 ) ' prints: MyArray1 1 10
Print "MyArray2", LBound( MyArray2 ), UBound( MyArray2 ) ' prints: MyArray2 1 10
Erase MyArray1, MyArray2
Print "MyArray1", LBound( MyArray1 ), UBound( MyArray1 ) ' prints: MyArray1 1 10
Print "MyArray2", LBound( MyArray2 ), UBound( MyArray2 ) ' prints: MyArray2 0 -1Example showing the before and after results of multi-dimension arrays:
Dim MyArray1(1 To 3, 4 To 9) As Integer
ReDim MyArray2(1 To 3, 4 To 9) As Integer
Print , "LOWER", "UPPER"
Print "MyArray1", _
LBound( MyArray1, 1 ); ", "; LBound( MyArray1, 2 ), _
UBound( MyArray1, 1 ); ", "; UBound( MyArray1, 2 )
Print "MyArray2", _
LBound( MyArray2, 1 ); ", "; LBound( MyArray2, 2 ), _
UBound( MyArray2, 1 ); ", "; UBound( MyArray2, 2 )
Erase MyArray1, MyArray2
Print
Print "MyArray1", _
LBound( MyArray1, 1 ); ", "; LBound( MyArray1, 2 ), _
UBound( MyArray1, 1 ); ", "; UBound( MyArray1, 2 )
Print "MyArray2", _
LBound( MyArray2, 1 ); ", "; LBound( MyArray2, 2 ), _
UBound( MyArray2, 1 ); ", "; UBound( MyArray2, 2 )The above example will output:
LOWER UPPER
MyArray1 1, 4 3, 9
MyArray2 1, 4 3, 9
MyArray1 1, 4 3, 9
MyArray2 0, 0 -1, -1
Category: Array Functions
Kind: sub
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing