Control structures are widely used in logic and aid in the development of any development activity. By default, there are three basic control structures, namely:

  • Simple Sequence
  • Selection
  • Repetition

The actions are made based on these three structures.

 

Control Structures

 

The following is a simple task that is always executed. She will obey the order from left to right, top to bottom. An example of simple sequence is used as follows:

Goes into the kitchen; Opens the refrigerator; Fixes the meal; Has Lunch.

The selection structure is used when there is a need to choose between two options. For example, when asked if you’re hungry, you respond yes or no. This decision will result in the execution of some tasks or not.

The selection structure uses the form “If …… then,” or “If …… then …….. but”. To better understand this, see example:

If you are hungry then you eat.

This is a simple way to illustrate a selection. If you are hungry, you eat. Otherwise, you do not eat.

 

The truth table in this case would be as follows:

If (Expression 1) So (Expression 2) Result

T T You eat (T)

T F You do not eat (F)

T F You eat (T)

F F You do not eat (T)

 

Finally, the repetition structures serve to repeatedly perform a routine. This repetition can be finite or infinite (infinite looping). One should be very careful to repeat commands, for running an infinite looping can lock the computer.

This command is known as “While (condition) Do”. This repetition tests the condition before executing the loop. Take the example:

While Money> 10 do: Buy bread; Buy milk; Buy eggs.

In this example, we have a variable (Cash), which is tested before because there is not enough money, you cannot make the purchase. Then, as the condition is true, the purchase will be made.

You might also like…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.