[Solved] How to debug a single subroutine?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Lestrad
Posts: 5
Joined: Fri Aug 09, 2019 10:31 am

[Solved] How to debug a single subroutine?

Post by Lestrad »

Hello to all. I'm a longtime MS Office user, with quite a bit of experience programming in VBA - Word, but also Excel and Access. I'm now trying to switch to Linux and OpenOffice.
My subs and functions are all in one or two modules. I'm used to the "Full Module View" in the VBA editor/debugger, which lets you place your cursor in a subroutine and step through just that subroutine. But if there's a way to do that in OpenOffice, I can't figure it out. No matter where I put the cursor, only the first sub in the module gets run. I can run the individual macros in the module individually, but I need to be able to step through them.
For now it looks like the only way to do it is either to put each macro in a separate module, or else to copy the code I want to step through and paste it in at the top of the module. Isn't there another way? Any help would be appreciated.

Regards,
Les
Last edited by Hagar Delest on Mon Aug 12, 2019 8:03 am, edited 1 time in total.
Reason: tagged solved
OpenOffice 4.1.6 on Linux Mint 19.1
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to debug a single subroutine?

Post by Villeroy »

Is there any serious reason why you install OpenOffice on a Linux machine?
You run LInux Mint.
Linux Mint comes with LibreOffice preinstalled.
LibreOffice offers to place the cursor in a routine and start step mode.
--------------
In OpenOffice and LIbreOffice and MS VBA you can place a stop mark with F9, start step mode with F8, add a variable to the watch window with F7 and run code with F5. Only OpenOffice runs no routine other than the first one. When I used to use OpenOffice, I put a small debug routine on top of a module from where I called other routines.
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
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to debug a single subroutine?

Post by JeJe »

Tools Menu/Macros/Run Macro

You can put a sub at the top of the module to call the macro you want. eg

Code: Select all

sub ToRunWhateverMacro
'Macrox
Macroy( a, b,c)
end sub

LibreOffice does this better.

Edit: I tried Linux Mint en route to settling on MX Linux as that is lighter weight and impressed me more.
I stick with OpenOffice (on my Windows machine) because I got less crashes compared to LO...
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Lestrad
Posts: 5
Joined: Fri Aug 09, 2019 10:31 am

Re: How to debug a single subroutine?

Post by Lestrad »

Villeroy wrote:Is there any serious reason why you install OpenOffice on a Linux machine?
Thanks for your replies!

Alas, there is a serious reason - for me at least: I can't get the spell checker to work properly on Libre Office Writer. (It's serious for me because I make my living translating and editing.) I've tried two versions so far, including the latest one. And I plan to keep trying until I finally get the spell checker working, because it does look as if the future will belong to LibreOffice.

That solution using a call from a little sub at the top is great. Thanks to all of you.
OpenOffice 4.1.6 on Linux Mint 19.1
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to debug a single subroutine?

Post by Villeroy »

Install the system wide language package for all text processing programs. This is not included on Ubuntu's 2GB install medium and I guess it is the same with Mint. Spell check and localization should work with any native text processing program from your distribution. IMHO OpenOffice is bad and unstable with any recent Linux distribution.
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
Lestrad
Posts: 5
Joined: Fri Aug 09, 2019 10:31 am

Re: How to debug a single subroutine?

Post by Lestrad »

Thanks.

I've seen that lots of people have trouble getting the spell checker to work. In my case it works, but when I add a word to a custom dictionary - which I need to do often at the moment -, the spell checker thinks it's come to the end of the file and stops. BUT now OpenOffice has started doing the same thing. So I think I'll be going back to LibreOffice before long.

In any case the spell checking is not my top priority. Learning to convert all my VBA macros to Open/LibreOffice is. I'll be posting quite a few questions on that, I'm afraid. ;-) I never thought I'd praise Microsoft for anything, but one has to admit that the documentation on VBA is extensive, easy to find, and well written. So far, though I've tried hard, I haven't found a single good source for OO/LO (I realise that there are very good reasons for that).

Thanks again for your help!
OpenOffice 4.1.6 on Linux Mint 19.1
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: How to debug a single subroutine?

Post by RoryOF »

I have just tried, using spelling checker and Language Tool on OO; adding a word to a custom dictionary allowed the spelling check continue from the word location; other instances of the chosen word were immediately deselected in the onscreen display.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to debug a single subroutine?

Post by JeJe »

So far, though I've tried hard, I haven't found a single good source for OO/LO (I realise that there are very good reasons for that).
http://www.pitonyak.org/oo.php/AndrewMacro.pdf

Almost essential tool, MRI:

https://extensions.openoffice.org/en/pr ... ction-tool

Very useful:

https://extensions.openoffice.org/en/pr ... -ide-tools
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Lestrad
Posts: 5
Joined: Fri Aug 09, 2019 10:31 am

Re: How to debug a single subroutine?

Post by Lestrad »

Thanks, this gave me a great leg up! I wasn't able to find much via the first link, but the MRI is exactly what I was looking for.

I'll explore your third link once my heart stops pounding with excitement over MRI!
OpenOffice 4.1.6 on Linux Mint 19.1
Lestrad
Posts: 5
Joined: Fri Aug 09, 2019 10:31 am

Re: How to debug a single subroutine?

Post by Lestrad »

RoryOF wrote:I have just tried, using spelling checker and Language Tool on OO; adding a word to a custom dictionary allowed the spelling check continue from the word location; other instances of the chosen word were immediately deselected in the onscreen display.
That works for me too, but the problem is that after a while, the spell checker acts as if it's been halted - the Resume button is enabled. And then when I click Resume, I get "Spell check is complete," with many many pages left unchecked.

I should explain that I'm editing a 950-page novel full of characters and places with names the author sometimes misspells when re-introducing them (sometimes many pages after the most recent mention). So I created a specific custom dictionary for all the names. So admittedly I'm make heavy demands on the spell checker. One thing I have to say, though, is that MS Word would have given up trying to underline misspelled terms in such a long document. With AOO so far that hasn't happened.

If the problem continues I'll open a new thread for the spell checker problem.

Thanks for your help.
Les
OpenOffice 4.1.6 on Linux Mint 19.1
User avatar
robleyd
Moderator
Posts: 5086
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: How to debug a single subroutine?

Post by robleyd »

Troubleshooting spellcheck might save you asking a further question
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Solved] How to debug a single subroutine?

Post by RoryOF »

I often edit documents of similar size, using a custom dictionary for document specific names and terms. Spellcheck has never stopped working on them.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply