iOS Question Error in LastIndex2

shirlun

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

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

ret = "1{234567".LastIndexOf2("{", 7)
 

shirlun

Active Member
Licensed User
Longtime User
Starts at the given index and advances to the beginning, but in my testing it returns -1 which is not correct.
 
Upvote 0

JanPRO

Well-Known Member
Licensed User
Longtime User
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
B4X:
ret = "1{234567".IndexOf("{")

Jan
 
Upvote 0

shirlun

Active Member
Licensed User
Longtime User
Double checked, same bug in V3.0
 

Attachments

  • lastindexof2.jpg
    lastindexof2.jpg
    80.1 KB · Views: 210
Upvote 0

shirlun

Active Member
Licensed User
Longtime User
I must use LastIndexOf to replace LastIndexOf2, this will slow down the app.

B4X:
x = use.SubString2(0, test + 1).LastIndexOf("{")
'x = use.LastIndexOf2("{", test)
 
Upvote 0

shirlun

Active Member
Licensed User
Longtime User
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: 198
Upvote 0
Top