Execute the following basic code and run function "my_function". function my_function () as string dim my_string as string let my_string = "abc def jhi" mid( my_string, 5 ) = "123" let my_function = my_string end function What value was returned by this function? Actual behavior: * "microsoft office 2016 excel": return value is "abc 123 def"; * "libreoffice 6.2.5.2 calc": return value is "abc 123". Expected behavior: return values must be identical.
Related docs: https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/mid-statement
Reproduced, except for the result being ""abc 123 jhi"
IMHO this is not a bug, to make mid() vba compatible, use Option VBASupport 1 Sub Main msgbox my_function() End Sub function my_function () as string dim my_string as string let my_string = "abc def jhi" mid( my_string, 5 ) = "123" let my_function = my_string end function
(In reply to Oliver Brinzing from comment #3) > IMHO this is not a bug, to make mid() vba compatible, use > > Option VBASupport 1 > > Sub Main > msgbox my_function() > End Sub >... On pc Debian x86-64 with master sources updated today, I got abc 123 with VBASupport equal to 1 or 0, whatever
With this patch: diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index fe266fdc009c..777b21040230 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -1159,7 +1159,7 @@ void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite) OUStringBuffer aResultStr = aArgStr; sal_Int32 nErase = nReplaceLen; - aResultStr.remove( nStartPos, nErase ); + aResultStr.remove( nStartPos, nErase - nStartPos); aResultStr.insert( nStartPos, aReplaceStr.getStr(), std::min(nReplaceLen, nReplaceStrLen)); it works. But this unit test fails: s = "The lightbrown fox" Mid(s, 5, 10, "lazy") it expects: "The lazy fox" but with the patch I get: "The lazyrown fox" Perhaps, I could use "nErase - nStartPos" only when using VBASupport 1 but: 1) Still I don't know if the patch is right 2) Changing behaviour of mid function may bring some regressions for some other users => There's no more Basic expert in https://wiki.documentfoundation.org/FindTheExpert, so I'm a bit stuck.
I put in cc the bugtracker related to the QA test which fails with the test patch quoted in my previous comment.
(In reply to Julien Nabet from comment #4) > On pc Debian x86-64 with master sources updated today, I got abc 123 sorry, only checked with LO 6.0.7.3 (VBASupport 1 worked but 0 crashes LO) and AOO 4.1.5, behaviour changed with LO 6.1. maybe a side effect from fixes: Bug 111313 - Crashed in Calc Macro (Basic) Bug 121325 - 4-argument form of Mid() BASIC function broken in 6.x (worked in 5.x and OO)
Dear deustrno, To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the information from Help - About LibreOffice. If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice. Please DO NOT Update the version field Reply via email (please reply directly on the bug tracker) Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/ 2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to 'inherited from OOo'; 4b. If the bug was not present in 3.3 - add 'regression' to keyword Feel free to come ask questions or to say hello in our QA chat: https://kiwiirc.com/nextclient/irc.freenode.net/#libreoffice-qa Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team MassPing-UntouchedBug
Testing the initial case on Excel: function my_function () as string dim my_string as string let my_string = "abc def jhi" mid( my_string, 5 ) = "123" let my_function = my_string end function Excel returns "abc 123 jhi" not "abc 123 def"
Dear deustrno, To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the information from Help - About LibreOffice. If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice. Please DO NOT Update the version field Reply via email (please reply directly on the bug tracker) Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/ 2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to 'inherited from OOo'; 4b. If the bug was not present in 3.3 - add 'regression' to keyword Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team MassPing-UntouchedBug