Hilfe für LibreOffice 7.4
CompatibilityMode() function controls or queries runtime mode. It affects all code executed after setting or resetting the runtime mode.
Verwenden Sie diese Funktion mit Vorsicht, beschränken Sie sie beispielsweise auf die Dokumentkonvertierung.
CompatibilityMode(Optional Enable As Boolean) As Boolean
CompatibilityMode function always returns the mode that is active after its execution. That is if called with argument, it returns the new mode, if called without argument, it returns active mode without modifying it.
Enable: Sets or unsets new compatibility mode when the argument is present.
CompatibilityMode function relates to Option VBASupport 1, in which case it always returns True. It is unrelated to Option Compatible compiler directive.
Diese Funktion kann in folgenden Situationen Auswirkungen haben oder helfen:
Scoping of variables.
Ausführen des Befehls RmDir im VBA-Modus. In VBA werden nur leere Verzeichnisse von RmDir entfernt, während LibreOffice Basic ein Verzeichnis rekursiv entfernt.
Ändern des Verhaltens des Basisbefehls Dir. Das Verzeichnis-Flag (16) für den Befehl Dir bedeutet, dass in LibreOffice Basic nur Verzeichnisse zurückgegeben werden, während in VBA normale Dateien und Verzeichnisse zurückgegeben werden.
Color components calculation with the Red and Blue functions which are interchanged (The Green function is not affected).
Gegeben sei ein NICHT leeres Verzeichnis unter file:///home/me/Test
Sub RemoveDir
MsgBox CompatibilityMode() ' False
CompatibilityMode( True )
RmDir( "file:///home/me/Test" )
CompatibilityMode False
MsgBox CompatibilityMode ' False
End Sub
With CompatibilityMode( True ) the program raises an error, otherwise the Test directory and all its content is deleted.
Ändern des Verhaltens von Dir
Sub VBADirCommand
CompatibilityMode( Enable := True ) ' Shows also normal files
Entry$ = Dir( "file:///home/me/Tmp/*.*", 16 )
Total$ = ""
While Entry$ <> ""
Total$ = Total$ + Entry$ + Chr$(13)
Entry$ = Dir
Wend
MsgBox Total$
CompatibilityMode Enable := False ' Shows only directories
End Sub