#1✎ 23CrazyblobBeginner 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✎ 306ToadIsTheBestAvatar EmbargoI didn't change my avatar for 90 daysWebsiteVideo GamesI like to play video games!HobbiesIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthINPUT QWERTY$
IF QWERTY$!="" THEN @LOOP ELSE 'Put code here
@LOOP
'Put code here
GOTO @LOOP
Posted
Edited
by ToadIsTheBest
#3✎ 23CrazyblobBeginner 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✎ 23CrazyblobBeginner 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✎ 23CrazyblobBeginner 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✎ 306ToadIsTheBestAvatar EmbargoI didn't change my avatar for 90 daysWebsiteVideo GamesI like to play video games!HobbiesIntermediate ProgrammerI 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✎ 144312Me21AdminSyntax HighlighterReceived for creating the code syntax highlighter on SBSNight PersonI like the quiet night and sleep late.Express YourselfSecond YearMy account is over 2 years oldWebsiteuse == to test if they're the same.
Posted
#8✎ 23CrazyblobBeginner 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✎ 306ToadIsTheBestAvatar EmbargoI didn't change my avatar for 90 daysWebsiteVideo GamesI like to play video games!HobbiesIntermediate ProgrammerI 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✎ 136TheV360Intermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthFirst 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✎ 23CrazyblobBeginner 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✎ 80niconiiVideo 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✎ 23CrazyblobBeginner 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✎ 23CrazyblobBeginner 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
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✎ 23CrazyblobBeginner 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
#18✎ 23CrazyblobBeginner 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
#20✎ 23CrazyblobBeginner 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