? GOTO??? (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
💀

GOTO???

  • #1 ✎ 53 JINC_DEV Video Games I like to play video games! Hobbies Pokemon Is Awesome! I love Pokemon! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Can someone please explain what GOTO does, with small simple words and possibly giving an example??? Posted
  • #2 ✎ 74 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 GOTO sends you to a specified label Example: @LOOP GOTO @LOOP Posted
  • #3 ✎ 479 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
    GOTO sends you to a specified label Example: @LOOP GOTO @LOOP
    ^ it helps when you have sections of code were you switch them around but havedef/end between the main loops for sections and you can say acls while 1'main loop 'awesome code goes here if clear==1 then [email protected] wend def 'variable name 'user defined instructions end @sect2 while 1'main loop for second section 'awesome code goes here with different attributes for second section wend
    Posted
  • #4 ✎ 53 JINC_DEV Video Games I like to play video games! Hobbies Pokemon Is Awesome! I love Pokemon! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength
    GOTO sends you to a specified label Example: @LOOP GOTO @LOOP
    So does it skip to a certain line of code???
    Posted
  • #5 ✎ 74 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
    GOTO sends you to a specified label Example: @LOOP GOTO @LOOP
    So does it skip to a certain line of code???
    If you do GOTO @EXAMPLE 'Your code @EXAMPLE Then it does. Sorry I couldn't give a more detailed explanation, others should be able to give more help.
    Posted Edited by KingCo
  • #6 ✎ 53 JINC_DEV Video Games I like to play video games! Hobbies Pokemon Is Awesome! I love Pokemon! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength
    GOTO sends you to a specified label Example: @LOOP GOTO @LOOP
    So does it skip to a certain line of code???
    If you do GOTO @EXAMPLE 'Your code @EXAMPLE Then it does. Sorry I couldn't give a more detailed explanation, others should be able to give more help.
    That Otay.
    Posted Edited by 12Me21
  • #7 ✎ 396 kenchic OSP Contest 1 Contest Participant I participated in the first SmileBASIC Source OSP Contest! Second Year My account is over 2 years old Website Good Page Hidden Achievements Protip: Don't ever use labels for loops. Use WHILE/WEND or REPEAT/UNTIL, to name a few. Posted
  • #8 ✎ 479 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
    Protip: Don't ever use labels for loops. Use WHILE/WEND or REPEAT/UNTIL, to name a few.
    yep because you can use break on those but im not so sure on @loop. if you want to use @ then its good to use gosub.
    Posted
  • #9 ✎ 152 TheV360 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself Also you have to name e v e r y label, while using WHILE UNTIL lets you have clearer and more to-the-point code. Posted
  • #10 ✎ 479 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
    Also you have to name e v e r y label, while using WHILE UNTIL lets you have clearer and more to-the-point code.
    you mean wend instead of until until is with repeat
    Posted
  • #11 ✎ 152 TheV360 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself
    Also you have to name e v e r y label, while using WHILE UNTIL lets you have clearer and more to-the-point code.
    you mean wend instead of until until is with repeat
    Nah, I just meant both WHILE WEND and REPEAT UNTIL. Should have at least put an "and" there...
    Posted
  • #12 ✎ 479 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
    Also you have to name e v e r y label, while using WHILE UNTIL lets you have clearer and more to-the-point code.
    you mean wend instead of until until is with repeat
    Nah, I just meant both WHILE WEND and REPEAT UNTIL. Should have at least put an "and" there...
    oh. ok
    Posted
  • #13 ✎ 2 CreatorDotMaker GOTO works with these neat little things called ‘labels’ these labels essentially are words (letters and numbers without spaces) that start with the symbol ‘@‘ it should look something like this: @Label ‘Doesn’t have to be the word label, it can be any word you want. Basically let’s say you have some code under that label: @Label PRINT “HELLO WORLD” So you are at the part of your code where everything is confusing and you need to know your way around, and you want your program to read a certain part of your code. Then you use the GOTO command, like this: @Label PRINT “HELLO WORLD” GOTO @Label Basically what is happening above is you specify your label (Which is @Label) then you are printing the words “HELLO WORLD” to the console, and then you are telling the code to reread the line where it says @Label. This is honestly the simplest way I can put it, it’s probably easier if you get better examples rather than mine.. Just think of it this way, when a program runs, there it reads line by line, I’ll call this a “pointer.” And a label is like a checkpoint, it saves the position of a pointer, and when you are using a GOTO command, it moves your pointer all the way up to that checkpoint (represented as the label). Posted
  • #14 ✎ 152 TheV360 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength 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 works with these neat little things called ‘labels’ these labels essentially are words (letters and numbers without spaces) that start with the symbol ‘@‘ it should look something like this: @Label ‘Doesn’t have to be the word label, it can be any word you want. Basically let’s say you have some code under that label: @Label PRINT “HELLO WORLD” So you are at the part of your code where everything is confusing and you need to know your way around, and you want your program to read a certain part of your code. Then you use the GOTO command, like this: @Label PRINT “HELLO WORLD” GOTO @Label Basically what is happening above is you specify your label (Which is @Label) then you are printing the words “HELLO WORLD” to the console, and then you are telling the code to reread the line where it says @Label. This is honestly the simplest way I can put it, it’s probably easier if you get better examples rather than mine.. Just think of it this way, when a program runs, there it reads line by line, I’ll call this a “pointer.” And a label is like a checkpoint, it saves the position of a pointer, and when you are using a GOTO command, it moves your pointer all the way up to that checkpoint (represented as the label).
    You can also use labels to skip over lines of code. GOTO @SKIP BGMPLAY 0 @SKIP Also, if you want an infinite loop, use a WHILE WEND loop. They're so much better. T$="Hello world!" WHILE 1 VSYNC GCLS FOR I%=0 TO LEN(T$)-1 GPUTCHR I%*16,104+FLOOR(32*SIN(2*PI()*((MAINCNT+I%)/90))) NEXT I% WEND
    Posted