[Gambas-user] declaring user-defined datatype arrays as PUBLIC

Bodard Fabien gambasfr at ...11...
Thu Mar 3 22:16:04 CET 2005


Le jeudi 3 Mars 2005 22:06, Horst Geisler a écrit :
> Hey there
> I have Problems with declaring user-defined datatype arrays as _PUBLIC_
> in Gambas:
>
> '#I have this user-defined datatyp
> clBelegung.class:
>
> Public  Name As String
> Public  Zustand As boolean
> ---------------------------------------------------
> '# and I declare in another global class File
> _clGlobal.class:_
> STATIC PUBLIC  Eingang AS NEW clBelegung[]
> ---------------------------------------------------
> '#I want use it and its values in different modules like this:
> _module1.module:_
> DIM i as INTEGER
> For i=1 to 7
>    clGlobal.Eingang[i].Name ="&23" & i
>    clGlobal.Eingang[i].Zustand = True
> Next
> ---------------------------------------------------
> _module2.module:_
> DIM i as INTEGER
> For i=1 to 7
>    Print clGlobal.Eingang[i].Name  & ":" & clGlobal.Eingang[i].Zustand
> Next
> ---------------------------------------------------
>
> If I 'run' this Gambas Project  I get the error messages like
>
> 'Arrays are forbidden here'  (STATIC PUBLIC  Eingang[] AS NEW clBelegung)
> or
> 'Syntax error at line ...'  (STATIC PUBLIC  Eingang AS NEW clBelegung[])


In fact you have 2 way :
first:
define the array size as static array like
STATIC PUBLIC  Eingang[6] AS NEW clBelegung

else
define a dynamic object array and then set each entry with a new class

STATIC PUBLIC  Eingang AS NEW Object[]

in Public Sub _New()

dim i as integer
For i = 0 to 6
	Eingang[i] = NEW clBelegung
next

Fabien Bodard





More information about the User mailing list