[Gambas-user] Arrays
ron
ronstk at ...239...
Sat Apr 21 01:15:14 CEST 2007
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
More information about the User
mailing list