Some examples:
var I : Integer; S : String;
var I1, I2, I3 : Integer;
Object Pascal requires you to declare all variables before they are used and everytime you declare a variable you must specify a data type.
Example:
procedure TForm1.Button1Click(Sender: TObject);
var I : Integer;
A, B : Char;
Finished : Boolean;
begin
I := 0;
//Some code here
Finished := True;
end;
You will find that you cannot mix two different data types.
Using the example above, I := True; will not work.
These variables both have different data
types, doing this will result
in a compiler error: Incompatable types:
'Integer' and 'Boolean'.
You can change Variables during program
execution like this:
procedure TForm1.Button1Click(Sender: TObject);
var I : Integer; S : String;
begin
I := 0;
S := 'Chuck Norris
- Karate.';
I := 10;
S := 'Walker Texas
Ranger.';
end;
The above code doesn't really makes sense,
but you can see that the variables
I and S are changed as the code is executed.