Description: Mid statement should behave as documented by MS Steps to Reproduce: 1. open MS doc at https://learn.microsoft.com/en-us/office/vba/Language/Reference/user-interface-help/mid-statement 2. Paste the example code that details the expected outputs 3. Run the example in LibreOffice Actual Results: they differ from MS documentation Expected Results: see MS documentation Reproducible: Always User Profile Reset: No Additional Info: Current help does not document MID as a statement. Regressions are not expected to be detected.
MID is both available as a statement and as a function.
I can confirm that this does not work in LO Basic: Mid(MyString, 5, 3) = "fox" In LO the Basic interpreter thinks this is a boolean test and returns False, since it evaluates left and right expressions and then checks for their equality. I'm not sure if it would be possible to have such construction in the current implementation of our interpreter. Alain, do you know of any other LO Basic function that works similarly to this?
Forget about my Comment #2 above. I tested it wrong. Now I ran the following code: Sub TestMid Dim MyString MyString = "The dog jumps" ' Initialize string. Mid(MyString, 5, 3) = "fox" MsgBox MyString Mid(MyString, 5) = "cow" MsgBox MyString Mid(MyString, 5) = "cow jumped over" ' MyString = MsgBox MyString Mid(MyString, 5, 3) = "duck" ' MyString = MsgBox MyString End Sub In MS VBA we get: "The fox jumps" "The cow jumps" "The cow jumpe" "The duc jumpe" In LO Basic we get: "The fox jumps" "The cow" "The cow" "The duc" It seems that when you omit the "Length" argument, LO Basic cuts off the remainder of the string. Also, when the resulting string is larger than the original string, MS VBA cuts off the difference and keeps the string length, whereas LO Basic increases the string length. So yeah, I believe they both should work the same way.
Named/Keyword arguments should be documented according to line 595 in https://opengrok.libreoffice.org/xref/core/basic/source/runtime/stdobj.cxx?r=98f88ac1 until VBA compatibility is implemented. cf. Positional or Keyword Arguments in https://help.libreoffice.org/24.2/en-US/text/sbasic/shared/01020300.html?&DbPAR=SHARED&System=UNIX