INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to concatenate strings in new Delphi (old way no longer works) E2008 Incompatible types

How to concatenate strings in new Delphi (old way no longer works) E2008 Incompatible types

How to concatenate strings in new Delphi (old way no longer works) E2008 Incompatible types

(OP)
Any explanation of why these lines of code are bad? Is something totally different about strings in the new Delphi as compared to Delphi 7?

{ lbx.Items.Add(Dest + '[' + Dest2 + ']'); }
{ TODO: So plus signs are illegal now? How do you concatenate strings?}
lbx.Items.Add(Concat(Dest,'[',Dest2,']')); // this doesn't work either

Here's how the two variables are defined:
Dest: array[0..254] of char;
Dest2: array[0..254] of char;

RE: How to concatenate strings in new Delphi (old way no longer works) E2008 Incompatible types

Totally different, in some ways yes. Its the ANSI char thing I guess.

Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
That's just perfectly normal Paranoia everyone in the universe has that: Slartibartfast

RE: How to concatenate strings in new Delphi (old way no longer works) E2008 Incompatible types

You can convert each array to a string, then concatenate them

CODE

function CharArrayToString(const Ch: Array of Char): String
begin
   Result := '';
   if Length(Ch) > 0 then
      SetString(Result, PChar(@Ch[0]), Length(Ch));
end;

lbx.items.add(CharArrayToString(Dest)+'['+CharArrayToString(Dest2)+']'); 

RE: How to concatenate strings in new Delphi (old way no longer works) E2008 Incompatible types

cupboy2013, you can make a Cast to String before concatenate:

CODE -->

lbx.Items.Add(string(Dest) + '[' + string(Dest2) + ']'); 

Hope this helps.

http://www.imoveisemexposicao.com.br/imobiliarias-em-guarulhos

RE: How to concatenate strings in new Delphi (old way no longer works) E2008 Incompatible types

Why are you using char arrays instead of the default string type? The listbox.items will accept them, and concatenation should be availble with + operator.

RE: How to concatenate strings in new Delphi (old way no longer works) E2008 Incompatible types

(OP)
This was a Delphi 7 program. Maybe char arrays were the only way it worked back then. Not quite sure. Anyone know?

RE: How to concatenate strings in new Delphi (old way no longer works) E2008 Incompatible types

(OP)
Now I know why. It's because the char arrays are needed to call the Windows API functions this program uses.

RE: How to concatenate strings in new Delphi (old way no longer works) E2008 Incompatible types

(OP)
This is the solution:

lbx.Items.Add(StrPas(Dest) + '[' + StrPas(Dest2) + ']');

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close