https://bugs.freedesktop.org/show_bug.cgi?id=79426
Priority: medium
Bug ID: 79426
Assignee: [email protected]
Summary: Macros: Passing an error object to a function causes a
run time error.
Severity: normal
Classification: Unclassified
OS: All
Reporter: [email protected]
Hardware: Other
Whiteboard: BSA
Status: UNCONFIRMED
Version: 4.2.3.3 release
Component: BASIC
Product: LibreOffice
Created attachment 100121
--> https://bugs.freedesktop.org/attachment.cgi?id=100121&action=edit
Writer doc with additional code examples, analysis and screen shots
Problem description:
====================
Passing an error object to a function causes a run time error. Any reference
within the function to the argument containing an error object such as
“CVErr(2)“, causes the run time error: “BASIC runtime error. Argument is not
optional.”
How to reproduce the problem:
=============================
1. In a LibreOffice document with Macros, open Tools --> Macros --> Organize
Macros --> pick any module to edit
2. Type (or cut/paste) the following code in to the “Module” of your choice.
(Module1 will do)
-------------------------
Sub TestCVErr
Dim vErr
Dim nValue as Integer
Dim ss
vErr = CVErr(2)
nValue = vErr
ss = ""
ss = ss & "VarType, TypeName, and nValue = " & VarType(vErr)
ss = ss & ", " & TypeName(vErr)& ", " & nValue
Print ss
Print fnGetErrNum(vErr) 'This causes failure
End Sub
Function fnGetErrNum(vErr)
Dim nValue as Integer
nValue = vErr
fnGetErrNum() = nValue
End Function
-----------------------------------
3. Run TestCVErr
4. The program stops with a run time error ( “BASIC runtime error. Argument is
not optional.”) in the function
5. Replace the last line in TestCVErr() with the following, passing the integer
nValue rather than the error object:
------------------------------------
Print fnGetErrNum(nValue) 'This works
------------------------------------
6. Run TestCVErr and the function returns the number correctly.
Current behavior:
===================
If the argument being passed to the function contains an error object, any
reference to it will cause a run time error. The same code that works in the
main routine will fail if placed within a function referencing the vErr as an
argument. The same behavior was observed in both a Linux (fc20) and a Windows
(Win7/64-Bit) environment.
Expected behavior:
===================
The function should return an integer value of 2; this should be the same
behavior as the code in the main routine “nValue = vErr” which casts the error
object into an integer value.
Operating System: All
Version: 4.2.3.3 release
--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs