Arrays: Difference between revisions
m
Copy paste error fixed
m (→{{header|FutureBasic}}: copy paste error fixed) |
m (Copy paste error fixed) Tag: Manual revert |
||
Line 4,107:
Alpha Romeo Mike
Mike Delta Alpha
</pre>
=={{header|Gambas}}==
In Gambas, there is no need to dimension arrays. The first element of an array is numbered zero, and the DIM statement is optional and can be omitted:
<syntaxhighlight lang="gambas">
DIM mynumbers AS INTEGER[]
myfruits AS STRING[]
mynumbers[0] = 1.5
mynumbers[1] = 2.3
myfruits[0] = "apple"
myfruits[1] = "banana"
</syntaxhighlight>
In Gambas, you DO need to dimension arrays. The first element of an array is numbered zero. The DIM statement is optional and can be omitted ONLY if defined as a Global variable.
'''[https://gambas-playground.proko.eu/?gist=5061d7f882a4768d212080e416c25e27 Click this link to run this code]'''
<syntaxhighlight lang="gambas">Public Sub Main()
Dim sFixedArray As String[] = ["Rosetta", "code", "is", "a", "programming", "chrestomathy", "site"]
Dim sFixedArray1 As New String[10]
Dim iDynamicArray As New Integer[]
Dim siCount As Short
For siCount = 1 To 10
iDynamicArray.Add(siCount)
Next
sFixedArray1[5] = "Hello"
sFixedArray1[6] = " world!"
Print sFixedArray.Join(" ")
Print iDynamicArray[5]
Print sFixedArray1[5] & sFixedArray1[6]
End</syntaxhighlight>
Output:
<pre>
Rosetta code is a programming chrestomathy site
6
Hello world!
</pre>
|