Position, shouldn't it return -1 if nothing is found?

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 998
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Position, shouldn't it return -1 if nothing is found?

Post by Grovkillen » Wed Apr 08, 2020 10:26 am

Code: Select all

Let>STRING=123
Position>1,STRING,0,POS,FALSE
//POS=0
Position>2,STRING,0,POS,FALSE
//POS=1
Position>3,STRING,0,POS,FALSE
//POS=2
Position>4,STRING,0,POS,FALSE
//POS=0
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1347
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Position, shouldn't it return -1 if nothing is found?

Post by Dorian (MJT support) » Wed Apr 08, 2020 10:43 am

Position

Hi Grovkillen,

"Returns the starting position of a substring in a string. The search commences at the position specified in start. If found the starting position of the substring is returned in the result variable. If no match is found this value will be zero."
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Grovkillen
Automation Wizard
Posts: 998
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Position, shouldn't it return -1 if nothing is found?

Post by Grovkillen » Wed Apr 08, 2020 12:11 pm

Dorian (MJT support) wrote:
Wed Apr 08, 2020 10:43 am
Position

Hi Grovkillen,

"Returns the starting position of a substring in a string. The search commences at the position specified in start. If found the starting position of the substring is returned in the result variable. If no match is found this value will be zero."
Yes that is understood but if you look at my example you'll see that the string containing "1" (or "12" or "123" for that matter) will also return zero.

If it's by design then the start position of zero shouldn't be allowed.
Let>ME=%Script%

Running: 15.0.24
version history

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts