instr and instrrev bug *solved*
Posted: Sun Nov 06, 2016 3:29 pm
Hi,
As ESP Basic has no 2 -dimensional array's (yet I hope) I was going to make an array that has multiple values in each element for setting RGB values in a neopixel string.
The variable will look like a = "r100 g200 b300"
So for getting the sriings out for putting the right values in the Neopixel commands I would use the instr() command.
Now I think I found a bug or maybe something I do not understand so please have a look at this:
This program prints 6 as value of the variable valg which it is supposed to be
And this also print 6 as value for valg.
As far as I read in the documentation the 3d parameter tells instr from where to start counting. 3 is in my opinion the 3d letter so the outcome should not be 6.
Now this:
The outcome is in this case also 6 and it should be counting from the right side backwards so should not be giving 6 as an answer but 9.
This print a 0 as value for valg.
Something wrong with these commands or am I missing something ???
I am using ESP Basic 3.0.Alpha 59
Luc
As ESP Basic has no 2 -dimensional array's (yet I hope) I was going to make an array that has multiple values in each element for setting RGB values in a neopixel string.
The variable will look like a = "r100 g200 b300"
So for getting the sriings out for putting the right values in the Neopixel commands I would use the instr() command.
Now I think I found a bug or maybe something I do not understand so please have a look at this:
Code: Select all
a = "r100 g200 b300"
print a
valg = instr(a, "g")
print valg
This program prints 6 as value of the variable valg which it is supposed to be
Code: Select all
a = "r100 g200 b300"
print a
valg = instr(a, "g", 3)
print valg
And this also print 6 as value for valg.
As far as I read in the documentation the 3d parameter tells instr from where to start counting. 3 is in my opinion the 3d letter so the outcome should not be 6.
Now this:
Code: Select all
a = "r100 g200 b300"
print a
valg = instrrev(a, "g")
print valg
The outcome is in this case also 6 and it should be counting from the right side backwards so should not be giving 6 as an answer but 9.
Code: Select all
a = "r100 g200 b300"
print a
valg = instrrev(a, "g", 3)
print valg
This print a 0 as value for valg.
Something wrong with these commands or am I missing something ???
I am using ESP Basic 3.0.Alpha 59
Luc