[Solved] Random error messages with 28000 line macro
-
- Posts: 10
- Joined: Mon Nov 27, 2017 7:47 pm
[Solved] Random error messages with 28000 line macro
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
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
Last edited by Crisdeannn on Sat Apr 30, 2022 7:12 am, edited 1 time in total.
LibreOffice 7.0.4.2 (x64), Windows 10
Re: Random error messages
I think we need to see the full text of the macro.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Random error messages
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.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Random error messages
Or just try changing the names to something less generic.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
-
- Posts: 10
- Joined: Mon Nov 27, 2017 7:47 pm
Re: Random error messages
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...RoryOF wrote:I think we need to see the full text of the macro.
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.
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.JeJe wrote:Or just try changing the names to something less generic.
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
Re: Random error messages
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.15 on Xubuntu 22.04.4 LTS
-
- Posts: 10
- Joined: Mon Nov 27, 2017 7:47 pm
Re: Random error messages
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.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.
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
Re: Random error messages
And why do you need any help from us? You are the expert. You have the code.The macro has more than 28.000 lines
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Posts: 10
- Joined: Mon Nov 27, 2017 7:47 pm
Re: [Solved] Random error messages
It took me some time to confirm that the solution is robust. Breaking the code into modules solves this kind of problem entirely.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.
Thank you for your support.
LibreOffice 7.0.4.2 (x64), Windows 10
Re: [Solved] Random error messages with 28000 line macro
I am stunned to think macros all in one module for 28000 rows. The modules create a namespaces, so you can call function with same name : module1.funct e module2.funct, example Sub Main() is in every module.
The namespace is no abstract, but represent a logical set of functions. A module can represents a Class, where the properties are in a Type and the functions (methods) have an instance of the Type for parameter.
I think this as an architectural design for the own project.
The namespace is no abstract, but represent a logical set of functions. A module can represents a Class, where the properties are in a Type and the functions (methods) have an instance of the Type for parameter.
I think this as an architectural design for the own project.
LibreOffice 6.3 on Windows 10 64bit
Re: [Solved] Random error messages with 28000 line macro
28000 lines of linear code is a disaster waiting to happen ... and it has happened.
Break it into manageable modules.
Break it into manageable modules.
LO 6.4.4.2, Windows 10 Home 64 bit
See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.
Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.
Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Re: [Solved] Random error messages with 28000 line macro
BASIC anyway is a disaster, the (quantity of disaster) can be approximatly calculated by
Code: Select all
QOD = lines_of_code^2
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)