Jump to content
Angus Robertson

When did Pos become PosEx?

Recommended Posts

To save me looking at lots of old compilers, does anyone know in which version of Delphi that Pos got an extra argument to become equivalent to PosEx in D2007?  Hopefully D2009?

 

Angus

 

Share this post


Link to post
Posted (edited)

Can't tell you when it was added, but it is present in D2007.

Edited by Bill Meyer

Share this post


Link to post

PosEx was available in Delphi 2007, but became obsolete in XE3 when Pos got a third offset argument. 

 

function Pos(const SubStr, Str: UnicodeString; Offset: Integer = 1): Integer;

 

Abgus

 

Share this post


Link to post

Delphi XE3 because I have this code in Spring.pas:

{$IFNDEF DELPHIXE3_UP}
function Pos(const SubStr, Str: UnicodeString; Offset: Integer): Integer;
asm
  jmp PosEx
end;
{$ENDIF}

 

  • Thanks 1

Share this post


Link to post
5 hours ago, Angus Robertson said:

PosEx was available in Delphi 2007

PosEx() was introduced in Delphi 7.

5 hours ago, Angus Robertson said:

but became obsolete in XE3 when Pos got a third offset argument. 

Confirmed.  The Offset parameter is not present in Pos() in XE2, but is present in XE3.

 

Share this post


Link to post
12 hours ago, Angus Robertson said:

PosEx was available in Delphi 2007, but became obsolete in XE3 when Pos got a third offset argument. 

 

function Pos(const SubStr, Str: UnicodeString; Offset: Integer = 1): Integer;

In D2007, I have the Offset argument.

Share this post


Link to post
Posted (edited)
On 6/26/2020 at 6:34 PM, Bill Meyer said:

In D2007, I have the Offset argument.

In D2007, there is no Offset parameter in Pos(), only in PosEx().  Here are the declarations from D2007:

 

System.pas

function Pos(const substr, str: AnsiString): Integer; overload;
function Pos(const substr, str: WideString): Integer; overload;

StrUtils.pas

function PosEx(const SubStr, S: string; Offset: Integer = 1): Integer;

For comparison, here are the declarations from XE2, before the Offset parameter was added to Pos():

 

System.pas

function Pos(const SubStr, Str: ShortString): Integer; overload;
function Pos(const SubStr, Str: UnicodeString): Integer; overload;
function Pos(const SubStr, Str: WideString): Integer; overload;
function Pos(const SubStr, Str: RawByteString): Integer; overload;

System.StrUtils.pas

function PosEx(const SubStr, S: string; Offset: Integer = 1): Integer; overload;

System.AnsiStrings.pas

function PosEx(const SubStr, S: AnsiString; Offset: Integer = 1): Integer; overload;

And here are the declarations from XE3, when the Offset parameter was added to Pos():

 

System.pas

function Pos(const SubStr, Str: _ShortStr; Offset: Integer = 1): Integer; overload;
function Pos(const SubStr, Str: UnicodeString; Offset: Integer = 1): Integer; overload;
function Pos(const SubStr, Str: _WideStr; Offset: Integer = 1): Integer; overload;
function Pos(const SubStr, Str: _RawByteStr; Offset: Integer = 1): Integer; overload;

System.StrUtils.pas

function PosEx(const SubStr, S: string; Offset: Integer = 1): Integer; inline; overload;

System.AnsiStrings.pas

function PosEx(const SubStr, S: AnsiString; Offset: Integer = 1): Integer; inline; overload;

 

Edited by Remy Lebeau
  • Thanks 1

Share this post


Link to post
12 minutes ago, Remy Lebeau said:

In D2007, there is no Offset parameter in Pos(), only in PosEx().  Here are the declarations from D2007:

You are correct, of course. I think I copied that from help, though. Should have checked more closely.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×