Difference between revisions of "Global variables"

From Lazarus wiki
Jump to navigationJump to search
Line 1: Line 1:
 
{{Global variables}}
 
{{Global variables}}
  
A global [[Variable]] is a variabe that is declared in the main section of a program or the interface part of a unit. Globals declared in a program cannot be accessed from within a unit. Globals declared in a unit can be accessed from within a program or another unit.
+
A global [[Variable|variable]] is a variabe that is declared in the main section of a [[Program|program]] or the [[Interface|interface]] part of a [[Unit|unit]]. Globals declared in a program cannot be accessed from within a unit. Globals declared in a unit can be accessed from within a program or another unit.
  
  program GlobalVariables;
+
<syntaxhighlight>
  var
+
program GlobalVariables;
    g: integer;
+
var
  begin
+
  g: integer;
  end.
+
begin
 +
end.
 +
</syntaxhighlight>
  
 
'''g''' is a global variable.
 
'''g''' is a global variable.
Line 14: Line 16:
 
== External variable ==
 
== External variable ==
  
External variable is a global variable has been declared in [[Unit|unit]] [[Interface|interface]] section.
+
External variable is a global variable has been declared in unit interface section.
  
 
== Read More ==
 
== Read More ==
 
* [[Var]]
 
* [[Var]]
 
* [[Local_variables]]
 
* [[Local_variables]]
 
[[Category:Pascal]]
 

Revision as of 22:56, 13 January 2019

English (en) suomi (fi) русский (ru)

A global variable is a variabe that is declared in the main section of a program or the interface part of a unit. Globals declared in a program cannot be accessed from within a unit. Globals declared in a unit can be accessed from within a program or another unit.

program GlobalVariables;
var
  g: integer;
begin
end.

g is a global variable.


External variable

External variable is a global variable has been declared in unit interface section.

Read More