LibreOfficeDev 7.4 Help
De functie CompatibilityMode beheert de runtime mode en beïnvloedt, na elke wijziging van die mode, alle code die daarna wordt uitgevoerd.
Wees voorzichtig met het gebruik van deze functionaliteit, beperk deze bijvoorbeeld tot de conversie van een document.
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.
Deze functie heeft invloed op of kan nuttig zijn in de volgende situaties:
Scoping of variables.
Voer het commando RmDir uit in VBA-mode. In VBA worden alleen lege mappen verwijderd met RmDir terwijl LibreOfficeDev Basic recursief een map verwijderd.
Verandert de werking van het Basic commando Dir. De vlag van de map (16) bij het commando Dir betekent dat alleen mappen worden teruggegeven door LibreOfficeDev Basic, terwijl in VBA ook de normale bestanden worden teruggegeven.
Color components calculation with the Red and Blue functions which are interchanged (The Green function is not affected).
Given a NOT empty directory at 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.
Gedrag Dir aanpassen
Sub VBADirCommand
CompatibilityMode( Enable := True ) ' Toont ook normale bestanden
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