A variable is a place keeper used to store
Data types used with variables:
||values that are text (i.e. numbers and
||whole numbers (i.e. no fractions)
||whole and fractions (i.e. numbers with
digits after the decimal point)
||any single character (i.e. text, symbol
||true or false values
- Variables are declared after the abbreviation “var”
- Variables can be declared globally: They are declared
under the var above implementation at the top of the programming code.
These variables are valid throughout the program.
- Variables can also be declared locally: These variables
are declared inside the event handler (the procedure you create yourself by
double clicking on a button in design mode for example). You must type in the
var as well as the variables themselves. These variables are only valid within
this specific event handler or procedure.
- For example:
iCount : Integer;
- Similar variables can be listed after each other
separated by a comma:
sName, sSurname : String;
iAge, iNum1, iNum2 : Integer;
rAmount : Real;
Rules for variable (and component) names in Delphi:
- Name can be any length but Delphi uses only first 255
- First character must be letter or underscore not a
- You cannot use any special characters such as a
question mark (?), but you can use an underscore (_).
- No spaces area allowed in the name of a variable.
- Reserved words (such as begin, end, if, program) cannot
be used as variables.
- Delphi is case insensitive – it does not matter whether
capital letters are used or not. Just make sure the way variables or
components are used is consistent throughout the program.
Also see variables
Delphi resources index
Return to Home Page
© JAK Olivier (2008)