[Gambas-user] gb3: converting structures to classes

Kevin Fishburne kevinfishburne at ...1887...
Tue Feb 7 09:46:36 CET 2012


On 02/06/2012 11:35 PM, nando wrote:
> Quite easy.
> Here's a suggestion/example
>
>
>
> Make a class called Tune...
> ...Dim a bunch of privates for values (name, artist, date, genre)
> ...Write SUBs for things to do with Tunes
>
>
> In FMain...
> PUBLIC Tunes AS Object[]
>
>
>
> In a SUB somewhere...
> Dim newTune as NEW Tune( possible constructor information if you want)
>
> Tunes.Add( newTune)
>
> ---
>
> As long as Tunes[] points to class instances of Tune, they remain existing.
>
>
> -Fernando
>
>
>
> ---------- Original Message -----------
> From: Kevin Fishburne<kevinfishburne at ...1887...>
> To: gambas-user at lists.sourceforge.net
> Sent: Mon, 06 Feb 2012 22:58:46 -0500
> Subject: Re: [Gambas-user] gb3: converting structures to classes
>
>> On 02/06/2012 09:36 AM, nando wrote:
>>> I am doing the same thing.
>>> Using class in place of structures.
>>> Then arrays or collections of the classes.
>>> Works great!
>>>
>> What are the general steps to do such a thing? How do you declare a
>> class, define its properties, then create an array of the class? I'm
>> starting to think it may be more complicated (or at least different)
>> than with structures.
>>

Looks like a class is a structure with optional methods attached to 
procedures instead of just assignable properties. I'll play around with 
it and see if I can reproduce the structures as per your example. There 
should be a super simple project somewhere to show how classes work on a 
basic level. This is BASIC, so one can't presume people know what 
classes are. Thanks, classes look like they could be very useful.

-- 
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271





More information about the User mailing list