Thanks to “stanks”, who downloaded the book, started working with it, and encountered a problem related to a change in Gambas3. On the web page “Array Declaration“, note that “In Gambas 3, embedded arrays cannot be used as local variables anymore. But they can be public!“
Therefore, on page 54, when you are using Gambas3, the code should read:
Public narMatrix[3, 3, 3] As Integer
Public Sub Main()
Dim i As Integer
Dim ii As Integer
Dim iii As Integer
For i = 0 To 2
For ii = 0 To 2
For iii = 0 To 2
Print i, ii, iii & ” ==> “; ‘note that “;” prevents a newline.
narMatrix[i, ii, iii] = i * 9 + ii * 3 + iii
Print narMatrix[i, ii, iii]
Next
Next
Next
End
If you don’t make this change, you will get the error message “Embedded arrays are forbidden here in MMain.module“.
Also, note that declaring the array “PUBLIC” means that you don’t use the keyword DIM — “PUBLIC” automatically does the dimensioning .
Like this:
Like Loading...
Filed under: Comments/Questions
February 10, 2012 • 5:51 pm
Adjustment to code on page 54, for Gambas3 only
Thanks to “stanks”, who downloaded the book, started working with it, and encountered a problem related to a change in Gambas3. On the web page “Array Declaration“, note that “In Gambas 3, embedded arrays cannot be used as local variables anymore. But they can be public!“
Therefore, on page 54, when you are using Gambas3, the code should read:
Public narMatrix[3, 3, 3] As Integer
Public Sub Main()
Dim i As Integer
Dim ii As Integer
Dim iii As Integer
For i = 0 To 2
For ii = 0 To 2
For iii = 0 To 2
Print i, ii, iii & ” ==> “; ‘note that “;” prevents a newline.
narMatrix[i, ii, iii] = i * 9 + ii * 3 + iii
Print narMatrix[i, ii, iii]
Next
Next
Next
End
If you don’t make this change, you will get the error message “Embedded arrays are forbidden here in MMain.module“.
Also, note that declaring the array “PUBLIC” means that you don’t use the keyword DIM — “PUBLIC” automatically does the dimensioning .
Share this:
Like this:
Filed under: Comments/Questions