Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deprecated command StrPas

When i try to compile my code I get the below error. Could anyone suggest what am I doing wrong here?

W1000 Symbol 'StrPas' is deprecated: 'Moved to the AnsiStrings unit'

The code fragment that i'm trying to compile is:

{$IFDEF NEWVER} // Codegear delphi 2009    d12.0
      StrCopy(pSerialNumber, @Buf[pDevDesc.SerialNumberOffset + 1]);
{$ELSE}
      StrPCopy(pSerialNumber,
        FlipAndCodeBytes(StrPas(@Buf[pDevDesc.SerialNumberOffset + 1])));
{$ENDIF}
like image 687
jimsweb Avatar asked Dec 14 '22 18:12

jimsweb


1 Answers

The documentation has the answer. It says:

This function is provided for backwards compatibility only. To convert a null-terminated string to an AnsiString or native Delphi language string, use a typecast or an assignment.

So instead of StrPas(...) you should cast to either AnsiString or UnicodeString depending on whether or not the buffer is 8 bit or 16 bit.

like image 92
David Heffernan Avatar answered Dec 28 '22 07:12

David Heffernan