Difference between revisions of "Var"

From Lazarus wiki
Jump to navigationJump to search
Line 1: Line 1:
[[Keyword]] which is used to mark section, where [[Variable|variables]] and their data [[Type|type]]s are declared.
+
[[Keyword]] which is used to mark section, where [[Variable|variables]] and their data [[Type|type]]s are declared. In [[Procedure|procedure]] or [[Function|function]] '''var'' indicated by the use of [[Variable parameter|variable parameter]].
 +
 +
Variables are declared at the beginning of the [[Program|program]], procedure ,function or [[Unit|unit]].
 +
 
  
<delphi>
+
Variables are declared in two parts. First is then name of variable. This is followed by a [[Colon|colon]].
  program/unit
+
Second is the [[Type|type]] of variable. This is followed by a [[Semicolon|semicolon]].
  (..)
 
  var:(a,b):real;
 
  (..)
 
  begin
 
  (..)
 
  end.
 
</delphi>
 
 
   
 
   
 +
<delphi>
 +
 +
  var
 +
    age : integer ;
 +
 +
</delphi>
 +
 +
If you are planning to use various variables of the same type, you can declare more than on in
 +
first part. The variables must be separated with a [[Comma|comma]].
 +
 +
<delphi>
 +
 +
  Var
 +
    man, woman : human ;
 +
 +
</delphi>
 +
 +
 +
 +
== read more ==
 +
* [[Local variables]]
 +
* [[Global variables]]
 +
 +
 
[[category:Pascal]]
 
[[category:Pascal]]

Revision as of 14:57, 31 July 2008

Keyword which is used to mark section, where variables and their data types are declared. In procedure or function 'var indicated by the use of variable parameter.

Variables are declared at the beginning of the program, procedure ,function or unit.


Variables are declared in two parts. First is then name of variable. This is followed by a colon. Second is the type of variable. This is followed by a semicolon.

<delphi>

 var
   age : integer ;

</delphi>

If you are planning to use various variables of the same type, you can declare more than on in first part. The variables must be separated with a comma.

<delphi>

 Var
   man, woman : human ;

</delphi>


read more