https://bugs.documentfoundation.org/show_bug.cgi?id=150727

Rafael Lima <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |NOTABUG
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Rafael Lima <[email protected]> ---
Actually this is the intended behavior. It's by design in Basic (and in VBA as
well).

According to Pitonyak's book about LO Basic:

"By default, arguments are passed by reference rather than by value. In other
words, when the called subroutine modifies an argument, the caller sees the
change. You can override this behavior by using the ByVal keyword."

To avoid changing the value of x, you need to use the ByVal keyword:

Sub Main()
    Dim x As String
    x = "foo"         ' (1)
    Aux(x)            ' (2a)
    MsgBox x          ' ==> "bar", expected "foo"
End Sub

Sub Aux(ByVal y As String)      ' (2b)
    y = "bar"         ' (3)
End Sub

I'm closing this as NAB.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to