Hello! I'm CKlidify, and in this tutorial I will teach you how to use the GOTO and IF commands!
The GOTO command can be used for many different things, and can have a lot more use to it when using it with the IF command! So, let's begin. Look at it like this, you can create a waypoint in your code and you can go to your waypoint by using the GOTO command... So let's create a SUPER SIMPLE loop out of the GOTO command. First, you want to define a "waypoint" at the beginning of your code:
Then we want it to print "Hi"
@START PRINT "Hi"
Now, we want it to loop, so we add the final bit of code to make this:
@START PRINT "Hi" GOTO @START
If you were to run this program as of now, it woud print "Hi" every frame. To stop it, press the stop button on the bottom screen! Now, we're going to go even further with the GOTO command, with the IF command!
IF you've ever wanted an if command THEN you have it! That's the format for the IF command!
IF _____ THEN _____
It's that simple. The best way to deminstrate is to create an input:
then add an if statement saying "IF the player inputs blah THEN print 'kthen'"
INPUT "Uhhhh";VAR$ IF VAR$=="BLAH" THEN PRINT "kthen"
It's that simple... Now, let me explain! The double equals sign means "EQUAL TO" So, if VAR$ is equal to "BLAH"... We got that much figured out. Now, if you were to use one equals sign, then it wouldn't work, because on equals sign means "EQUALS", which SETS a value! So, if VAR$ is equal to "BLAH" then print "kthen"! See, simple! Now let's run the program! First, let's say something other than "BLAH"
READY RUN Uhhhh? Blurp OK
Now, let's try typing "BLAH"
READY RUN Uhhhh? BLAH kthen OK
See? it works! Now, let's put GOTO and IF together!
GOTO and IFEdit
Let's create a program in which if you say pi, it gives you pie! We'll start off by adding a "waypoint"
Then we will use "CLS" to clear everything on the screen
Now we will add an input:
then an if statement:
IF VAR$=="3141" THEN GOTO @WIN
then add a loop
Now, what will this all do? Well, it will clear the screen, print "Pi?" then if you type "3141" it wil go to the waypoint "@WIN", but if not "3141" it will goto "@START". Now, let's create "@WIN"
"CLS" to clear everything on the screen
Then print them a pie
PRINT "HAVE A PIE" PRINT "[INSERT PIE]"
You're final overall code should be:
@START CLS INPUT "Pi";VAR$ IF VAR$=="3141" THEN GOTO @WIN GOTO @START @WIN CLS PRINT "HAVE A PIE" PRINT "[INSERT PIE]"
Now, if you were to run the program you would see this if we answer something that's not 3141:
Then it would reset back to "Pi?", but if we type "3141" we would see this:
Then clear screen and become
HAVE A PIE [INSERT PIE] OK
And there you go! Watch the video tutorial to see a better version of this program!