Placeholder argument count mismatch

Properties
PC0034 Warning Usage Code Fix Ignore Obsolete

StrSubstNo, Error, Message, and Confirm substitute placeholders (%1, %2, #1, etc.) in the format string with the arguments that follow it. The runtime does not validate that the counts match — if a label contains %1 and %2 but only one argument is passed, the output contains a literal %2 in user-facing text. Extra arguments are silently discarded.

Pass exactly as many substitution arguments as there are unique placeholders in the format string.

Example

procedure NotifyUser()
var
    WelcomeMsg: Label 'Hello %1, welcome to %2!', Comment = '%1=Name,%2=Company';
begin
    Message(WelcomeMsg); // Placeholder argument count mismatch [PC0034]
end;

Supply the matching arguments:

procedure NotifyUser()
var
    WelcomeMsg: Label 'Hello %1, welcome to %2!', Comment = '%1=Name,%2=Company';
begin
    Message(WelcomeMsg, UserName, CompanyName);
end;

When the diagnostic is reported

This rule extends CodeCop AA0131 to cover two gaps:

  • For StrSubstNo, Error, and Message, the rule fires only when zero substitution arguments are passed — AA0131 already handles mismatches when at least one argument is present.
  • For Confirm, the rule fires on any mismatch, since AA0131 does not cover Confirm. The second parameter of Confirm is the default button (Boolean); substitution arguments start at the third position.
  • The format string must be a Label or a string literal. Text variables are skipped because their value cannot be determined at compile time.
  • Both %N and #N placeholders are recognized. Duplicate placeholders (e.g. %1 ... %1) count as one unique placeholder.

See also