[Gambas-user] Bad string conversion etc.
Benoit Minisini
gambas at ...1...
Wed Oct 1 14:45:33 CEST 2008
On mercredi 01 octobre 2008, Rolf-Werner Eilert wrote:
> Still trying to convert a Gambas1 app to Gambas2. Basically, it begins
> to run. However, there are strange error message at some points, and I
> do not understand what causes them.
>
> 1. This line
>
> po = links.Find(wert[8], gb.Language)
>
> results in "Bad string conversion". Strange to me, as I do not see any
> conversion here.
By using gb.language, you force a locale-aware comparison of the strings
inside links. This locale-aware string comparison is implemented by first
converting the strings into 32 bits Unicode, and that conversion apparently
fails. What does the links array contain?
>
> 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!)
This is a little bug in addition optimization. Anyway, if you want to do
arithmetic, do it on numbers, not on strings:
Maske.Index = CInt(wert[0]) - 1
Regards,
--
Benoit Minisini
More information about the User
mailing list