Delphi Error – E2198 %s cannot be applied to a long string

Delphi Compiler Error

E2198 %s cannot be applied to a long string

Reason for the Error & Solution

It is not possible to use the standard function HIGH with long strings. The standard function HIGH can, however, be applied to old-style short strings.

Since long strings dynamically size themselves, no analog to the HIGH function can be used.

This error can be caused if you are porting a 16-bit application, in which case the only string type available was a short string. If this is the case, you can turn off the long strings with the $H command line switch or the long-form directive $LONGSTRINGS.

If the HIGH was applied to a string parameter, but you still wish to use long strings, you could change the parameter type to ‘openstring’.

program Produce;
  var
    i : Integer;
    s : String;

begin
  s := 'Hello Developers of the World';
  i := HIGH(s);
end.

In the example above, the programmer attempted to apply the standard function HIGH to a long string variable. This cannot be done.

(*$LONGSTRINGS OFF*)
program Solve;
  var
    i : Integer;
    s : String;

begin
  s := 'Hello Developers of the World';
  i := HIGH(s);
end.

By disabling long string parameters, the application of HIGH to a string variable is now allowed.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...