Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 09:02 02 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : FOR NEXT can I have 2 next?

Author Message
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 06:16am 13 Oct 2015
Copy link to clipboard 
Print this post

Is this legitimate...

FOR X = 1 TO 10

GETINFO

IF Z = 0 THEN
STUFF(X) = 0
NEXT X
END IF

STUFF(X)=Z*2

NEXT X

Not concerned about the operations, but can there be 2 nexts in a for next loop based on an if then?
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 06:41am 13 Oct 2015
Copy link to clipboard 
Print this post

No you can not.
However in beta 36 there is now a CONTINUE FOR, which i am happy to say is one of my wishes coming true. :)

You would use it like this:
[code]
FOR X = 1 TO 10
GETINFO
IF Z = 0 THEN
STUFF(X) = 0
CONTINUE FOR
END IF

STUFF(X)=Z*2
NEXT X
[/code]
You example could also be done with:
[code]
FOR X = 1 TO 10
GETINFO
IF Z = 0 THEN
STUFF(X) = 0
ELSE
STUFF(X)=Z*2
END IF
NEXT X
[/code]
Which in this particular case would be a better way to do it.
But i guess it was only an example, not a real part of the program.


Edited by MicroBlocks 2015-10-14
Microblocks. Build with logic.
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 06:54am 13 Oct 2015
Copy link to clipboard 
Print this post

Thanks MB, that make perfect sense. Couldn't see the forest for the trees... What was I thinking?????
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024