User Tools

Site Tools

k7:k7.4:k7.4.3:k7.4.3.1:start Native arrays

Gambas has a predefined array class for each native data type. The name of these classes is the name of the data type followed by an open and a closed square bracket:

Boolean[] 	Array of Boolean Values
Byte[] 	        Array of byte values
Short[] 	Array of short values
Integer[] 	Array of integer values
Long[] 	        Array of long values
Single[] 	Array of Single values
Float[] 	Array of Float values
Date[] 	        Array of Date values
String[] 	Array of string values
Object[] 	Array of Object values
Pointer[] 	Array of pointer values
Variant[] 	Array of Variant values

You can initialize an array or create an array within an expression with the[….Chapter 7.4.5 Inline Arrays.

Examples for the declaration of native arrays:

Dim myArray As New String[]
Dim myTable As New Float[10, 8]
Dim dArray As New Date[]
Dim aObjectArray As New Object[]

Example of using a native array:

  • Declaration of the variables aPlanets of type String array
  • Create an array object
  • Paste nine elements (data type string) into the string array using an inline array
  • Output of all elements of the array in the console of the Gambas IDE
Dim sElement As String
Dim aPlanets As String[]

aPlanetes = New String[]
aPlanetes = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"]

For Each sElement In aPlanetes
  Print sElement,
The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k7/k7.4/k7.4.3/k7.4.3.1/start.txt · Last modified: 05.02.2022 (external edit)

Page Tools