Welcome to your AOZ Studio Lesson 5
Let see how to manipulate text into your program, to start with we are going to learn some new functions.
We will also see two kinds of Loops (DO..Loop and Repeat…Until) and the use of the Mouse buttons.
In the editor, click the paper icon on the far left to create a new project. Give the new project the name Lesson 5 and save it as described in Lesson 1.
Great, so starting with the new instructions of this lesson:
Left$ and Right$ Instructions——————–
Used to find a specified number of letters from the left hand and right hand end of a string.
eg. say that A$=”AOZ Studio”
Print Left$(A$,3) Will print “AOZ”
Instr Instructions———————–
Used to find the position a string within another string
eg. say that A$=”AOZ Studio”
Print Instr(A$,”tud”) Will print the answer 6 because in A$ “tud” starts at the 6th letter
Upper$ Instruction————–
Used to convert a string into capitals (upper case). We have seen that instruction before.
eg. aoz or Aoz into AOZ
Lower$ Instruction————
Same thing the other way round, it is used to convert a string into lower case.
eg. AOZ or Aoz into aoz
Repeat Until Instruction———-
This is a new instruction to do loops
But let see this with a working example
Start the main program loop Repeat..Until
Repeat
cls 1
home
Paper 1 : Pen 0 : locate 1, 1 : Print "First name then press return";
Paper 0 : Pen 1 : Input " ";F$
Paper 1 : Pen 0 : locate 1, 3 : Print "Surname then press return";
Paper 0 : Pen 1 : Input " ";S$
note the ‘;’ that ask the next thing to Print to follow ; here the input question mark
A$=F$+" "+S$
Print
Paper 1 : Pen 0 : print " -> Full Name A$= " + A$
Paper 1 : Pen 0 : Print:Print
Do the string manipulations and print results to screen
Print "Left$(A$,5):" + Left$(A$,5) + " Right$(A$,5):" + Right$(A$,5) + " Mid$(A$,3,5):" + Mid$(A$,3,5) : Print
Print "Instr(A$,''e''): "+ Str$(Instr(A$,"e")) : print
Print "Upper$(A$):" + Upper$(A$) + " Lower$(A$):"+Lower$(A$) : print
Print A$ - " " + " Minus Spaces"
Print A$ - S$ + " Minus Surname"
Print A$ - "a" - "e" - "i" - "o" - "u" + " Minus all the vowels"
Paper 1 : Pen 0 : locate 1, 20 : Centre "LEFT MOUSE CLICK TO GO AGAIN" + " - RIGHT MOUSE CLICK TO QUIT"
Check for end of program or repeat
Do // Start the second program loop the Do..Loop
M=Mouse Key //get the information of a mouse clic and store it in the M variable
the possible values are:
0 = no mouse click
1= left mouse button click
2= right mouse button click
Exit If M>0 // Exit the Do..Loop only if a mouse clic happened (M=1 or 2)
Loop
we have exit here the Do Loop because M = 1 or 2 (not 0)
Until M=2 // we exit the Repeat..Until only on the right mouse clic(M=2), if not we continue that main program loop
**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: Exit within a Loop is not a super clean way of programming, you can think at different ways of doing the same
We made great progresses, your next Lesson 6 will be an introduction of creating games 🙂 Have fun with it!
Updated 23.07.2023
Tested with AOZ Studio™ version 1.0 Update 44 on 23.07.2023