Download it now!
Bug 51433 - Intermittent Error - Inadmissible value or data type. Data type mismatch.
Summary: Intermittent Error - Inadmissible value or data type. Data type mismatch.
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: low normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-25 23:14 UTC by libreofficebugs
Modified: 2016-04-16 15:27 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description libreofficebugs 2012-06-25 23:14:25 UTC
By "intermittent", I do NOT mean that the bug can only be reproduced sometimes. It can ALWAYS be reproduced if you follow the directions below precisely.  By "intermittent", I mean that if you wander from the precise instructions given, the results become unpredictable.  Entering the same input can lead to different behavior depending on how you got there.

I have reproduced it on 3.4.5 running on Linux Mint Debian 64-bit and on 3.3 and 3.5.4.2 running on Windows XP.

Steps to reproduce:
1) Open Calc and start with a new empty spreadsheet file.
2) Click Tools, Macros, Organize Macros, LibreOffice Basic...
3) Click "Untitled 1", click New, click OK.
4) In the code editor, press Ctrl+A then Delete to clear any automatic skeleton code.
5) Enter the following code:
Function Q(a, b)
 Q = IIf(a MOD b = 0, 0, b - (a MOD b))
End Function
6) Go to cell A1; enter the formula "=Q(4,3)".
(no error, result is 2)
7) In the code editor, change the name of the function on lines 1 and 2 from "Q" to "R" (example - other names will work).
8) Change the formula in A1 to read "=R(4,2)".
(no error, result is 0)
9) Again, change the formula in A1 to now read "=R(4,3)"; enter.
(You are taken back to the code editor; line 2 is highlighted; The message box reads "Inadmissible value or data type. Data type mismatch.")

Extra credit:
Change the function name again (e.g. "Foo")
Change the formula to "=FOO(4,3)". (no error)
Change the formula to "=FOO(4,4)". (no error)
Change the formula to "=FOO(4,5)". (now you get the error as described above)
Comment 1 Thomas Hackert 2013-06-24 17:20:10 UTC
Hello libreofficebugs, *,
I tried to follow your instruction up to the point, but when I reach point 6, I get
<quote>
BASIC runtime error.
Argument is not optional.
</quote>
in the BASIC Editor instead of an "2" ... :( Same goes for point 7 and 9 ... :(

Tested with
LO Version: 4.1.0.1 Build ID: 1b3956717a60d6ac35b133d7b0a0f5eb55e9155
OS: Debian Testing AMD64

Would you be so kind to test it again with a newer version of LO than 3.5.4, please? And what I miss, is a description, what you have inspected ... ;) I am not a developer nor a BASIC geek, but just a QA guy ... ;)

Sorry for the inconvenience
Thomas.
Comment 2 libreofficebugs 2013-07-04 00:26:02 UTC
Thank you Thomas.

The bug still reproduces for me exactly as described in the original bug report.  I've tried on both the 4.0.2 that is current for Kubuntu 13.04 as well as with 4.0.4.2 from Calculate 13.6.1 (a Gentoo based distro).  I think 4.0.4 is the latest stable release and I'm not sure how I'd try it on the newer version that you tried (4.1.0.1) unless I installed Debian Testing.

I'm guessing your inability to reproduce the bug was either due to misunderstanding my directions or not following the steps closely enough.

I'm not a developer nor a Basic geek either, but I think I can explain briefly how this should work, and maybe you can get past step 6 to reproduce the bug.

(The TLDR of this is as follows: 1) No positive integers as arguments to this function should ever cause an error.  2) Simply changing the name of the function should not result in an error when the same arguments didn't cause an error using the previous function name.)

I make a function in the Basic editor, then I access it by using it in a spreadsheet formula (changing the name to all-caps, of course).
The function takes 2 arguments, which we name 'a' and 'b'.
The body of the function consists of this single line:
 Q = IIf(a MOD b = 0, 0, b - (a MOD b))
"Q = " means set the return value of the function to the value of the expression which follows.
"IIf" means "immediate if".  The "IIf" function requires 3 arguments.  It evaluates the truth of the 1st argument and returns either the 2nd argument (if True) or the 3rd argument (if False).
So, in the example above, the value 0 should be returned whenever the first argument to IIf is True, otherwise it should evaluate and return the 3rd argument.
"MOD" is a binary operator that evaluates to the remainder when dividing the first operand by the second.
"=" is a binary operator that evaluates True if the operands are equal, False otherwise.
"-" is a binary operator that evaluates to the remainder of the second operand subtracted from the first.

