-2

The following code compiles and workes using Delphi 5 but not using Delphi 10.1 Berlin;

function CopyTable(const tSource: TwwTable; const Destination: string): DBIResult;
var
   pSourceTableName, pDestination: array[0..DBIMAXTBLNAMELEN] of char;
begin
     tSource.Open;
     StrPCopy(pSourceTableName, tSource.TableName);
     StrPCopy(pDestination, Destination);
     Result := DbiCopyTable(tSource.DBHandle, False, pSourceTableName, nil, pDestination);
     tSource.Close;
end;

Compiler reports [dcc32 Error] SUPPORT1.PAS(3655): E2010 Incompatible types: 'PAnsiChar' and 'array[0..260] of Char' twice.

How do I change it such that it compiles clean and works as intended? NB. I cannot scrap the BDE at this stage of a large migration.

S L Bentall
  • 257
  • 2
  • 11
  • 1
    Have you looked at the declaration of StrPCopy - http://docwiki.embarcadero.com/Libraries/Seattle/en/System.SysUtils.StrPCopy ? – RBA Nov 22 '16 at 14:11
  • 1
    Always include compiler/exception error messages. – H H Nov 22 '16 at 14:42
  • I am rather shocked that BDE would work at all with such a modern version of Delphi. I thought they completely removed it many versions ago. Have you installed it manually? – Jerry Dodge Nov 22 '16 at 14:55
  • The BDE was deprecated and then removed. It is available for download, which I duly have done and installed. Basic TTable (and TwwTable componets compile and work. It is the BDE API parameters with which I am having difficulty. – S L Bentall Nov 22 '16 at 15:01
  • @JerryDodge, BDE for Berlin comes in quite handy when you need to migrate a project away from it. You benefit from the modern IDE instead of being stuck with an ancient Delphi version. – Uwe Raabe Nov 22 '16 at 15:31

1 Answers1

3

DbiCopyTable expects AnsiChar, so you should declare both char arrays accordingly.

Uwe Raabe
  • 45,288
  • 3
  • 82
  • 130
  • Thank you ever-so much. Changing 'of char' to 'of ansichar' appears to have done the trick! 8^) – S L Bentall Nov 22 '16 at 15:24
  • @SLBentall It appears you have never accepted any answer here on Stack Overflow. To show your gratitude, you should seriously consider marking answers as "Accepted" This rewards the person who answered and helps give you credibility. People here don't tend to appreciate answering someone's question who has a history of not accepting them. – Jerry Dodge Nov 22 '16 at 16:59
  • Jerry Dodge - I am sorry if I have caused you offence - although from your comment I do not know how. I am new to using this facility - if I have failed to do something please explain. My comment above I hoped made it perfectly clear that I was thankful for the advice I was given - what else should I have done? – S L Bentall Nov 22 '16 at 23:27
  • Aaah, I've discovered how to "Accept" now. I guess I should have asked this first, but is there an 'overview' somewhere I can read which gives guidelines on the protocol for using this excellent system? – S L Bentall Nov 23 '16 at 08:22
  • 1
    To answer my own query (I appear to have left it too long to edit my previous comment), Aaah, I guess I should have done the 'Tour' before asking my question. Apologies to all the helpful responders for not understanding how to use the system properly. – S L Bentall Nov 23 '16 at 08:32