? Label Loops ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Label Loops

NEVER USE THESE.

@LOOP 'CODE GOTO @LOOP @LOOP GCLS GOSUB @GAME GOSUB @RENDER WAIT 1 GOTO @LOOP @GAME 'CODE RETURN @RENDER 'CODE RETURN
Author
kenchic
Updated
Rating
16 votes
Categories
Keywords
  • label
  • loops
  • never
  • use
57 Comment(s) ProKuku ProKuku Avatar Taboo I didn't change my avatar for 180 days Website First Year My account is over 1 year old Website Pokemon Is Awesome! I love Pokemon! Express Yourself I like how something so obvious managed to get chicken the “good page” badge. Y_ack Y_ack Actually, it was https://smilebasicsource.com/page?pid=698 that did. This one is too controversial; 'Good page' requires a certain ratio of upvotes to downvotes. 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Maybe you should suggest an alternative rather than just telling people not to do something. I'm pretty sure there are already like 10 pages for WHILE/REPEAT loops though. Y_ack Y_ack I think the idea was to make an explanation for Label use examples and the comment made it in there for obvious reasons MochaProbably MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies Fun fact: REPEAT loops exist too. They loop until an contidion is satisfied. ninjagnu ninjagnu Basically while but checks condition after an iteration not before. random_god random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Video Games I like to play video games! Hobbies fun fact you NEED to use for loops to load a map on screen, at least of what i know, ex: FOR I=0 TO 3 BGSCREEN I,127,128'(or I,64,64) NEXT /the rest of map loading code random_god random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Video Games I like to play video games! Hobbies edit button too small on the end of the code its 'the rest of map loading code UnderCake UnderCake Halloween 2017 Contest Runner Up I placed 2nd in the SmileBASIC Source Halloween 2017 Contest! Programming Contest Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength First Year My account is over 1 year old Website actually that only if you want to make it faster and easyer, you can do without it would just be a lot more code. but yes good Y_ack Y_ack GOTO can emulate any other loop structure. They exist for convenience, as do the named commands and BASIC itself. Programming as we know it is about abstraction. Anyway, for comparison: FOR I=0 TO 3 BGSCREEN I,127,128 NEXTcan be accomplished with this literal jump: VAR I = 0 @LOOP_1 BGSCREEN I,127,128 DEC I, -1 'for "speed" IF I <= 3 THEN GOTO @LOOP_1In addition, a finite loop can be "unwrapped" by writing out every instruction. BGSCREEN 0,127,128 BGSCREEN 1,127,128 BGSCREEN 2,127,128 BGSCREEN 3,127,128 The counting "FOR" loop allows us to not worry about iterator variables, it handles the increment itself. Most of the "debate" occurring in the comments here seems to be DSM not bothering to learn structures like this. I'm sure he'll choose the unwrapped version when checking all 512 sprites--after all, it's faster that way. TheV360 TheV360 Third Year My account is over 3 years old Website First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself DaSonicMario, if you want the most speed for your programs, don't use Python, Lua, or C#! Use Assembly! It's so much faster! Sure you sacrifice a little code readability, but in the end, it's worth it. IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength no i meant speed in basic, idiot also basic and lua are the only programming languages i know TheV360 TheV360 Third Year My account is over 3 years old Website First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself it was an extreme example and it was sarcastic. Chemicalex Chemicalex Drawing I like to draw! Hobbies RNG Hidden Easter Eggs Video Games I like to play video games! Hobbies lol kitesinpowerlines kitesinpowerlines Avatar Block I didn't change my avatar for 30 days. Website Avatar Embargo I didn't change my avatar for 90 days Website Avatar Taboo I didn't change my avatar for 180 days Website I agree and disagree. I think GOTO loops are nice for beginners to understand how loops work (especially if they have no programming experience). With that being said, once you have the basics down it is time to abandon label loops, otherwise you will not grow as a programmer beyond the "beginner" levels. IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength well...if having a loop that is a few milliseconds slower than a GOTO loop doesn't bother you then use the more advanced loops if you want you game to run AS FAST AS POSSIBLE (like if your making a game about going fast!) use GOTO loops. [EDIT:added ICODE, this message and a dot] ProKuku ProKuku Avatar Taboo I didn't change my avatar for 180 days Website First Year My account is over 1 year old Website Pokemon Is Awesome! I love Pokemon! Express Yourself I don’t think a few milliseconds will affect gameplay very much at all. I find it hard to believe that your only argument to support your enthusiasm for Label loops is something that you didn’t even know until you saw someone say it a few days ago. IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Quote from MASTERR3C0RD: "GOTO loops aren't that much more faster. We're talking milliseconds here, which doesn't matter unless you're making a very very advanced game where those milliseconds are the difference between staying above 30FPS or dropping frames like it's hot. So stop being an annoying pest and shut up about things you know nothing about". the key part is:"GOTO loops aren't that much more faster. We're talking milliseconds here, which doesn't matter unless you're making a very very advanced game where those milliseconds are the difference between staying above 30FPS or dropping frames like it's hot." well, more specifically, the "which doesn't matter unless you're making a very very advanced game where those milliseconds are the difference between staying above 30FPS or dropping frames like it's hot." kitesinpowerlines kitesinpowerlines Avatar Block I didn't change my avatar for 30 days. Website Avatar Embargo I didn't change my avatar for 90 days Website Avatar Taboo I didn't change my avatar for 180 days Website Faster isn't always ideal, especially if it is only milliseconds. But hey, you can continue using your GOTO loops and I'll continue to not play any of your programs because we all know you aren't producing quality games or resources judging by the ratings of your submissions. Perhaps if you took the time to learn about other ways to program you may be able to put something out that worth the attention it receives. MasterR3C0RD MasterR3C0RD Helper Received for being very helpful around SmileBASIC Source Achievements Third Year My account is over 3 years old Website osu! Is Awesome! I love osu! Express Yourself Look, no one has hit a point where GOTO is really important yet AFAIK, and I don't think you need to use it unless you're trying to write CS:GO in SB (which isn't even technically possible). Stop taking my comments out of context, and just accept that GOTO is not a good alternative to WHILE, FOR, REPEAT, or other better loops unless you are 101% sure that your game will not work properly with proper loops. I highly doubt that you NEED to use it especially at the skill level you're at right now. 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Saying "milliseconds" is quite an exaggeration. The difference is only that big after a few thousand/million passes through the loop. random_god random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Video Games I like to play video games! Hobbies thanks chicken, for showing not to use worse loops. i already knew, but this can help others. IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength i have a joke idea:edit the for to be CAPITAL and make it use ICODE! it'd be a joke about FOR loops. kenchic kenchic First Year My account is over 1 year old Website Second Year My account is over 2 years old Website Third Year My account is over 3 years old Website i have a joke idea: how about you stop commenting every two seconds like this is miiverse or something? it'd be a joke about your inability to read any mood. IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength i have a joke idea:how about you stop thinking i don't know the difference between SBS and Miiverse it'd be a joke about how dumb you are and how smart i am TheV360 TheV360 Third Year My account is over 3 years old Website First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself I like how instead of having a point, you now just insult people for no good reason. IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength ported from my resource Title:GOTO Loops (chicken rebuttal) description: GOTO loops are better than FOR loops for these reasons: 1. Faster 2. Clearer 3. they both do the same thing (i think) 4. GOTO loops easier to read for people who aren't good at programming and GOTO loops are also faster than every other loop, but that's the only pro over using GOTO over REPEAT UNTIL or WHILE 1 WEND loops. those loops are better at doing specific things. But...that's about it. i've said all i can say about GOTO loops. chicken's resource is so broken bob the builder can't fix it so what do you think? are GOTO loops or FOR loops better? vote on that poll! tags:chicken rebuttal bad jokes roasts GOTO loops FOR LOOPS ARE BAD! tagline:DaSonicMario VS chicken GOTO loops vs every other kind of loop WHICH SIDE ARE YOU ON? images: IMAGE 1: IMAGE 2: IMAGE 3: KingCo KingCo Avatar Taboo I didn't change my avatar for 180 days Website RNG Hidden Easter Eggs Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Dude, this isn't a competition to see who's opinion is better, it is just a resource suggesting something you shouldn't use. To me it seems like you are spewing out crap just to be "right". Also, how do you know that GOTO loops are faster? Chicken may be right and FOR loops may be better. It also seems like the only reason you like GOTO loops is because you don't feel like learning WHILE, FOR, and WEND to make FOR loops. I may be wrong about all of this, but I suggest you be quiet and stray away from this resource. I swear if this reply gets deleted because I said for you to be quiet I will chuck a pineapple at someone. Not trying to start a fight, but still, you should probably delete this comment, better yet have an admin delete it. EDIT: Ok, so throw all the stuff I said about speed in the trash can because I just noticed MBR's comment. Sorry about that. ProKuku ProKuku Avatar Taboo I didn't change my avatar for 180 days Website First Year My account is over 1 year old Website Pokemon Is Awesome! I love Pokemon! Express Yourself Let’s get a more reasonable poll in here and let EVERYONE see the results this time. MasterR3C0RD MasterR3C0RD Helper Received for being very helpful around SmileBASIC Source Achievements Third Year My account is over 3 years old Website osu! Is Awesome! I love osu! Express Yourself GOTO loops aren't that much more faster. We're talking milliseconds here, which doesn't matter unless you're making a very very advanced game where those milliseconds are the difference between staying above 30FPS or dropping frames like it's hot. So stop being an annoying pest and shut up about things you know nothing about. TheV360 TheV360 Third Year My account is over 3 years old Website First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself GOTO loops may make sense, but WHILE and REPEAT loops are so much better. I don't know what you're talking about with "easier for beginners," WHILE and REPEAT make so much more sense. With GOTO loops, the only hint of what it's doing is in a random IF statement. With WHILE and REPEAT loops, that IF statement is built directly into the command itself. Also, why are you not using FOR loops?! They're so simple! They just take go from one number to another number using the variable you provided. Trying to make a GOTO Seriously, give a reason that GOTO is better than WHILE, FOR, and REPEAT without saying "its faster" or "its easyer for beginners." These commands don't exist to be more complex and for advanced users, they exist to make your code look great and make it more readable. Also, in modern languages, GOTO isn't even a command. There's only WHILE, FOR, and REPEAT. Also maybe CASE. Anyway, if you need code examples for the new commands, just ask someone. Finally, there's a manual built into the editor! Use it. </angryParagraphs> IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength FOR loops are confusing IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength O, MASTER OF R3C0RD1NG i thought it was seconds faster TheV360 TheV360 Third Year My account is over 3 years old Website First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself FOR loops aren't confusing if you make a small amount of effort to understand them. FOR loops take a variable, reset it to value 1, then take it to value 2, adding whatever the STEP is set to each time. (by default, it just adds one until it reaches value 2) FOR (variable)=(value 1) TO (value 2) STEP (step) PRINT "Hi! ";(variable) NEXT FOR I=0 TO 3 STEP 2 PRINT "Hi! ";I NEXT enter that code and see what happens. try changing one thing. try removing the STEP. IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength THIS RESOURCE IS MORE WRONG THAN SOMEONE SAYING SONIC 06 IS THE BEST SONIC GAME EVEN BOB THE BUILDER CAN'T FIX THIS #roast kenchic kenchic First Year My account is over 1 year old Website Second Year My account is over 2 years old Website Third Year My account is over 3 years old Website Did you just delete your comment to get rid of my reply? IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength i didn't see your reply. i just moved the main point of it to a reply on another comment. MasterR3C0RD MasterR3C0RD Helper Received for being very helpful around SmileBASIC Source Achievements Third Year My account is over 3 years old Website osu! Is Awesome! I love osu! Express Yourself There's nothing inherently wrong with using label loops, but it's better to use WHILE, FOR, REPEAT, etc unless you need to make sure your program runs as fast as possible, since label loops don't prepare you for other programming languages in the future, and usually you don't need to squeeze every bit of speed out of your code in SB so kenchic kenchic First Year My account is over 1 year old Website Second Year My account is over 2 years old Website Third Year My account is over 3 years old Website It is more readable to use other types of loops, and eliminates any possibility of you mixing up your loop labels with your data labels. EDIT: Other loops work with auto-indenters, while label loops are left in the dust. IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength no, it's more readable to use GOTO loops instead of FOR loops kenchic kenchic First Year My account is over 1 year old Website Second Year My account is over 2 years old Website Third Year My account is over 3 years old Website You're spewing crap now. Why would you ever use a GOTO loop in place of a FOR loop situation? IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength GOTO loops are more readable than FOR loops TheV360 TheV360 Third Year My account is over 3 years old Website First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself Wait, you're saying this... I=0 @LOOP PRINT "HI! ";I I=I+1 IF I<=9 THEN:GOTO @LOOP ...is more readable than this?!: FOR I=0 TO 9 PRINT "HI! ";I NEXT don't forget to also indent your code IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength yes i don't know how FOR loops work UnderCake UnderCake Halloween 2017 Contest Runner Up I placed 2nd in the SmileBASIC Source Halloween 2017 Contest! Programming Contest Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength First Year My account is over 1 year old Website well, if you dont know how a for loop works then why are you even saying they are worse.. its like saying im the best person in the universe without even looking at anyone else or like saying "Bob the builder gAmE iS tHe BeeSt iN thE UniVeRSe and minecraft is so dumb because it has nothing to do" without ever playing minecraft, its just not good, or like disliking someone for no reason without knowing anything about them. label loops can be good in certain situations but honestly if your need it just use another loop or a DEF. also a for loop is not something you would use as a game loop, unless you totally screwed things up they are used for other things. now while wend loops are my fav, but i also use repeat until ones too. use them. use defs. learn them then once you have, come back here and see all your mistakes, or just sty with label loops and never make a good game and have problems for the rest of your hopefully short coding life. CyberYoshi64 CyberYoshi64 Night Person I like the quiet night and sleep late. Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Well, REPEAT/WHILE/FOR/GOTO loops are all as fast as each other (in my opinion). Although for code & size improvements I would replace any loop with a FOR loop if the content should happen a certain amount. REPEAT could be used for this too. WHILE is perfect for an ∞ loop. But each one is not faster than the other. IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength GOTO is a few milliseconds faster than the other ones CyberYoshi64 CyberYoshi64 Night Person I like the quiet night and sleep late. Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Fortunately, @LOOP REM Do something INC X IF X<9 THEN GOTO @LOOP Either: FOR X=0 TO 9 REM Do something NEXT Or: REPEAT REM Do something INC X UNTIL X==9 Speed = is the same on each type Readability (for new SB users) = GOTO isn't a good idea Size in programs = GOTO takes more space than WHILE/FOR/REPEAT My conclusion = GOTO is not recommended (especially for unskilled programmers/new SB users). TheV360 TheV360 Third Year My account is over 3 years old Website First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself GOTO is only faster by a few milliseconds because it doesn't have to check if something's true or change a variable. When you add in the cost of checking if something is true before continuing a GOTO loop, GOTO may actually be worse... also it looks awful. [citation needed] With WHILE and FOR, everything is clearly labelled as "yep, this is the thing getting checked for every loop," or "hey, this is the variable that goes up every loop." Also, GOTO breaks variable scoping, which is a very useful tool if you know how to use it. 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself FOR is faster than GOTO. random_god random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Video Games I like to play video games! Hobbies i think it doesn't matter which one at all. i still recomend not goto, but it doesn't matter all that much. KingCo KingCo Avatar Taboo I didn't change my avatar for 180 days Website RNG Hidden Easter Eggs Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Too bad, label loops are the only loops I feel like learning, plus it would take me too long to change my games code to use WHILE loops. kenchic kenchic First Year My account is over 1 year old Website Second Year My account is over 2 years old Website Third Year My account is over 3 years old Website Your code would benefit. I learned how to use WHILE in a few minutes after people were saying not to use them. IAmRalsei IAmRalsei Video Games I like to play video games! Hobbies First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength it would NOT benefit. GOTO loops are better than regular loops because they are faster! ProKuku ProKuku Avatar Taboo I didn't change my avatar for 180 days Website First Year My account is over 1 year old Website Pokemon Is Awesome! I love Pokemon! Express Yourself How do you know this DSM? EDIT: I now see MBR’s comment UnderCake UnderCake Halloween 2017 Contest Runner Up I placed 2nd in the SmileBASIC Source Halloween 2017 Contest! Programming Contest Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength First Year My account is over 1 year old Website now heres the problem, imagine yourself trying to catch a penny in mid air, but because you are using a label loop it goes too fast and skips the line that catches it making you never able to get it. speed does not always mean "better", also anyone who has used label loops for long enough knows they cause lots of glitches and problems in your programs that are hard to fix, now when i switched to while/wend loops literally all my glitches went away in my program and it was a GREAT thing too. very worth the time to switch your code over. anyways why am i here..? idk, bye. random_god random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Video Games I like to play video games! Hobbies i ^gr^^. i used to have a heck ton of problems with [email protected] but they mostly went away except me forgetting to define a variable.