Re: StrPas equals assign?

From: Wayne Niddery [TeamB] (wniddery_at_chaffaci.on.ca)
Date: 01/22/04


Date: Thu, 22 Jan 2004 11:59:02 -0500

Florian Teichert wrote:
>
> var aStr: String;
> aPChar: PChar;
>
> 1. aStr := StrPas(aPChar);
> 2. aStr := aPChar;
>
> ... aren't there any possible differences?

Yes, the first simply does the second, so doing the second is slightly more
efficient. The reason the StrPas function (and a few others) exist is
because they were needed in Delphi 1 (16 bit) to convert between asciiz
strings and original Pascal strings. Since Delphi was endowed with long
strings the compiler has been able to generate the correct code and allow
direct assignment between the two. The functions remain for backward
compatibility.

-- 
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"It is error alone which needs the support of government. Truth can
stand by itself." - Thomas Jefferson