Welcome to your AOZ Studio Lesson 2
// After the two // everything will be a note, reminder or explanation, but not a program instruction for AOZ.
I will show you how to enter information into your program and then output it to the screen.
In the editor, click on the paper icon on the far left to create a new project. Give the new project the name Lesson 2 and save it as described in Lesson 1.
Variables————–
A “variable” is a way to temporarily store information. The value it stores can vary, a number, a letter, a sentence… We saw it in Lesson 1 and we’re going to play with it a little bit now in this lesson.
For example:
N = 20
Print N
N = 2000
Print N
ELEPHANT= 1
Print ELEPHANT
ANYWORD$ = "Kitchen"
Print ANYWORD$
ANYWORD$= "elephant"
Print ANYWORD$
ELEPHANT$ = "Fred"
Print ELEPHANT$
End
The variable “N” is used to store the number 20, then 2000.
The variable “EACHWORD$” is used to store the words kitchen, then elephant and then Fred.
Letters and words are called strings in computer language. EACHWORD$ is a “string variable”, it stores pieces of text.
We need to put the words in double quotation marks, “kitchen”, “elephant”.
Note that we add the dollar sign to the end of the variable name so that the computer knows that the variable contains a word and not a number. Variables must be written exactly the same each time;
If we spell EveryWord$, then EVERYWORD$ or everyword$ or eVeRyWoRd$ is not recognized as the same thing.
**Click on the “Build and Run” button in the middle, it looks like a PLAY button or push F1 to run it inside your IDE
**Now, delete the End instruction above, so the following instructions will be executed as well:
Cls
Cls clears the screen. Note: So fast that you don’t even get to see the print commands from above.
Print "Question1 of 4": Input "Is the number 95 a number or a string? Z or S"; ANSWER1$
Note the colon between print and input. It allows us to write multiple commands on one line.
If – Else -End if Command————
Now let me explain the very useful 3-part command “if” and “Else” and “End if” to make simple logical decisions.
If (something is true) -> (performs an action) Else (performs other actions until End if). For example: If Points = 1000 then Print “Player won” else Print “Unfortunately lost”.
Note: Else is not mandatory.
If Upper$( ANSWER1$ ) = "Z"
The Upper$ function converts the Answer1$ variable to uppercase because we cannot know if the user will enter upper or lower case letters. So if the answer is n or N, it will be printed:
Print "Yes 95 is a number, it is an integer or integer" : Inc POINTS
Else
Print "Not correct, 95 is an integer number"
End If
Print
Print "Question 2 of 4": Input "Can the variable >name< be used to store your name? Y or N"; ANSWER2$
If Upper$( ANSWER2$) = "N"
Print "Right. There is no dollar sign $ at the end. That means it is for storing numbers, not strings": Inc POINTS
Else
Print "That's wrong. This variable type is for text".
End if
Print
Print "Question 3 of 4" : Input "Show me the symbols used to make the computer ignore the program commands"; ANSWER3$
If ANSWER3$ = "//" Or ANSWER3$ = "'"
Print "You get it!" : Inc POINTS
Else
Print "Sorry, wrong. The double slash (//) or apostrophe (') is used for comments in the program".
End If
Print
Print "Question 4 of 4": Input "Can the variable >cheese< be used to store text?. Y or N"; ANSWER4$
If Upper$( ANSWER4$) = "N"
Print "Well done! This variable is for storing (integer) numbers" : Inc POINTS
Else
Print "Ouch! Words are stored in string variables with dollar signs at the beginning and end."
End If
Print
Print "Press a key for your result..."
Wait key
Cls
Wait key simply waits for a key to be pressed
Cls you know, the screen is cleared
Print
If POINTS= 4 then Print" CONGRATULATIONS!"
Print " You have " + Str$( POINTS) + " from 4"
**Click on the “Run in Browser” button or F1 to start the program in the browser or on “Run in AOZ Viewer” (F2) to start it in the editor.
Note: There is no Else or End If with this simple If.
You’re ready for the…..important now. Lesson 3 . Congratulations!
Updated 23.07.2023
Tested with AOZ Studio™ version 1.0 Update 44 on 23.07.2023