Heads up Xojoscript bug

Xojoscripts MID extension method is broken :frowning:

Dim s As String = "if(!0" + &u338 + ")"

Dim s1 As String = s.Mid(7,1)
Dim s2 As String = Mid(s,7,1)

Print s1 // you get a diamond 

Print S2 // you get the ) as expected

<https://xojo.com/issue/59815>
I’ve asked this case be made public (there’s some odd glitch in feedback)

maybe the new string methods are 0 based? called Middle

[quote=484454:@Norman Palardy]Xojoscripts MID extension method is broken :frowning:

Dim s As String = "if(!0" + &u338 + ")"

Dim s1 As String = s.Mid(7,1)
Dim s2 As String = Mid(s,7,1)

Print s1 // you get a diamond 

Print S2 // you get the ) as expected

<https://xojo.com/issue/59815>
I’ve asked this case be made public (there’s some odd glitch in feedback)[/quote]
XojoScript does not support API 2 yet.

Greg - This has nothing to do with API 2
This is classic string operations and this occurs in 2019r1.1 r2.1 and r3.1

[quote=484454:@Norman Palardy]Xojoscripts MID extension method is broken :frowning:
[/quote]
If you change to s.Mid(6,1) you will also get a diamond.

It looks like Xojoscript s.Mid is working like s.MidB, test this code on a Desktop project and you will get the diamond too:

Dim s1 As String = s.MidB(7,1)

I hope is an easy fix.

Testing a little more, changing the original script to:

[code]Dim s As String = “if(!0” + &u338 + “)”

Dim s1 As String = s.Mid(8,1)
Dim s2 As String = MidB(s,8,1)

Print s1 // you get the )

Print S2 // you get the ) as expected using MidB[/code]
Both get )

Weird that s.MidB(8, 1) shows an error: “Too many arguments: got 2, expected only 1”

take the same code & paste it into a method in xojo (like the open even of a window) :slight_smile:

the same code in xooscript and xojo itself do not give consistent results

hence my warning of this weird behaviour