[Gambas-user] Declaring 'Public pbSwitch As Object[16]' throws error 'Syntax error in FMain.class:3'

Tobias Boege taboege at ...626...
Tue Aug 15 13:03:03 CEST 2017


On Tue, 15 Aug 2017, Doug Hutcheson wrote:
> I have just found Gambas and have the usual learning curve. Sigh.
> 
> I have copied the code from http://gambaswiki.org/wiki/comp/gb/object/a
> ttach into a new project and tried stepping through it. The first
> statement is the declaration 'Public pbSwitch As Object[16]' and this
> throws ''Syntax error in FMain.class:3'. If I delete the array
> dimension '16', I can step through the code until the first time the
> array is used when it falls over, of course. Can someone please tell me
> what I have done wrong?
> 
> By the way, I am glad to have found Gambas, as it leverages my VB and
> LibreOffice Basic experience. Excellent application!
> 

I don't know if "Public a As x[k]" was ever valid in Gambas (the source code
in the markdown of that page looks like Gambas2). See the Array Declaration
page [1]. You have normally two types of arrays in Gambas. The normal dynamic
ones, which you can declare with

  Public a As New x[k]
  Public a As New x[](k) ' alternative

(note the NEW keyword), and so-called embedded arrays:

  Public a[k] As x

Usually you want the former (normal) arrays.

I updated the example in the Object.Attach() documentation.

Regards,
Tobi

[1] http://gambaswiki.org/wiki/lang/arraydecl

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list