Guida di LibreOfficeDev 7.4
CompatibilityMode() function controls or queries runtime mode. It affects all code executed after setting or resetting the runtime mode.
Utilizzate questa funzione con cautela, limitatela, per esempio, alla conversione di documenti.
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.
Questa funzione può interessare o aiutare nelle situazioni sotto specificate:
Scoping of variables.
Avvio del comando RmDir nel modo VBA. In VBA solo le directory vuote vengono rimosse da RmDir, mentre LibreOfficeDev Basic le rimuove in modo ricorsivo.
Cambio del comportamento Dir di Basic. Il flag di directory (16) per il comando Dir indica che vengono restituite solo directory in LibreOfficeDev Basic, mentre in VBA vengono restituiti normali file e directory.
Color components calculation with the Red and Blue functions which are interchanged (The Green function is not affected).
Specificata una directory NON vuota in 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.
Modifica del comportamento 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