Dim
DescriptionDim name.<type>(<expression>, [<expression>], ...)
Dim is used to 'size' the new arrays. An array in PureBasic can be of any types, including Structure structured, and user defined types. Once an array is 'sized' it can be resized but its content will be deleted. Arrays are dynamically allocated which means than a variable or an expression can be used to size them. When you define a new array, please note that it will have one more element than you used as parameter, because the numbering of the elements in PureBasic (like in other BASIC's) starts at element 0. For example when you define Dim(10) the array will have 11 elements, elements 0 to 10. This behaviour is different for static arrays in structures. Arrays are always globally accessable in PureBasic. This means that they can always be accessed from inside procedures without needing to use the Global or Shared commands. If you want to delete the content of an array and release its used memory during program flow, call Dim with array name and 0 elements. Note: Array bound checking is only done with activated Debugger.Example:
Dim MyArray.l(41) MyArray(0) = 1 MyArray(1) = 2 Example 2 : Dim MultiArray.b(NbColumns,NbLines) MultiArray(10,20) = 10 MultiArray(20,30) = 20