What are sketchware blocks and variables ?
What are sketchware blocks and variables ? – We’ve covered some terrain, and some people are uncertain about what blocks actually do and what they are. So over the next few days, we’ll look at a few of them, and the things they can do. The first one will be the Orange blocks that are at the top. They are blocks that can be varied.
TYPES OF VARIABLES
Consider variables as place holders , and the variables they represent can be used to temporarily hold a variety of values. There are four kinds of variables:
1. Boolean
2. Number Variable
3. String variable
4. Map variable
We’ll be covering Boolean Variables in the future. Today, we’ll be covering numbers, strings and map variables.
BOOLEAN VARIABLES
A boolean is a type of data type that can only have the possibility of two values. A user’s for instance is able to be logged into or out. Therefore, the value of this variable can be either true or false. In the above image, I’ve made an boolean variable named isRunning.
I can use it to find out if the application has started by setting it to true when the application starts(onStart). Then I can specify what happens while an app starts.
NUMBER VARIABLES
A number variable can only hold numbers and can be used to perform calculations. Number variables are easily identified through their oval shapes. Did you remember in high school, when you had to solve math and you were given an equation like “x + y = Z? Consider variables as placeholders like x in the equation.
In the case of example, if develop an application that adds two numbers, it is necessary to give the app to work the same no matter what inputs the user enters in the input field. Instead of calculating with an unchanging number such as 0, 1, 2 3, 4, 5 6 7 9, we substitute the numbers using variables whose values can alter. It is possible to give this variable its name, x. This way, regardless of the change in x the results are to be true and is in line with any established guidelines.
Thus, in our app instead of saying _2 + 4 = 6, we will convert the text we receive from our edittext into an array of variables. They can be given simple names such as:
A, B C
num1, num2, num3
day1sales, day2sales, day3sales
This makes it much easier to do calculations. This will result in it looking like this using our reasoning:
a + b = c
num1 + num2 = total
day1sales + day2sales = salestotal
When you insert the number variable to Sketchware and you add the variable, 3 additional blocks will be added. These are
Set Number this changes the value of the variable to the number put in the oval that is blank. It could be a different variable, a formula or any other number. PLEASE NOTE THAT THIS BLOCK DOES NOT DISPLAY A NUMBER. TO DISPLAY A NUMBER YOU WILL STILL NEED TO SET TEXTVIEW TO THE VALUE OF THAT VARIABLE.
What are sketchware blocks and variables ?
Make number increase by 1.The title suggests this block will increase the variable number.
Reduce number by 1 this block reduces the number variable by one
STRING VARIABLES
Variables are also a great way to substitute alphanumeric text. Variables are rectangular in their shape. This is useful for situations where users enter lots of temporary data , but each one with different values. For instance, in cameras it is possible to use strings to store image names. Instead of making the list of individual names, you can make use of strings to record information about the time and location every time you take a photo and use them as the image name.
MAP VARIABLES
These keys are used to save information that has many fields of data in each key. If you’re developing an app for chat and you want to gather the following information: *date, time, message and user ID. Instead of recording these details and then saving them in a set of textviews each time the message is sent, you could store them temporarily in an underlying map variable.