Difference between revisions of "Variables"

From SCAR Divi Manual
Jump to: navigation, search
(Created page with "Variables are fields which contain non-permanent data, meaning you can change the contents of them at any time. A variable is defined as a name and type. The name can be anything...")
 
 
Line 1: Line 1:
Variables are fields which contain non-permanent data, meaning you can change the contents of them at any time. A variable is defined as a name and type. The name can be anything matching '''[_A-Za-z][_A-Za-z0-9]*''', the type should already be declared when you use it, this can be an [[arrays|array]], a regular [[:Category:Basic Types|basic]] or [[::Category:Structured Types|structured]] type, a (internally defined) [[sets|set]] or finally a [[classes|class]]. The declaration of a variable can either be global or local, in both cases the '''var''' keyword is used to define them.
+
Variables are fields which contain non-permanent data, meaning you can change the contents of them at any time. A variable is defined as a name and type. The name can be anything matching '''[_A-Za-z][_A-Za-z0-9]*''', the type should already be declared when you use it, this can be an [[arrays|array]], a regular [[:Category:Basic Types|basic]] or [[records|structured]] type, a (internally defined) [[sets|set]] or finally a [[classes|class]]. The declaration of a variable can either be global or local, in both cases the '''var''' keyword is used to define them.
  
 
In case of a global variable, it is defined outside of a function.
 
In case of a global variable, it is defined outside of a function.

Latest revision as of 11:39, 27 June 2011

Variables are fields which contain non-permanent data, meaning you can change the contents of them at any time. A variable is defined as a name and type. The name can be anything matching [_A-Za-z][_A-Za-z0-9]*, the type should already be declared when you use it, this can be an array, a regular basic or structured type, a (internally defined) set or finally a class. The declaration of a variable can either be global or local, in both cases the var keyword is used to define them.

In case of a global variable, it is defined outside of a function.

var
  i: Integer;

In case of a local variable, it is defined inside of a function and not available on a global scope, just inside of the function where it was defined.

procedure Proc;
var
  i: Integer;
begin
  // Code
end;