? Input help? (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Contest results!

Input help?

1 2
  • #1 ✎ 24 Crazyblob Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Minecraft Is Awesome! I love Minecraft! Express Yourself If I put a input in let's say [INPUT QWERTY$] , how do I make it where if you type a string or words in.. it'll go to a @loop, or do a command with THEN. Sorry, a bit newbie to this. Posted Edited by Crazyblob
  • #2 ✎ 347 ToadIsTheBest Avatar Embargo I didn't change my avatar for 90 days Website Video Games I like to play video games! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength INPUT QWERTY$ IF QWERTY$!="" THEN @LOOP ELSE 'Put code here @LOOP 'Put code here GOTO @LOOP Posted Edited by ToadIsTheBest
  • #3 ✎ 24 Crazyblob Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Minecraft Is Awesome! I love Minecraft! Express Yourself Thank you! Posted
  • #4 ✎ 24 Crazyblob Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Minecraft Is Awesome! I love Minecraft! Express Yourself I have another question too actually Posted
  • #5 ✎ 24 Crazyblob Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Minecraft Is Awesome! I love Minecraft! Express Yourself It didn't work. I did Everything you said with if password$!="PASSWORD" THEN @loop else end no matter what it goes to the loop Posted Edited by Crazyblob
  • #6 ✎ 347 ToadIsTheBest Avatar Embargo I didn't change my avatar for 90 days Website Video Games I like to play video games! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength
    It didn't work. I did Everything you said with if password$!="PASSWORD" THEN @loop else end no matter what it goes to the loop
    can i see your code?
    Posted
  • #7 ✎ 1505 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS OSP Contest 2 Winner I won the second SmileBASIC Source OSP Contest! Programming Contest Second Year My account is over 2 years old Website use == to test if they're the same. Posted
  • #8 ✎ 24 Crazyblob Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Minecraft Is Awesome! I love Minecraft! Express Yourself I fixed the issue, thank you. It's weird tho because when I do the word or string inside the "" it goes to the ELSE instead of the THEN. Another question.. what if instead of only having a one string inside the "" meaning both "PASSWORD" And another string or word which will have its own loop. So PASSWORD will go to @loop and for example TYPEME will go to @loop2 and anything else will run END. Posted
  • #9 ✎ 347 ToadIsTheBest Avatar Embargo I didn't change my avatar for 90 days Website Video Games I like to play video games! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength
    I fixed the issue, thank you. It's weird tho because when I do the word or string inside the "" it goes to the ELSE instead of the THEN. Another question.. what if instead of only having a one string inside the "" meaning both "PASSWORD" And another string or word which will have its own loop. So PASSWORD will go to @loop and for example TYPEME will go to @loop2 and anything else will run END.
    if password$=="PASSWORD" THEN @loop elseif password$=="TYPEME" then @loop2 elseif password$!="PASSWORD" and password$!="TYPEME" then end
    Posted Edited by ToadIsTheBest
  • #10 ✎ 137 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 Nicer code: IF PASSWORD$=="PASSWORD" THEN GOTO @LOOP1 ELSEIF PASSWORD$=="TYPEME" THEN GOTO @LOOP2 ELSE END ENDIFMulti-line IF statements make your code look so much better. Posted
  • #11 ✎ 24 Crazyblob Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Minecraft Is Awesome! I love Minecraft! Express Yourself What's the endif for? I also noticed instead of one = There's two of them.. why is that? Thank you guys.. this is gonna sound dumb but what if I wanted to add even more of those input things like "PASSWORD" "TYPEME"? Once again thank you Posted
  • #12 ✎ 89 niconii 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
    What's the endif for?
    ENDIF is used when you want an IF that goes over multiple lines. These do the same thing: IF A THEN B IF A THEN B ENDIF The single line version doesn't need ENDIF because it knows it ends at the end of that line.
    I also noticed instead of one = There's two of them.. why is that?
    = and == have different meanings in many programming languages, including SmileBASIC. It's something that does tend to confuse new programmers. 'This means "set the variable A to B" A=B 'This means "are A and B equal?" A==B
    Thank you guys.. this is gonna sound dumb but what if I wanted to add even more of those input things like "PASSWORD" "TYPEME"?
    If you want different passwords to do different things: IF PASSWORD$=="PASSWORD" THEN 'Do something ELSEIF PASSWORD$=="TYPEME" THEN 'Do something else ELSE 'Incorrect password ENDIF If you want different passwords to do the same thing: IF PASSWORD$=="PASSWORD" || PASSWORD$=="TYPEME" THEN 'Do something ELSE 'Incorrect password ENDIF || means "or", so this is saying "if the password is PASSWORD or the password is TYPEME, then do this". There's also && for "and", if you want to check that multiple things are true.
    Posted Edited by niconii
  • #13 ✎ 24 Crazyblob Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Minecraft Is Awesome! I love Minecraft! Express Yourself Thank you! Posted
  • #14 ✎ 24 Crazyblob Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Minecraft Is Awesome! I love Minecraft! Express Yourself What if I wanted it if I did the "password" and it'll take me to @loop but.. if a variable equals 1 instead of taking me to @loop I'll go to @loop2 ? I know.. I'm a newb, thank you Posted
  • #15 ✎ 221 Shelly
    What if I wanted it if I did the "password" and it'll take me to @loop but.. if a variable equals 1 instead of taking me to @loop I'll go to @loop2 ? I know.. I'm a newb, thank you
    INPUT "PASSWORD";INPUT$ IF INPUT$=="STRING" AND VARIABLE==1 THEN @LOOPONE IF INPUT$=="STRING" AND VARIABLE!==1 THEN @LOOPTWO
    Posted
  • #16 ✎ 24 Crazyblob Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Minecraft Is Awesome! I love Minecraft! Express Yourself Thank you!! Posted
  • #17 ✎ 221 Shelly
    Thank you!!
    Did it work?
    Posted
  • #18 ✎ 24 Crazyblob Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Minecraft Is Awesome! I love Minecraft! Express Yourself I wanted it to be in the same IF actually... Also whats the "password" string for at the input? And the ;? I also noticed at the second part of the variable thing, you put the ! . Why is that? Thank you. I'm sorry, just a bit new to coding but I do appreciate the help you've given me Posted
  • #19 ✎ 867 Lumage Head Admin
    I wanted it to be in the same IF actually... Also whats the "password" string for at the input? And the ;? I also noticed at the second part of the variable thing, you put the ! . Why is that?
    The built-in manual might be bad, but it does exist. http://smilebasic.com/en/reference/ >INPUT ["Guiding text string";] Variable The square brackets indicate an optional parameter. In this case, text to use to prompt the user. The semicolon separates the arguments, here... ! is the logical NOT operator. !TRUE is FALSE and !FALSE is TRUE Shelly meant to write !=, the "not equal to" or inequality comparison. Also, be careful with AND. AND is a bitwise intersection test, which is functionally equivalent to a logical and, &&, only in the case of booleans (that is, TRUE/FALSE/1/0). It doesn't matter too much yet, but just remember to use && when checking that two conditions are met. INPUT PASSWORD$ IF VARIABLE == 1 THEN GOTO @LOOP2 ELSEIF PASSWORD$ == "PASSWORD" THEN GOTO @LOOP ELSE GOTO @SOMETHINGELSE ENDIF
    Posted
  • #20 ✎ 24 Crazyblob Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Minecraft Is Awesome! I love Minecraft! Express Yourself Yup, thank you guys. I'm working on a text adventure type of game, so that's why I've been asking for this info.. and cuz I'm new to programming. Posted
1 2