Go Down

Topic: Help with Loops and IFs?? (Read 1 time) previous topic - next topic

LockDots

Jan 12, 2013, 12:20 am Last Edit: Jan 12, 2013, 06:54 am by LockDots Reason: 1
First time programmer here, please be gentle  :P

I'm used to programming in pBasic from taking a course in it in school but I'm trying to teach myself C/C++ or whatever the Arduino programming language is called and having writer's block so to say.

I need to write a bit of code that uses (if need be) an IF statement where if the condition is true it needs to loop to itself endlessly until the condition is not met.

For example, in pBasic I would write:

StarterCheck:
If StarterIn = HIGH THEN StarterCheck

How would I do this in C?

tuxduino

That would be GoTo, I guess.

LockDots

It wouldn't cause an issue using GoTo to send it to itself?

LarryD

The way you have it in your schematic isn't the same as how you have it wired up!

tuxduino

#4
Jan 12, 2013, 01:06 am Last Edit: Jan 12, 2013, 01:08 am by tuxduino Reason: 1
A sub calling gosub itself causes infinite recursion and eventually a crash due to memory exhaustion.

edit: that is, if there's no end condition or it's triggered too late.

Go Up