So here's the initial example:
In the spreadsheet you've entered "=Q(4,3)".  So when the function runs, 'a' will be equal to 4 and 'b' will be equal to 3.
Substituting those values in we get:
 Q = IIf(4 MOD 3 = 0, 0, 3 - (4 MOD 3))
Simplify, starting with the MOD operator:
 Q = IIf(1 = 0, 0, 3 - (1))
Now the other two:
 Q = IIf(False, 0, 2)
So 2 is the answer you should get in step 6 by following the directions.  If you're getting an error there, you've either not followed the steps correctly or you've discovered another separate bug on your version of LO [not likely]. Based on the error message you gave, it could be that you mistakenly entered "=Q(4.3)" instead of "=Q(4,3)". "Q" requires 2 arguments [e.g. 4,3] whereas 4.3 is a single value so you would have gotten that "Argument is not optional." error.  Just make sure you're following the directions carefully.

After step 6, we change the name of the function in the code editor from "Q" to "R", then in the worksheet simultaneously update the function name and change the value of the second argument from 3 to 2.  The value is now 0 because 4 is evenly divisible by 2.  You don't get the error until step 9 when you change the second argument back to 3.

(If you're still having trouble understanding my steps to reproduce the bug, I could possibly do a screen capture and upload the video for you to watch.)

> And what I miss, is a description, what you have inspected ... ;)
I'm not sure I understand the question.  I haven't inspected anything because I'm not a developer - I was just reporting the bug.

I know there are other ways to write such a function, and I don't even remember what I was doing a year ago.  This was probably just simplified from a more complex function while preserving the ability to reproduce the bug.
Comment 3 Joel Madero 2013-07-23 17:33:00 UTC
Confirmed:

Bodhi Linux
LibreOffice Version: 4.1.0.3

Prioritizing:
New (confirmed)
Normal (could in theory make professional documents impossible to create)
Low (while it could, it requires a user to do some tricky stuff to get stuck and with over a year gone by and no duplicates marked - seems like it's not affecting many -- if any -- other users)


Noel: This one yours?
Comment 4 QA Administrators 2015-04-01 14:41:33 UTC
** Please read this message in its entirety before responding **

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 on a currently supported version of LibreOffice (4.4.1 or later)
   https://www.libreoffice.org/download/

   *If the bug is present, please leave a comment that includes the version of LibreOffice and your operating system, and any changes you see in the bug behavior
 
   *If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a short comment that includes your version of LibreOffice and Operating System

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)

http://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: http://webchat.freenode.net/?channels=libreoffice-qa

Thank you for your help!

-- The LibreOffice QA Team This NEW Message was generated on: 2015-04-01
Comment 5 libreofficebugs 2015-04-01 22:07:45 UTC
(In reply to QA Administrators from comment #4)
>    *Test to see if the bug is still present on a currently supported version
> of LibreOffice (4.4.1 or later)

Tested on 4.4.2.2 (Build ID: 40m0(Build:2)) on Kubuntu 14.04 (32-bit) from ppa:libreoffice/ppa
Still reproduces exactly as described in the opening comment.

> 4a. If the bug was present with 3.3 - set version to "inherited from OOo"; 

Setting "inherited" based on the fact that the bug as initially reported was reproducible on 3.3.
Comment 6 tommy27 2016-04-16 07:24:24 UTC
** Please read this message in its entirety before responding **

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 on a currently supported version of LibreOffice (5.0.5 or 5.1.2 https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the version of LibreOffice and your operating system, and any changes you see in the bug behavior
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a short comment that includes your version of LibreOffice and Operating System

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)

http://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: http://webchat.freenode.net/?channels=libreoffice-qa

Thank you for your help!

-- The LibreOffice QA Team This NEW Message was generated on: 2016-04-16
Comment 7 libreofficebugs 2016-04-16 15:27:53 UTC
No longer reproducible with the following version:
Version: 5.1.2.2
Build ID: 1:5.1.2~rc2-0ubuntu1~trusty0
CPU Threads: 2; OS Version: Linux 3.13; UI Render: default; 
Locale: en-US (en_US.UTF-8)