Danfoss MCO 305 Design Manual page 174

Programmable motion controller
Hide thumbs Also See for MCO 305:
Table of Contents

Advertisement

MCO 305 Design Guide
__ How to Program __
#ifdef, #ifndef, #if
Program code can be conditionally compiled using any of the following statements:
#ifdef name - If "name" has been defined using #define.
#ifndef name - If "name" has not been defined using #define.
#if integer-expression - If "integer-expression" evaluates to non-0.
These can be followed by any number of statements and then #endif.
#else can also be used as is shown in the following example.
Example:
#ifdef INCLUDE_DEBUG
PRINT "Position = ",apos
PRINT "Velocity = ",avel
#endif
#ifdef START_AT_0
start = 0
#else
start = 1
#endif
#if 0
This will never be compiled.
#endif
#if 1
This will always be compiled.
#endif
#define OPTION 1
#if OPTION > 2
This will be compiled only if OPTION is greater than 2.
#endif
If #if is used, then #elif (for "else if") can be used.
Example:
#define CUSTOMER_A 1
#define CUSTOMER_B 2
#define CUSTOMER CUSTOMER_B
#if CUSTOMER == CUSTOMER_A
Compile this for customer A.
#elif CUSTOMER == CUSTOMER_B
Compile this for customer B.
#else
Otherwise compile this.
#endif
174
®
MG.33.L5.02 – VLT
is a registered Danfoss trademark

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents