Global Variable

The variables are used to store values. One of them is global variable when it is declared in the main program area (see image).

It is recommended that avoid using this type of variable, since it can lead to confusion in the code. It is preferable to use local variable!
This type of variable is recognized at any point in your code, that is, within any function, you can use this variable as long as no local variable has the same name!

When you create a global variable, you can configure the following characteristics:

  1. Const: although it has the variable name, when we define a variable to be constant, it can not have its initial value changed;
  2. Type: defines the type of information that will be stored in the variable (simple types: integer, real, string or logical, vector: any simple type);
  3. Name: defines the name of the variable, used to trigger it from any part of the program;
  4. Value: defines the first value to be stored in the variable (initialize the variable).