Random error messages

Creating a macro - Writing a Script - Using the API

Random error messages

Postby Crisdeannn » Sat Mar 06, 2021 12:54 pm

Hello,

For few days I struggle with strange behaviour of the editor.

Probably it started since I had downloaded additional dialog window from another spreadsheet and made few changes in the sequence of first functions in the code.

When I start a macro, it breaks and I am getting random and pointless error notifications.

For example:

for line:
dim oWindow as object
"Inadmissible value or data type.
Index out of defined range."

for line
oSheet = ThisComponent.Sheets(4)
"BASIC runtime error.
Object variable not set."

for line:
if parameter = 0 then
"BASIC runtime error.
Object variable not set."

etc.

Sometimes all I need to do to solve that issue is to close and open the spreadsheet or to place a line with MsgBox() function before the line which was a subject of an "error", for example:

MsgBox("Hello")
dim oWindow as object

Such "solution" works for a while but soon these issues return in different code line.

Since I don't even know how to define the problem, I could not find any solutions, but it looks like a general issue that should have happened to other users by now. Do you have any suggestions ?

Thank you
LibreOffice 7.0.4.2 (x64), Windows 10
Crisdeannn
 
Posts: 9
Joined: Mon Nov 27, 2017 7:47 pm

Re: Random error messages

Postby RoryOF » Sat Mar 06, 2021 12:58 pm

I think we need to see the full text of the macro.
Apache OpenOffice 4.1.9 on Xubuntu 20.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 32523
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Random error messages

Postby JeJe » Sat Mar 06, 2021 2:09 pm

Try a search for all the other instances of the variables you're having problems with to see if there are any conflicts/duplications. If you have a function or another variable also called oWindow you can have problems. It could be in an extension or it could be in the built in OO macro libraries.
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1532
Joined: Wed Mar 09, 2016 2:40 pm

Re: Random error messages

Postby JeJe » Sat Mar 06, 2021 2:20 pm

Or just try changing the names to something less generic.
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1532
Joined: Wed Mar 09, 2016 2:40 pm

Re: Random error messages

Postby Crisdeannn » Sat Mar 06, 2021 6:56 pm

RoryOF wrote:I think we need to see the full text of the macro.


The macro has more than 28.000 lines and, unfortunately, I am not allowed to publish the whole code. It is also impossible to choose problematic parts, because error messages seems to appear randomly in unpredictable parts of the code. I suppose that studying it would not lead to the answer...

JeJe wrote:Try a search for all the other instances of the variables you're having problems with to see if there are any conflicts/duplications. If you have a function or another variable also called oWindow you can have problems. It could be in an extension or it could be in the built in OO macro libraries.


JeJe wrote:Or just try changing the names to something less generic.


All variable and function names are uniqe. They worked fine before I made a change that caused the problem. I think the code and variable names are not the issue.

To give you better understanding of what is going on, I'll describe what I did in last minutes and how I "solved" the problem.

I was trying to shorten the code to recreate these errors on short code version. I removed first two functions (which were not important) and the macro started without any error notifications. After pressing one of the keys in dialog window it broke again with another issue:

for line:
z=2
"BASIC runtime error.
Object variable not set."

Before z=2, I just added "dim z as integer" and restrated the macro. Now it didn't even start (so the situation got worse) but broke on a line of different routine:

for line:
if parametry_pierwotne = 0 then
"BASIC runtime error.
Object variable not set."

Before this line I added empty line (just by simply pressing enter) and restarted macro again. Now it works fine and do not crush. Everything seems to be perfect.

When changing the code I was also getting error messages like:

for line:
MsgBox("Start")
"BASIC runtime error.
Sub-procedure or function procedure not defined."

or for line:
Start_dialog_0
"BASIC runtime error.
Property or method not found: ᤀ禁€ऀ." (yes, with these funny characters)

As you can see these errors seem to make no sense. I wonder what can cause the program to behave like that.
LibreOffice 7.0.4.2 (x64), Windows 10
Crisdeannn
 
Posts: 9
Joined: Mon Nov 27, 2017 7:47 pm

Re: Random error messages

Postby RoryOF » Sat Mar 06, 2021 7:37 pm

It is my memory (perhaps faulty) that there is a limit of 64KB to an OpenOffice macro code module - perhaps also to a LibreOffice macro code module. If you have 28,000+ lines, that only allows 2.5 characters per line. So if my memory is correct (not checked) you may need to break your code into modules. But I am not an expert macro writer, so someone with more experience may have other suggestions to offer.
Apache OpenOffice 4.1.9 on Xubuntu 20.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 32523
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Random error messages

Postby Crisdeannn » Sat Mar 06, 2021 8:46 pm

RoryOF wrote:It is my memory (perhaps faulty) that there is a limit of 64KB to an OpenOffice macro code module - perhaps also to a LibreOffice macro code module. If you have 28,000+ lines, that only allows 2.5 characters per line. So if my memory is correct (not checked) you may need to break your code into modules. But I am not an expert macro writer, so someone with more experience may have other suggestions to offer.


Considering what errors I get, that could be the reason. I have checked that and OpenOffice wiki states that modules within libraries have a maximum size of 64kb.

I have it in one module and the code contains 620.000 characters (665 kB in notepad).

However, I have experienced this problem just for few days. Last week macro versions have over 600.000 characters, which means that they exceed 64kb limit 10 times and still work fine.

I will try to split the code in few modules and let you know if the problem reoccur.
LibreOffice 7.0.4.2 (x64), Windows 10
Crisdeannn
 
Posts: 9
Joined: Mon Nov 27, 2017 7:47 pm

Re: Random error messages

Postby Villeroy » Sat Mar 06, 2021 9:35 pm

The macro has more than 28.000 lines

And why do you need any help from us? You are the expert. You have the code.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29693
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests