[Gambas-user] class within a class with a key
Bruce Steers
bsteers4 at gmail.com
Fri Apr 14 18:26:31 CEST 2023
use Export to expose functions.
I added the _get command to Class1.class
now something like this works...
Print gb_Class1["key_01"].student_01
Print gb_Class1["key_01"].student_02
Print gb_Class1["key_02"].student_01
Print gb_Class1["key_02"].student_02
On Fri, 14 Apr 2023, 16:18 Mayost Sharon, <sharon at 455.co.il> wrote:
> ---------- Original Message -----------
> From: Bruce Steers <bsteers4 at gmail.com>
> To: Gambas Mailing List <user at lists.gambas-basic.org>
> Sent: Fri, 14 Apr 2023 14:56:09 +0100
> Subject: Re: [Gambas-user] class within a class with a key
>
> > On Fri, 14 Apr 2023 at 13:55, Mayost Sharon <sharon at 455.co.il> wrote:
> >
> > > Hello
> > > I need help on how to make a class within a class
> > > Attached is an example that gives me an error because I'm missing
> > > something that I can't figure out what to do
> > >
> > > I want to reach a state of:
> > > Print gb_Class1.students["key_01"].student_01
> > > Print gb_Class1.students["key_01"].student_02
> > >
> > >
> > > Thank you
> > >
> > > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> > >
> >
> > to use Keys like a collection you need to use Collection datatype.
> > Your Class2.class is not coded to work like a collection with Keys so it
> > does not work as you expect.
> >
> > I got your code working by making the Class1.class $students a
> collection
> > of Class2 objects.
> > Class2.class has no functions just the student_01 student_02 properties.
> >
> > BruceS
> ------- End of Original Message -------
>
> First of all thank you very much
>
> 1.
> When I type "." In the end so that it completes
> gb_Class1.students.
> This completes a collection list
> I wanted it to complement only what is in class 1
> .Add
> .students
>
> 2.
> When I type "." In the end so that it completes
> gb_Class1.students["key_01"].
> It does not complete anything
> Because it understands that it is a Variant variable
> I wanted it to complement only what is in class 2
> .student_01
> .student_02
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230414/464a0ef8/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: class_01-0.0.1.tar.gz
Type: application/gzip
Size: 12156 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230414/464a0ef8/attachment.gz>
More information about the User
mailing list