Why doesn't this work?
vining
X Member
DEFINE_START
nVST_DeBug = 0 ; // use to debug from start up! change to 0 when finished debugging!
if (nVST_DeBug) // or comment out completely !
{
#WARN 'nVST_DeBug is set to 1 in DEFINE_START' ;
}
No matter what I change nVST_DeBug to I get the compiler warning, which is not what I expected!
Why?
Comments
-
The short answer is because that?s its job. It?s a precompile directive. Unless there is some other precompile directive wrapped around it (i.e. #IF_DEFINED, #IF_NOT_DEFINED, etc.) the warning message will be generated at compile time. The compiler doesn?t evaluate IF conditions. IF conditions are evaluated at run-time. Precompile directives are not evaluated at run-time, they are evaluated at compile time.
-
As a follow up, you could do something like this:
Debug is on and will generate your warning ? at compile timeDEFINE_CONSTANT INTEGER nDebugOff = 0 INTEGER nDebugOn = 1 DEFINE_VARIABLE INTEGER nDebug DEFINE_START nDebug = nDebugOn #IF_DEFINED nDebugOn #WARN 'Debug in On' #END_IF
And to turn debug off and not have the warning generated you could do this:DEFINE_CONSTANT INTEGER nDebugOff = 0 //INTEGER nDebugOn = 1 DEFINE_VARIABLE INTEGER nDebug DEFINE_START nDebug = nDebugOff #IF_DEFINED nDebugOn #WARN 'Debug in On' #END_IF
HTH -
It should be noted that Joe's examples require a re-compile to turn the debug flag on and off, you can't use precompiler directives on-the-fly.
I've found it simpler to use SEND_STRING 0 coupled with a regular variable (or virtual device channel). Precompiler directives are a bit kludgy for this kind of application, IMO. -
Yes, you do have to recompile if you modify source code.DHawthorne wrote:It should be noted that Joe's examples require a re-compile to turn the debug flag on and off, you can't use precompiler directives on-the-fly.
Isn?t that what this thread is about ? compile time? Thought I did note that:
me wrote:Precompile directives are not evaluated at run-time, they are evaluated at compile time.
Agreed. The example is there to show how the directive works answering the original question posed. A debug channel normally suffices for me too.DHawthorne wrote:I've found it simpler to use SEND_STRING 0 coupled with a regular variable (or virtual device channel). Precompiler directives are a bit kludgy for this kind of application, IMO. -
Joe wrote:
That's what I suspected.Unless there is some other precompile directive wrapped around it (i.e. #IF_DEFINED, #IF_NOT_DEFINED, etc.)
DHawthorne wrote:
I have a regular debug variable used through out the code as a conditon for enabling or disabling my SEND_STRING 0's which is the var nVST_DeBug. I just wanted a lazy mans way of starting debug at start up just so I can see all the initialization stuff that I would miss if I'm slow on the trigger. The #WARN was put there as a reminder that I set it in DEFINE_START and not by setting a variable or channel.I've found it simpler to use SEND_STRING 0 coupled with a regular variable (or virtual device channel). Precompiler directives are a bit kludgy for this kind of application, IMO.
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums