Invalid Format command

The Delphi unit SysUtils has a commonly used function, called Format, for formatting values into a string.

StatusBar1.SimpleText := Format('There are now %d records in the table', [DataSet.RecordCount]);

The first parameter is a string containing text such as %d which tells the function at what position the variables passed to it should be placed. The second parameter is an array and can contain any number of values or variables. A warning is made if the number of values in the first parameter do not match the number in the second parameter :

Result:=Format('Two text items expected : Text 1=%s,Text 2=%s',[s]);

Also the types of values are also checked to make sure they match:

Result:=Format('Format what should be an integer value %x',[d]);

 




< Back to list of hints and warnings