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:
'***************************************************************************** ' 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 FunctionThe 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.
Fixing the RTL function would seem to be the only true solution.
-- -------------------------------------------------------- The Snake Pit - Development www.TheSnakePitDev.com Curtis Clauson [EMAIL PROTECTED] Proprietor
"Any sufficiently over-complicated magic is indistinguishable from technology." -- Llelan D.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
