? Label Programs (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Migrating to a new website for SmileBASIC 4

Label Programs

  • #1 ✎ 4 splapoon if i write something like @COM INPUT"CODE";RANDOMVARNAME$ IF RANDOMVARNAME$==PRINT THEN GOTO @PRINT IF RANDOMVARNAME$==SPRITE THEN GOTO @SPRITE GOTO @COM @PRINT PRINT "PRINT" GOTO @COM @SPRITE PRINT"SPRITE" GOTO @COM If i type sprite, ill take me to print insted Posted Edited by splapoon
  • #2 ✎ 434 the_squat1115 First Year My account is over 1 year old Website Forum Contributor Hidden Achievements Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength
    if i write something like @COM INPUT"CODE";RANDOMVARNAME$ IF RANDOMVARNAME$==PRINT THEN GOTO @PRINT IF RANDOMVARNAME$==SPRITE THEN GOTO @SPRITE GOTO @COM @PRINT PRINT "PRINT" GOTO @COM @SPRITE PRINT"SPRITE" GOTO @COM If i type sprite, ill take me to print insted
    Thats because you're using the PRINT command, instead of the SPSET command. This is kinda simple to get to work, first, hit the smile button at the keyboard. Next, go to the SPDEF section and select the sprite number you want to use. For example: SPSET 0'(Management number),0'(Strawberry sprite) The maximum amount of sprites you can get on-screen is 255, so you gotta be careful with that. If you want just to copy the code, just type this: SPSET 0,0
    Posted Edited by the_squat1115
  • #3 ✎ 4 splapoon
    if i write something like @COM INPUT"CODE";RANDOMVARNAME$ IF RANDOMVARNAME$==PRINT THEN GOTO @PRINT IF RANDOMVARNAME$==SPRITE THEN GOTO @SPRITE GOTO @COM @PRINT PRINT "PRINT" GOTO @COM @SPRITE PRINT"SPRITE" GOTO @COM If i type sprite, ill take me to print insted
    Thats because you're using the PRINT command, instead of the SPSET command. This is kinda simple to get to work, first, hit the smile button at the keyboard. Next, go to the SPDEF section and select the sprite number you want to use. For example: SPSET 0'(Management number),0'(Strawberry sprite) The maximum amount of sprites you can get on-screen is 255, so you gotta be careful with that. If you want just to copy the code, just type this: SPSET 0,0
    Now lets say I have two labels. label 1 is called rps for a rock paper scissors game, label 2 is called write to print something. now if i type write to print something, instead taking me to write, it takes me to the rock paper scissors game
    Posted
  • #4 ✎ 41 S_DE_Solutions Avatar Taboo I didn't change my avatar for 180 days Website First Year My account is over 1 year old Website Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself At first: Welcome @splapoon Its seems you are realy new at programming. I'm not sure, but it sounds like you're having trouble while programming. The Code is always executed from first line to the last line. So you should stop/end the code after the Main-loop. Please Note: If you write programs without function, it does matter in which order the programs are written. Posted
  • #5 ✎ 271 TheV360 Pokemon Is Awesome! I love Pokemon! Express Yourself First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself Okay hold on, I think everyone is working on different pages here.
    if i write something like @COM INPUT"CODE";RANDOMVARNAME$ IF RANDOMVARNAME$==PRINT THEN GOTO @PRINT IF RANDOMVARNAME$==SPRITE THEN GOTO @SPRITE GOTO @COM @PRINT PRINT "PRINT" GOTO @COM @SPRITE PRINT"SPRITE" GOTO @COM If i type sprite, ill take me to print insted
    The only issue I'm seeing here is that PRINT and SPRITE should be in quotes as they are strings of text. After fixing that, it seems that this example works as it should. Note that in the examples listed here, I've renamed the RANDOMVARNAME$ into just V$ so it could fit on the screen easier. Maybe check these things:
    1. Check to see that you're comparing against the word SPRITE, not the variable SPRITE. This code IF V==SPRITE THEN GOTO @SPRITE 'won't work won't work because it's checking if variable V (which isn't the same as V$) is equal to the uninitialized variable SPRITE, which is zero by default. The correct code in this case would be IF V$=="SPRITE" THEN GOTO @SPRITE
    2. Check to see if you're using the same variable in the INPUT and IF statements. They should both have the same type suffix (the little $ thing added onto the end, which says "this is a string")
    3. Check to see if the labels are correctly set to point to the right sections of code. I can't count how many times I've copy and pasted a bit of code only to forget to change it and have a mysterious bug crop up.
    Edit: here's the program I used that worked.
    Posted Edited by TheV360
  • #6 ✎ 246 niconii Power User Video Games I like to play video games! Hobbies Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Drawing I like to draw! Hobbies
    Edit: here's the program I used that worked.
    You changed @COM to @A, but line 5 still says GOTO @COM.
    Posted
  • #7 ✎ 202 seggiepants done = FALSE WHILE done == FALSE INPUT"CODE";cmd$ IF cmd$=="PRINT" THEN CMD_PRINT ELSEIF cmd$=="SPRITE" THEN CMD_SPRITE ELSEIF cmd$=="EXIT" THEN done = TRUE ELSE PRINT "Sorry, I didn't understand that." ENDIF WEND DEF CMD_PRINT PRINT "PRINT" END DEF CMD_SPRITE PRINT"SPRITE" END The real Elephant in the room is that you shouldn't be programming with line labels for a variety of reasons. I can make a lengthy post why if you like otherwise I will spare you the rant. It has been gold plated a bit, but isn't the above a lot easier to read, understand, and maintain? While loops, For loops, and functions are your friends and are there to make your life better. The @COM versus @A issue in the last few posts would be a non existant problem if you weren't using GOTO and GOSUB. It takes very little time for GOTO to stab you in the back COMPATABILITY NOTE: For SmileBasic on switch use #TRUE and #FALSE instead of TRUE and FALSE Posted