[Gambas-user] too many operands

Doriano Blengino doriano.blengino at ...1909...
Tue Sep 8 08:44:11 CEST 2009


MSulchan Darmawan ha scritto:
> Pada Mon, 07 Sep 2009 13:19:32 +0200
> Doriano Blengino <doriano.blengino at ...1909...> menulis:
>
>   
>>        res = db.Create("refpos")      ' append record in table named
>> refpos for i = 1 to 31
>>          res["Res" & i] = ...
>>        next
>>     
>
> Does this means the field name is Res1, Res2, ..., Res31 ???
> If so, wow this is great, I didn't know that variable names can be
> iterated.
>   
Res1, Res2... are *not* variables (or variable names), they are fields 
of a database record. The Result object takes care of getting the index 
between square brackets, which can be an arbitrary string, even a string 
expression, and operate on the corresponding record field.

This is why I omitted the right part of the assignment ("..."); in that 
place you can not do the same trick: but of course you can if you use 
there some object like another Result[] or Settings[] or objects like 
those, which can be indexed by mean of string expression.

Regards,
Doriano



More information about the User mailing list