[Gambas-user] Bad string conversion etc.

Simonart Dominique simonart.dominique at ...11...
Wed Oct 1 14:23:54 CEST 2008


Hi,

Rolf-Werner Eilert a écrit :

> 2. Here "Maske" is a tabstrip. First it is checked that it has enough 
> tabs. Then the "current" tab is set.
> 
> IF CInt(wert[0]) > Maske.Count THEN Maske.Count = CInt(wert[0])
> Maske.Index = CInt(wert[0] - 1)
> 
> Gambas will stop at the second line complaining "Type mismatch: wanted 
> Number got String instead".
> 
> Well, wert[0] at this time contains the string "1". This is a string 
> with a number, and CInt should convert it to a numeric value, shouldn't 
> it? (I tested to leave out the "- 1", this resulted in "Bad index" for 
> the tabstrip!)

I'm far to be expert with Gambas but here I think I 
understand the cause of your problem.
In this instruction, Gambas try to evaluate first the 
expression between parenthesis, and it find a (string - 
number) expression, which is bad. I would rather write
Maske.Index = CInt(wert[0]) - 1

I think that the second experience fails because wert[0] is 
bigger than the acceptable max index value

Dominique Simonart





More information about the User mailing list