Scope (LibreOffice Basic)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

In LibreOffice Basic (LO Basic), variable scope is a concept that determines where a variable can be accessed and modified. LO Basic provides various levels of scope, ranging from local to global.

Local scope & dim

A variable declared with dim inside a procedure (subroutine or function) is local to that procedure. It is only available within that block of code and ceases to exist once the procedure finishes.

E.g.:

Sub ExampleSub()
    Dim localVar As Integer   ' Local scope
    localVar = 10
    MsgBox "Local Variable Value: " & localVar
End Sub

Local scope & static

Variables declared with Static inside a sub or function are local, retains its value inbetween calls, while Dim does not.


NOT FINISHED YET

Sources