Name
#Const Directive
Syntax
#Constconstantname=expression
-
constantname(required; String literal) Name of the constant
-
expression(required; literal) Any combination of literal values, other conditional compilation constants defined with the
#Constdirective, and arithmetic or logical operators exceptIs
Description
Defines a conditional compiler constant.
By using compiler constants to create code blocks that are included in the compiled application only when a particular condition is met, you can create more than one version of the application using the same source code. This is a two-step process:
Defining the conditional compiler constant. This step is optional; conditional compiler constants that are not explicitly defined by the
#Constdirective, but are referenced in code, default to a value of Nothing.Evaluating the constant in the conditional compiler
#If...Thenstatement block.
A conditional compiler constant can be assigned any string, numeric,
or logical value returned by an expression. However, the expression
itself can only consist of literals, operators other than
Is, and another conditional compiler constant.
When the constant is evaluated, the code within the conditional
compiler #If...
Then block is
compiled as part of the application only when the expression using
the conditional compiler constant evaluates to
True.
Rules at a Glance
Conditional compiler constants are evaluated by the conditional compiler
#If... Thenstatement block.You can use any arithmetic or ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access