Debugging LibreOffice Macro Basic using Breakpoint and Watch
This tutorial will teach you LibreOffice basic macro debugging technique using breakpoint and watch. This is built on the Ubuntu 14.04LTS and LibreOffice using basic. These techniques applicable for almost all programming languages along with OpenOffice.
Lets define 3 variables which we would use for our exercise.
dim i, j, cnt
Define a for loop which would execute from 1 to 10. Inside the loop, increment two variables as below. This is just for demo, you can put any logic you want.
for cnt = 1 to 10 i = i + 1 j = i + 1 next cnt
Now, we want to put two breakpoints in the statement “for cnt = 1 to 10” and “j = i + 1”. When you put breakpoint inside your program, it runs in a debug mode and hold the execution at the breakpoint.
To put breakpoint, put the cursor in the statement and press F9 or press below button from tool bar.
Once you do that, you would see a red circle on the left side of the statement which means breakpoint is added.
If you want to remove breakpoint from a statement, press F9 again in the statement OR you can double-click the red circle.
Now, we would add a ‘watch’ to the variable “cnt”. When the program executes on debug mode, watch helps to monitor the value of a variable between program steps. To add watch on “cnt” variable, select the variable and press F7 or click the glass icon in the tool bar.
Once you do that, you would see the variable is added in the watch list of the bottom of the editor.
Execute by Step
We are all set with tools. Run the program by pressing F5. As we already added breakpoint, you would see the execution halts at the first breakpoint with a little yellow arrow. Now you have two options.
a) Press F5 again to continue execution of the program and it will halt again in the next breakpoint.
b) Press F8 (step execution) which would execute step by step and you can see the ‘watched’ variable ‘cnt’ value is changing as below.
Looking for Something Else?
If you are looking for something else in LibreOffice macro tutorials, Or, wants to learn more about it, please follow below link for complete Macro Tutorials Index: