hotcoffee:
the idea of my first "program" is, that I'm iterating and everytime when the iterator variable has a "2" as a digit the ledPin is lightning for 5 seconds.
And a second iterator(waiter) is counting down, everytime, when the ledPin should light.The Problem is that the if-case is only functioning with the number two.
After two the programm never comes back into the if-case and I don't understand why.Could anyone help and I know that it is maybe a bloody noob question, because I am one.
Well, where to start? It never comes back into the if case because the substring is never equal to 2 again. Substring, with just one argument, takes that to be the starting position of the substring, and without an end argument, goes to the end of the string.
If you run it a while, you'll see that fromlength is always one higher than the index of the last character in the String.
If you want to turn on the LED any time there is a '2' in the String, you probably want the .indexof() function.
Frankly, your program baffles me. What is the purpose of sek? you count it down from 2000 to 0, then iterate. Why?
continue is totally useless where it is. It is meant to skip instructions within the innermost enclosing loop and continue the loop from the top. In this case, the innermost enclosing loop is the while, and without the continue, it just starts the while loop again anyway.
michinyon,
There are uses for continue. I've used it mainly to discard further operations on something that I already know, will not be necessary.