2

I'm writting a macro in LibreOffice and woudld like to print somethings in the IDE window of LibreOffice.

In VBA I use Debug.Print to print some values in the IMMEDIATE Window.

What is the function Debug.Print (VBA) for Oobasic or StarBasic in LibreOffice? or it doesn't exist? If you know write the script please. Thanks.

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
jMcfly
  • 35
  • 1
  • 6
  • 1
    I don't program that much in LibreOffice but I don't think there's an immediate window. I think you can resort to `MsgBox` or `Print` for debugging, among other options. – BigBen Apr 27 '19 at 23:02
  • Why is this tagged VBA when it is not about VBA at all. – Noodles Apr 28 '19 at 07:39
  • Well, Oobasic and VBA are in many things identical. My macro deals with Calc and VBA deals with Excel. Only the inherent functions of each program functions are different, and I wanted to know if someone who use both softwares know. Beside that I tried to tag my query as #Oobasic but apparently the system doesn't allow me because I have not 1500 points to create a new tag. Sorry !!! – jMcfly Apr 28 '19 at 16:07
  • As BigBen said you can use Print VariableName or run the code step by step with F8 – patel May 05 '19 at 16:59

1 Answers1

1

Since the OP seems to at least be familiar with LibreOffice Basic as well as VBA, he should note that there is no Immediate window within the LibreOffice IDE. Using debug.print will not work. LibreOffice's version of debug.print comes bundled within a whole library of functions which can be used from the a library set called "ScriptForge". More information about "ScriptForge" can be found at https://help.libreoffice.org/7.5/en-US/text/sbasic/shared/03/lib_ScriptForge.html?DbPAR=BASIC

In order to get access to the ScriptForge's exception handling functions, you will need to invoke the service "Exception". This opens all of the functionality for error handling and display and it includes it's own version of debug.print. Please note, you do not have to encounter an error in order to use this service. Please see the code below for how I implemented (note that the code as it stands will not have any error).

Sub Main
    GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
    createscriptservice("Exception")
    SF_Exception.consoleClear()
    for x = 0 to 100
        SF_Exception.debugprint(x)
    next x
    SF_Exception.console()
End Sub

One of the main drawbacks of the debugprint subroutine is that it is not just simply one line of code. You will invoke the debugprint subroutine, but then you have to invoke the console. The console is also a bit of a problem. The console is basically a modal window. So the program pauses until you close the window. Granted there is a button to close the window, but it would be great to continue debugging the code along with displaying any output to debugprint console. Hope this helps.

Z T Minhas
  • 37
  • 6