A Beginner's Guide to Gambas, Revised for Version 3

Support for questions or comments about the book

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]

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 .

Filed under: Comments/Questions

Leave a Question or Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

A Beginner’s Guide to Gambas, Revised for Version 3

Click on the book cover to order the paperback book at Infinity Publishing!

Click on the shrimp to go to the main website for Gambas!

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 78 other followers

%d bloggers like this: