iOS Question Error in LastIndex2

shirlun

Active Member
Licensed User
Longtime User
With B4I 2.80, The following code return -1.

Code:
ret = "1{234567".LastIndexOf2("{", 6)

ret = "1{234567".LastIndexOf2("{", 7)
 
Starts at the given index and advances to the beginning, but in my testing it returns -1 which is not correct.
 
Upvote 0
Starts at the given index and advances to the beginning
No, thats wrong.
ret = "1{234567".LastIndexOf2("{", 6) ---> Only the part "7" will be searched for the string "{", so the result is -1.

In your case you should simply use
Code:
ret = "1{234567".IndexOf("{")

Jan
 
Upvote 0
Double checked, same bug in V3.0
 

Attachments

  • lastindexof2.jpg
    lastindexof2.jpg
    80.1 KB · Views: 502
Upvote 0
I must use LastIndexOf to replace LastIndexOf2, this will slow down the app.

Code:
x = use.SubString2(0, test + 1).LastIndexOf("{")
'x = use.LastIndexOf2("{", test)
 
Upvote 0
This bug still in v3.0 release, does it related to windows platform or other things ?
 

Attachments

  • cap.PNG
    cap.PNG
    72.3 KB · Views: 574
Upvote 0
Back
Top