<< Chapter < Page Chapter >> Page >

Allowable variable names and lengths

Most programming languages have very specific requirements regarding the allowable characters for variable names. I suspect that this is also true ofScratch, but I haven't found that specification anywhere. You will probably be okay as long as you stick with letters, numbers, the underscore character"_", and the hyphen or minus sign "-".

It appears experimentally that the allowable length of the variable name is longer than you would ever want to use so length doesn't seem to be alimitation.

Many programming languages won't allow you to use a numeric character for the first character in a variable name, but that restriction doesn't seem to applyto Scratch. However, since you might later move up to more mainstream languages, you might want to avoid getting into the habit of using numeric characters asthe first character in variable names.

Meaningful variable names

When using Scratch and all other programming languages, you should strive to use variable names that are meaningful. My preference is to begin variable nameswith a lower-case letter, use multiple words in the name where appropriate, and separate the words using a format commonly called camelCase to cause the human eye to separate the words.

(The upper-case characters are analogous to the humps on a camel.)

Here is an example of the camelCase format:

aVariableName

Some people prefer the following format:

A_Variable_Name

I prefer the camelCase format because it is easier to type, requires fewer characters, takes less space, and in my opinion, is just as effective.

Writing the program

Generally speaking, programs are written in Scratch by:

  1. Selecting buttons in the upper-center of Image 1 to expose the programming blocks in the tool boxes associated with each of the categories listed earlier .
  2. Dragging programming blocks from the toolbox in Image 1 to the rightmost pane in Image 1 and snapping those blocks together in groups to form program scripts.
  3. Entering literal numeric values or dragging other blocks and dropping them into text fields with the same shapeto fill out the details of the program.

There are other steps involved in writing a complex program that I didn't include above, but we will get to them later in this collection of modules.Hopefully you already know the physical steps in writing a program as a result of working through some online tutorials.

Although Scratch 2.0 has some new features and a different screen layout, the general procedure for writing a program in Scratch 2.0 isessentially the same as the procedure for writing a program in Scratch 1.4. Thus, the older v1.4 tutorials are still very relevant.

As you can see in Image 1 , this program consists of three scripts in the rightmost pane. Each script contains onetan block and two orange blocks. We already know that orange blocks have to do with data or variables. As you can see from the colors on the left ends of the buttonsin Image 1 , tan blocks are related to Events .

Programming blocks in the Events category

Image 3 shows some of the programming blocks that are available in the Events category. (Scratch 1.4 had tools for the Events category and the Control category combined into a single toolbox.)

Questions & Answers

how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
what is inflammation
Shelly Reply
part of a tissue or an organ being wounded or bruised.
Wilfred
what term is used to name and classify microorganisms?
Micheal Reply
Binomial nomenclature
adeolu
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Teaching beginners to code. OpenStax CNX. May 27, 2013 Download for free at http://cnx.org/content/col11498/1.20
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Teaching beginners to code' conversation and receive update notifications?

Ask