Watch, Follow, &
Connect with Us
Public Report
Report From:    [ Add a report in this area ]  
Report #:  8372   Status: Reported
Format on short strings erroneous
Project:   Build #:  7.1.1523.17956
Version:    8.0 Submitted By:   Guido Weber
Report Type:  Basic functionality failure Date Reported:  6/8/2004 11:35:49 PM
Severity:    Commonly encountered problem Last Updated:
Platform:    All versions Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: 1
Description
The output of SysUtils.Format on short strings differs, depending on whether the short string is declared as a named type or not. If no type is declared, Format writes 'System.Byte[]' as value for the string.
Steps to Reproduce:
Put a memo and a button on a Form, then insert the following code:

type
  string4t = string[4];

procedure TForm1.Button3Click(Sender: TObject);
var
  s1 : string4t;
  s2 : string[4];

  procedure doit(cnt : integer);
  var
    sl : TStrings;
    si : string;
  begin
    sl := Memo1.Lines;
    si := IntToStr(cnt);
    sl.Add(Format(si + 'a: "%s" - "%s"', [s1, s2]));
    sl.Add(Format(si + 'b: "%s" - "%s"', [string(s1), string(s2)]));
    sl.Add(si + 'c: "' + s1 + '" - "' + s2 + '"');
    sl.Add(System.String.Format(si + 'd: "{0}" - "{1}"', s1, s2));
  end;

begin
  s1 := '';
  s2 := '';
  doit(1);
  s1 := 'a';
  s2 := 'b';
  doit(2);
  s1 := System.String.Concat('asd', 'fgh');
  s2 := System.String.Concat('qwer', 'tz');
  doit(3);
end;
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01