Curtis Clauson wrote:

Andrew Douglas Pitonyak wrote:

In Basic, I can turn compatibility mode on and off for each specifi module. I can also use the CompatibilityMode method to specifically turn compatibility mode on and off in a piece of code. Is there any way to check the state of compatibility mode? Some routines return the current state when you set a new state, CompatibilityMode() does not :-(


(In the middle of Basic parser/compiler/runtime spelunking to create a Basic language specification.)

Unfortunately, there is no direct way to query the Compatibility mode state. You're right, the RTL function CompatibilityMode(Boolean) really should return the previous state, and the argument should be optional. It should also be named "VbCompatibilityMode" and "Option VbCompatiblity" to clearly indicate with what it is compatible (Basic *is* supposed to be language explicit).

However, you can deduce it indirectly, but only with the "Option Compatibility" statement. When "Option Compatibility" is specified, a set of String constants is inserted in public variable space. They are:
vbCr Chr(13)
vbCrLf Chr(13) & Chr(10)
vbFormFeed Chr(12)
vbLf Chr(10)


  vbNewLine      Chr(10)            Unix
  vbNewLine      Chr(13)            Mac
  vbNewLine      Chr(13) & Chr(10)  All others

  vbNullChar     Chr(0)
  vbNullString   Chr(0)
  vbTab          Chr(9)
  vbVerticalTab  Chr(11)

You can use the following function to test for the existence of one of these to indicate if "OPTION Compatible" was included in this module.
Tested with v1.1.4 & v1.9.74:

vbNullChar should be a string that contains a CHR$(0)... Should be fixed by OOo 2.0 release
http://www.openoffice.org/issues/show_bug.cgi?id=42467


Interesting about the vbNewLine... I was not certain what values it used. I simply documented it as OS dependent. :-)

The routine that you provide tells me if "Option Compatible" is contained at the top of the module. It does not tell me, however, if compatibility mode is on or off. I will make a comment on the difference at the bottom... Oh, I see that you mention this near the bottom already ... Smart!

'*****************************************************************************

' True if this module includes "OPTION Compatible".
'
' This will not work if the public string vbCr is explicitly defined, or
' with the RTL function CompatiblityMode(Boolean) since it does not
' insert the Visual Basic public string constants.
'
Function IsVbCompatible As Boolean
    ' Default return.
    IsVbCompatible = False

    ' Test for a well known Compatibility constant string.
    On Local Error Resume Next
     IsVbCompatible = (VarType(vbCr) = V_STRING)
End Function


The RTL function CompatibilityMode(Boolean) only sets the state and does not insert/remove the Vb public strings, so this function will not work with it. I have yet to find a way to deduce the state set by this function.

Oh wait, you are aware of this....

Fixing the RTL function would seem to be the only true solution.


Setting "Option Compatible" appears to primarily set compile time items such as allowing an expanded character set or enabling the vb strings. Setting compatibility mode to true enables the keyword Private to work, which in turn allows Dim to properly declare variables Private as it should. I do not remember off hand if I need to explicitly call CompatibilityMode(True) for RmDir(path$) to change the behavior of RmDir(). Ugggg!

I must admit, however, it is probably not that big of a deal....

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw
My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm
Free Info:  http://www.pitonyak.org/oo.php


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to