E2128 %s clause expected, but %s found (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

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

The compiler was, due to the Object Pascal language syntax, expecting to find a clause1 in your program, but instead found clause2.


  program Produce;

    type
      CharDesc = class
        vch : Char;

  property Ch : Char;
      end;
  end.

The first declaration of a property must specify a read and write clause, and since both are missing on the 'Ch' property, an error will result when compiling. In the case of properties, the original intention might have been to hoist a property defined in a base class to another visibility level - for example, from public to private. In this case, the most probable cause of the error is that the property name was not found in the base class. Make sure that you have spelled the property name correctly and that it is actually contained in one of the parent classes.


  program Produce;

    type
      CharDesc = class
        vch : Char;

  property Ch : Char read vch write vch;
      end;
  end.


The solution is to ensure that all the proper clauses are specified, where required.