loop gone wrong


made a loop that need to test if the user has entered a valid number or not, cant see what i have done wrong but it does not work like i want it to.
i have also tried to make it check if the user has entered a number (any number) but couldn´t get to work either. for that purpose i use if (isDigit(subCounter)){} first with a Serial.read() to read a byte, and second with a Serial.parseInt()

i have included the total code here with this thread.

while(Serial.available()==0){} //vent på bruger indtastning
subCounter=Serial.parseInt(); //læs ind indtastning i varialbel
if(subCounter >=1 || subCounter <=255){} //test indtastning for verdi
Serial.println(“Du har ikke indtastet et nummer!! prøv igen…”); //print tekst og skift linie
goto tastTal; //hop til tastTal

sketch_may28d.ino (4.83 KB)

Don’t attach code, post incline with code tags

Are you sure about your|| ? Don’t you want && ?

What’s this goto crap?

the goto crap ...

the meaning here was if the user did not entered a valid answer to repeat until he/she did

and you are right about the && instead of the||

“subCounter >=1 || subCounter <=255” : Hvis subCounter er større end 0 eller mindre end 256 er det samme som at sige alle heltal, hvilket næppe er hvad du vil. Post din sketch ved hjælp af kode-tags i stedet for at vedhæfte den :slight_smile:

tak, men aner ikke hvordan man får det til, er helt ny i dette.

hvordan gør man det med tags ?

Just add the code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

(And best to write in English in the English forum)