$VarStringChecks Compiler Directive
Ordinarily,
the type of an argument for a var
parameter must
match the parameter’s type exactly. This restriction ensures
type safety when the subroutine modifies the var
parameter. If the
$VarStringChecks
directive is disabled, Delphi loosens
the restriction for short strings, letting you pass any short string
argument to a subroutine with any type of var
short string parameter.
If you disable $VarStringChecks
, you must take
care that the subroutine does not exceed the size of the short string
argument. One way to ensure this is to pass only arguments of maximum
possible length (e.g., string[255]
or
ShortString
types). Even better is to use long
strings instead of short strings.