Apache OpenOffice (AOO) Bugzilla – Issue 84433
Function return is inconsistent when the value is 'Empty'
Last modified: 2017-05-20 11:27:48 UTC
NOTE: This was observed on the OOo 2.3.1 actual release (Not RC1), but can't yet select this from this reporting tool. When a OOoBasic function return is unassigned/uninitialised, IsEmpty on the return value can still return False. This happens when there is a previous call to that function that returned an assigned/initialised value. STEPS TO REPRODUCE THE PROBLEM: 1. Open any OOo application, and create an OOoBasic macro in the Basic IDE as follows: Sub Code_Test MsgBox(IsEmpty(Bug_Demo(False))) MsgBox(IsEmpty(Bug_Demo(True))) MsgBox(IsEmpty(Bug_Demo(False))) End Sub Function Bug_Demo(bAssignReturnValue As Boolean) As Variant If bAssignReturnValue Then Bug_Demo = "Assigned a value" End If End Function 2. Run Code_Test: the result is three dialog boxes as follows: "True", "False", "False". The third MsgBox call is exactly the same as the first, but IsEmpty evaluates to different values. 3. Furthermore, if you run Code_Test a second time, the result is now: "False", "False", "False"; giving different results than the first execution, even though there are no global or static variables defined here. POSSIBLE WORKAROUND Seem to be able to work around this if an intermediate variable is introduced in Bug_Demo as follows: Function Bug_Demo(bAssignReturnValue As Boolean) As Variant Dim vReturnValue As Variant If bAssignReturnValue Then vReturnValue = "Assigned a value" End If Bug_Demo = vReturnValue End Function vReturnValue is correctly assigned to Empty every time, and thus Bug_Demo always returns Empty when (bAssignReturnValue = False) PROPOSED SOLUTION A function should return Empty everytime if the return value is unassigned.
Seems to be a BASIC thing, reassigned to Andreas.
STARTED, OOo 3.x
Reset assigne to the default "issues@openoffice.apache.org".