Difference between revisions of "Var"

From Lazarus wiki
Jump to navigationJump to search
(Fix errors and simplify (invalid doc references still need fixing))
Line 1: Line 1:
 
{{Var}}
 
{{Var}}
  
[[Keyword]] which is used to mark section, where [[Variable|variables]] and their data [[Type|type]]s are declared. When declared parameter of the [[Procedure|procedure]] or [[Function|function]] '''var''' indicated by the use of [[Variable parameter|variable parameter]].
+
Var is a [[keyword]] used to mark the section where [[Variable|variables]] and their data [[Type|type]]s are declared. When used for a parameter of a [[Procedure|procedure]] or [[Function|function]] then '''var''' indicates the use of a [[Variable parameter|variable parameter]].
 
   
 
   
Variables are declared at the beginning of the [[Program|program]], procedure, function or [[Unit|unit]].
+
Variables are typically declared at the beginning of a [[program]], [[procedure]], [[function]] or [[Unit|unit]].
  
 +
<syntaxhighlight>var
 +
  age: integer;</syntaxhighlight>
  
Variables are declared in two parts. First is then name of variable. This is followed by a [[Colon|colon]].
+
If you are planning to use various variables of the same type, they can be grouped so they share the same type definition. The variables must be separated by a [[comma]].
Second is the [[Type|type]] of variable. This is followed by a [[Semicolon|semicolon]].
 
 
<syntaxhighlight> ...
 
var
 
    age : integer ;
 
...</syntaxhighlight>
 
  
If you are planning to use various variables of the same type, you can declare more than on in
+
<syntaxhighlight>var
first part. The variables must be separated with a [[Comma|comma]].
+
  FirstName, LastName, address: string;</syntaxhighlight>  
 
 
<syntaxhighlight> ...
 
var
 
    man, woman : human ;
 
...</syntaxhighlight>  
 
  
 
== See also ==
 
== See also ==
 
* [[Local variables]]
 
* [[Local variables]]
 
* [[Global variables]]
 
* [[Global variables]]
* [[doc:/ref/refse19.html#x49-540004.2|Variable declaration]]
+
* [[doc:ref/refse19.html#x49-540004.2|Variable declaration]]
* [[doc:/ref/refse21.html#x51-560004.4|Thread Variables]]
+
* [[doc:ref/refse21.html#x51-560004.4|Thread Variables]]
* [http://www.cs.joensuu.fi/~saja/var_roles/| The Roles of Variables]
 
 
 
 
[[category:Pascal]]
 
[[category:Pascal]]

Revision as of 14:22, 10 March 2015

Deutsch (de) English (en) español (es) suomi (fi) français (fr) русский (ru) 中文(中国大陆)‎ (zh_CN)

Var is a keyword used to mark the section where variables and their data types are declared. When used for a parameter of a procedure or function then var indicates the use of a variable parameter.

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

var
  age: integer;

If you are planning to use various variables of the same type, they can be grouped so they share the same type definition. The variables must be separated by a comma.

var
  FirstName, LastName, address: string;

See also