It looks like you're new here. If you want to get involved, click one of these buttons!
what you probably mean by an IF loop is start:... CODE ...IF NOT(FOOBAR = 100) THEN FOOBAR=FOOBAR+1; GOTO start
Am I right ?If yes, then i well tell you than a FOR loop justmakes your code much clearer, slightly faster becausein this situation a FOR loop is the obvious choice,simply because thats what its for.If you have imbricated loops, you just have to use forunless you wand your code illegible. See example:
FOR I=1 TO 100 STEP 5 FOR J=1 TO 100 STEP 5 FOR K=0 TO 20 STEP .2 ... CODE ... NEXT K NEXT JNEXT I
is simpler, clearer, faster, more logical, better than
I = 0: J = 0: K = 0start_loop: 'Endless loop... CODE ...IF NOT(K=20) THEN K = K + .2: GOTO start_loopIF NOT(J=100) THEN J = J + 5: GOTO start_loopIF NOT(I=100) THEN I = I + 5: GOTO start_loop
Its just a matter of clarityGet a FOR loop and everyone will understant thatyou have three imbricated loopsThe IF loop with GOTOs are apalling.GET RID OF GOTOs !ITS POSSIBLE !HAVE NONE IN YOUR CODE, THEY REALLY SUK
Got it ?
Well in general people say that GOTO's are badfor you, and yes I agree.. in most situationsyou can get by without using a GOTO statement..
You can use stuff like: FOR, NEXT: DO, LOOP: WHILE, WEND...
BUT IMO there are some cases where a goto perhaps is not a very bad idea to use... like:
for x = 0 to 100 for y = 0 to 100 for z = 0 to 100 if condition = TRUE then goto OUTofLOOP next next next OUTofLOOP:
You have a lot of nestled loops, and you want to get out from them all..But yes I know you can get by using a while, wend, or do, loop......But I just wanted to mention it.
I try to stay away from GOTO's as much as I possibly can..It was a LONG time since I used one.
Ya, if you have anything to comment please do..Bye fellow programmes!