Difference between revisions of "Global variables"

From Free Pascal wiki
Jump to navigationJump to search
(categorization)
(Fix errors)
Line 1: Line 1:
A global [[Variable|variable]] is one that is defined in the [[main program]] of a program or the main part of a unit. Globals declared in a program cannot be accessed from a unit, but globals in a unit can be accessed from a main program or a unit that accesses that unit.
+
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
 
   var
     i:integer;
+
     g: integer;
 
 
 
   begin
 
   begin
 
   end.
 
   end.
  
'''i''' is a global variable.
+
'''g''' is a global variable.
  
  

Revision as of 13:03, 10 March 2015

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