Compiler Directives

 <  Day Day Up  >  

In FoxPro, the #CONST directive can be used to specify a value that is substituted for occurrences of the named constant in the code at compile time. The #IF #ELSE #ENDIF construct can be used to deliver source code that will include only the code that will compile correctly given the compiler version. #DEF , #UNDEF , and #IFDEF can similarly be used to determine what code gets compiled. The #Include directive reads in a text file, and is like the #ExternalSource directive in Visual Basic.

In Visual Basic .NET, the #Const compiler directive also exists, and the #IF / #ELSE / #ENDIF construct works much like its counterpart in FoxPro, although not to support multiple language versions because there's only one at this time; besides, Visual Basic doesn't allow code that isn't syntactically correct to exist in the source code, as it compiles automatically when you close a code window.

The most interesting compiler directive in Visual Basic is the #Region Name / #End Region block, which allows you to group code elements and collapse them to a single label by clicking on the "+" beside the #Region directive. There's no equivalent in FoxPro, although the way that FoxPro groups code into snippets in the Form and Class Designers provides similar functionality, in the sense of letting you see only some of the code at one time.

Table 1.8 summarizes compiler directives in Visual FoxPro and Visual Basic.

Table 1.8. Compiler Directives


Visual Basic

Visual FoxPro

Define a constant



Compile selected lines



Collapse part of code

#Region.. #End Region

No equivalent

Include a file



 <  Day Day Up  >  

Visual Fox Pro to Visual Basic.NET
Visual FoxPro to Visual Basic .NET
ISBN: 0672326493
EAN: 2147483647
Year: 2004
Pages: 130
Authors: Les Pinter

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: