[Gambas-user] Arrays

Steven Lobbezoo steven at ...1652...
Sat Apr 21 11:44:10 CEST 2007


Thanks a lot ron, 
that made it perfectly clear.

We should have a meganism to add these kind of comments
(maybe after verification by Benoit) to the documentation.
A bit like the docs for MySQL.
(And make it searchable)

Would be great.

Steven


Le samedi 21 avril 2007 01:15, ron a écrit :
> On Friday 20 April 2007 23:21, Steven Lobbezoo wrote:
> > Maybe it's better make it more clear with an example :
> >
> > I declare in the OOffice module :
> > PUBLIC Docs_t AS Object[] = [["terrain", "fiche",
> > "fiche_bien_terrain.odt"], ["terrain", "vitrine_horizon",
> > "vitrine_bien_terrain.odt"], ["appartement", "fiche",
> > "fiche_appart.odt"], ["batiment", "fiche", "fiche_bien_batiment.odt"]]
> >
> > than, in an other module / form i do
> >
> > Dim tmp[2]
> >
> >     tmp[0] = "terrain"
> >     tmp[1] = "fiche"
> >     hInt = OOffice.Docs_t.Find(tmp)
> >
> > And I want the index of the Objects array back in hInt
> > where the first 2 fields are as above.
> >
> > Actually it allways returns -1. Even if I feed it all tree fields.
> >
> > Steven
>
> for the first line:
> > PUBLIC Docs_t AS Object[] = [["terrain", "fiche",
> > "fiche_bien_terrain.odt"],
>
> the first series of names as ["terrain", "fiche", "fiche_bien_terrain.odt"]
> is a string[] element[0]="terrain"
> element[1]="fiche"
> element[2]="fiche_bien_terrain.odt"
>
> You did want "terrain" as key instead as value
>   sDataArray=Docs["terrain"]
> and then you have in
>   sDataArray[0] the value "fiche"
>   sDataArray[1] the value "fiche_bien_terrain.odt"
>
> All arrays are indexed by number except the collection that can have number
> or text.
>
> Your example Docs is stored as
> __|     0                  |     1                    |      2             
>                    | <-- item number in the record 0 | "terrain"          
> | "fiche"                | "fiche_bien_terrain.odt"    | 1 | "terrain"     
>      | "vitrine_horizon" | "vitrine_bien_terrain.odt"  | 2 | "appartement"
> | "fiche"                | "fiche_appart.odt"             | 3 | "batiment" 
>      | "fiche"                | "fiche_bien_batiment.odt" |
>
> ^------- record number
>
> I hope this explains why it not is working
>
> Ron
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user




More information about the User mailing list