Apache OpenOffice (AOO) Bugzilla – Issue 70700
Basic Mid instruction is changed by CompatibilityMode(True)
Last modified: 2013-02-24 21:00:39 UTC
Run this macro: Sub Main dim test as string CompatibilityMode(True) test = "abcdefg" Mid(test, 3, 3, "Y") ' result should be : abYfg print test, "result is " & (test="abYfg") End Sub With version 2.0.4 the result is "abYdefg" With CompatibilityMode(False), or with version 1.1.5, result is "abYfg", consistent with Mid() specification in OOoBasic. In VBA Mid() instruction does not exist. It is only a function with 3 arguments. (VBA detects a syntax error if 4 arguments or if used as an instruction). If the idea is to use CompatibilityMode() to adapt to VBA syntax, there is a bug, and this is a very bad idea. Because CompatibilityMode() was introduced in version 1.1.1 to enforce Private declarations in OOoBasic, and programmers may already use it for this, and not for VBA compatibility.
Andreas, please take care of this ...
No, CompatibilityMode() has not been introduced to enforce private declarations. CompatibilityMode(true) has the meaning "Behave compatible to VB(A)" and there has never been any different meaning. CompatibilityMode is important as it al- lows to change the behaviour of existing runtime functions in order to make them VB compatible without breaking existing code not using CompatibilityMode. Making private declarations really private is only one example amongst many other changes covered by CompatibilityMode(true). Also Mid has been changed. In CompatibilityMode it's possible now to use the correct VB syntax: Mid(test, 3, 3) = "Y". Internally this is mapped to the old Mid(test, 3, 3, "Y"), but of course also the result must be the same as in VB. As this hasn't been the case it had to be fixed. Your "false" result is the correct VB result and that's what I expect in a VB compatibility mode. As you wrote VB doesn't even know Mid with four arguments. The CompatibilityMode is designed to run correct VB programs correctly, the behaviour of incorrect VB programs is not specified. So when using CompatibilityMode(true) Basic programmers must be aware of the fact that the behaviour of runtime functions may differ from the former beha- viour and that there could be even more changes in the future. You can only decide if you want to use the CompatibilityMode completely or not at all. There's no way to only pick a detail you like. -> INVALID
The Issue you raised has been marked as 'Resolved' and not updated within the last 1 year+. I am therefore setting this issue to 'Verified' as the first step towards Closing it. If you feel this is incorrect, please re-open the issue and add any comments. Many thanks, Andrew Cleaning-up and Closing old Issues ~ The Grand Bug Squash, pre v3 ~ http://marketing.openoffice.org/3.0/announcementbeta.html
As per previous posting: Verified -> Closed. A Closed Issue is a Happy Issue (TM). Regards, Andrew