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


Relevant Pages

  • Re: Attn Huw
    ... I doubt you'd find many 1-based arrays in source code of Delphi ... Strings are the only exception AFAIK (but there's a reason ... Delphi strings are zero-based. ... The first position stores the length of the string the ...
    (borland.public.delphi.non-technical)
  • Re: StrPas question
    ... Ian Hinson wrote: ... shouldn't the StrPas function instead look like this? ... Maybe I'm just missing something in my understanding of Strings. ... Delphi long strings and pchars are compatible in the sense that they are ...
    (alt.comp.lang.borland-delphi)
  • TeamB, Borland, admit obvious
    ... Exhibit A: From Delphi 7 help. ... strings as using the Concat function: ... The plus operator is faster than Concat. ...
    (borland.public.delphi.non-technical)
  • Delphi 2009
    ... I upgraded to Delphi 2009 today, and I thought some potential CodeGear customers might like an opinion of someone with a lot of code. ... That failed miserably because MS's .Net package wouldn't install (despite it being a MS OS in an MS virtual machine... ... The only things that needed fixing were where the client and server programs communicated strings over a named pipe - they just had to be touched up to realize strings were in unicode - which is what I wanted anyways. ...
    (alt.comp.lang.borland-delphi)
  • Re: OpenSSH: spaces in user name
    ... >> computer exists to make work easier for people. ... There is no reason why those strings can't be any Unicode ... strings and overloading the space character, ...
    (comp.security.ssh)