E2071 This type cannot be initialized (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Error and Warning Messages (Object Pascal) Index

File types (including type Text), and the type Variant cannot be initialized, that is, you cannot declare typed constants or initialized variables of these types.


program Produce;

var
  V: Variant = 0;

begin
end.

The example tries to declare an initialized variable of type Variant, which illegal.


program Solve;

var
  V: Variant;

begin
  V := 0;
end.

The solution is to initialize a normal variable with an assignment statement.