[Gambas-user] VB to Gambas

Ron Onstenk ronstk at ...239...
Thu Mar 3 11:09:47 CET 2005


On Thursday 03 March 2005 10:02, Eilert wrote:
> Hi Charlie,
>
> is it possible to use this with array objects? I've been trying around a
> bit here, but no hope.
>
> Two questions:
> First: when I try STATIC PUBLIC like in your example, I get an error
> message "ProgType is static" when trying to stuff something into the
> variable. So I changed it to a simple "PUBLIC", then it was ok. Why's that?
>
> Well, now this:
>
> This is an example of what I tryed based on your example:
>
>
> ' Gambas class file ProgType
>
> PUBLIC Name AS String[]
> PUBLIC Pfad AS String[]
> PUBLIC Verzeichnis AS String[]
>
> 'This is in another class (form)
>
> PUBLIC Prog1 AS NEW ProgType
>
> or
>
> STATIC Prog1 AS NEW ProgType
>
>
> and in a SUB there:
>
> 	Prog1.Pfad.Add("hello")
>
> The automatic list appears, so Gambas understands this is an array
> object, it offers "Name", "Pfad", .Add etc., everything ok so far, but
> when I run it I get this "Null object" error.
>
> Why?
>
> I tried to declare the array at different places and in different ways,
> but there is always the same error.
>
> Rolf
>

----------------------
' Gambas class file ProgType
PUBLIC Name AS String
PUBLIC Pfad AS String
PUBLIC Verzeichnis AS String
--------------------

'This is in another class (form)
PUBLIC Prog1 AS NEW object[] ' objects of ProgType
 or
STATIC PUBLIC Prog1 AS NEW object[] ' objects of ProgType

I belive STATIC should be the correct one, try and error ;)

and in a SUB there:
PUBLIC SUB onButton1Click()

	DIM progdata AS NEW ProgType
	progdata.Name= "the_name"
	progdata.Pfad = "The_Pfad"
	progdata.Verzeichnis = "The_Ordner"

> 	Prog1.Pfad.Add("hello")
	Prog1.Add(progdata) 'Prog1 is the array of progdata's
END

May be this will help as a guide.

Ron




More information about the User mailing list