トピック
James kawaiipikachu

NEXT command help

Im writing a simple progam to cycke through text & text background colours. While I was successful with text colour itself but as soon as I added the third line in the screenshot to cycle through text background I been gettint the "FOR without NEXT at 0:7" error message.
1そうだね
プレイ済み
返信[1]
親投稿
James kawaiipikachu
Also I tried adding NEXT to line 7 & so far the program does nothing including no error message until I stop the program.
0そうだね
プレイ済み
返信[2]
親投稿
SirZora 640Luigi
you need to put a second "Next" inside your Loop
0そうだね
プレイ済み
返信[3]
親投稿
James kawaiipikachu
I tried putting NEXT between the original NEXT & GOTO @LOOP & nothing happen didn't print out the "hello world" & no error message.
0そうだね
プレイ済み
返信[4]
親投稿
Aaron Krondelo
That's because your program is looping thousands of times per second, it needs a WAIT command to slow it down. WAIT 60 at the end of the loop would wait 1 second before looping again.
0そうだね
未プレイ
返信[5]
親投稿
Aaron Krondelo
And yes, you need a NEXT directly after the first NEXT. You can't have a FOR loop without a NEXT. I recommend printing your loop variables so you can see what your nested loop is doing.
0そうだね
未プレイ
返信[6]
親投稿
Nicole moesaku
The reason it's not working is because of the step in your second loop: FOR Y=15 TO 0 STEP 1 SmileBASIC does not automatically go backwards here. Instead, it actually counts 15, 16, 17, 18... and won't end until it hits 0. The problem is, it never will, since it's counting up instead of down. Instead, you need this: FOR Y=15 TO 0 STEP -1 With a step of -1, it will subtract 1 from Y each loop.
3そうだね
未プレイ
返信[7]
親投稿
Nicole moesaku
Something else that might help is indenting your code. It makes code easier to read and makes it easier to tell where things begin and end: @LOOP FOR X=0 TO 15 STEP 1 FOR Y=15 TO 0 STEP -1 COLOR X,Y:PRINT "HELLO WORLD" NEXT NEXT GOTO @LOOP
3そうだね
未プレイ
返信[8]
親投稿
James kawaiipikachu
Thanks & I got the program to work as how I wanted it now. Cheers.
1そうだね
プレイ済み
返信[9]
親投稿
Nicole moesaku
(Oops, my info was slightly wrong. FOR Y=15 TO 0 STEP 1 doesn't loop forever, it actually skips the loop entirely. It ends when Y is greater than or equal to 0, and 15 is greater than 0 to begin with, which is why your code did nothing before.)
0そうだね
未プレイ
返信[10]
親投稿
sambear sambear2005
#save miiverse
0そうだね
未プレイ