#1✎ 24CrazyblobBeginner ProgrammerI'm just starting out! I'm still trying to grasp the basics.Programming StrengthVideo GamesI like to play video games!HobbiesMinecraft Is Awesome!I love Minecraft!Express YourselfIf 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✎ 593IAmRalseiForum LeaderHiddenAchievementsFirst YearMy account is over 1 year oldWebsiteExpert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming StrengthINPUT QWERTY$
IF QWERTY$!="" THEN @LOOP ELSE 'Put code here
@LOOP
'Put code here
GOTO @LOOP
Posted
Edited
by IAmRalsei
#3✎ 24CrazyblobBeginner ProgrammerI'm just starting out! I'm still trying to grasp the basics.Programming StrengthVideo GamesI like to play video games!HobbiesMinecraft Is Awesome!I love Minecraft!Express YourselfThank you!
Posted
#4✎ 24CrazyblobBeginner ProgrammerI'm just starting out! I'm still trying to grasp the basics.Programming StrengthVideo GamesI like to play video games!HobbiesMinecraft Is Awesome!I love Minecraft!Express YourselfI have another question too actually
Posted
#5✎ 24CrazyblobBeginner ProgrammerI'm just starting out! I'm still trying to grasp the basics.Programming StrengthVideo GamesI like to play video games!HobbiesMinecraft Is Awesome!I love Minecraft!Express YourselfIt 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✎ 593IAmRalseiForum LeaderHiddenAchievementsFirst YearMy account is over 1 year oldWebsiteExpert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!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✎ 166012Me21Head AdminThird YearMy account is over 3 years oldWebsiteSyntax HighlighterReceived for creating the code syntax highlighter on SBSNight PersonI like the quiet night and sleep late.Express Yourselfuse == to test if they're the same.
Posted
#8✎ 24CrazyblobBeginner ProgrammerI'm just starting out! I'm still trying to grasp the basics.Programming StrengthVideo GamesI like to play video games!HobbiesMinecraft Is Awesome!I love Minecraft!Express YourselfI 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✎ 593IAmRalseiForum LeaderHiddenAchievementsFirst YearMy account is over 1 year oldWebsiteExpert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!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 IAmRalsei
#10✎ 202TheV360Pokemon Is Awesome!I love Pokemon!Express YourselfFirst DayJoined on the very first day of SmileBASIC SourceWebsiteNight PersonI like the quiet night and sleep late.Express YourselfNicer 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✎ 24CrazyblobBeginner ProgrammerI'm just starting out! I'm still trying to grasp the basics.Programming StrengthVideo GamesI like to play video games!HobbiesMinecraft Is Awesome!I love Minecraft!Express YourselfWhat'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✎ 103niconiiVideo GamesI like to play video games!HobbiesExpert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming StrengthDrawingI 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✎ 24CrazyblobBeginner ProgrammerI'm just starting out! I'm still trying to grasp the basics.Programming StrengthVideo GamesI like to play video games!HobbiesMinecraft Is Awesome!I love Minecraft!Express YourselfThank you!
Posted
#14✎ 24CrazyblobBeginner ProgrammerI'm just starting out! I'm still trying to grasp the basics.Programming StrengthVideo GamesI like to play video games!HobbiesMinecraft Is Awesome!I love Minecraft!Express YourselfWhat 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✎ 24CrazyblobBeginner ProgrammerI'm just starting out! I'm still trying to grasp the basics.Programming StrengthVideo GamesI like to play video games!HobbiesMinecraft Is Awesome!I love Minecraft!Express YourselfThank you!!
Posted
#16✎ 24CrazyblobBeginner ProgrammerI'm just starting out! I'm still trying to grasp the basics.Programming StrengthVideo GamesI like to play video games!HobbiesMinecraft Is Awesome!I love Minecraft!Express YourselfI 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
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
#18✎ 24CrazyblobBeginner ProgrammerI'm just starting out! I'm still trying to grasp the basics.Programming StrengthVideo GamesI like to play video games!HobbiesMinecraft Is Awesome!I love Minecraft!Express YourselfYup, 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
#19✎ 202TheV360Pokemon Is Awesome!I love Pokemon!Express YourselfFirst DayJoined on the very first day of SmileBASIC SourceWebsiteNight PersonI like the quiet night and sleep late.Express YourselfSorry, I'm super picky about code styling.
Here's a slightly more efficient version of Shelly's code:
INPUT "Enter Password";PASSWORD$
VARIABLE=0
IF PASSWORD$=="STRING" THEN
IF VARIABLE THEN
GOTO @LOOPONE
ELSE
GOTO @LOOPTWO
ENDIF
ENDIFPro tip: in SmileBASIC, there's no such thing as a boolean variable type, so
TRUE = 1
FALSE = 0
and IF VARIABLE THEN is the same as IF VARIABLE>0 THEN
#20✎ 24CrazyblobBeginner ProgrammerI'm just starting out! I'm still trying to grasp the basics.Programming StrengthVideo GamesI like to play video games!HobbiesMinecraft Is Awesome!I love Minecraft!Express YourselfOhhhh, thank you!
Posted