Compiler directives in IF statements
So I guess I am confused with compiler directives, specifically #DEFINE. I have a couple of #DEFINE's in some IF statements and the point is to only define them if a particular variable is true....simple enough. However it seems like at least with #DEFINE's that it runs that line no matter what regardless if it is in an IF statement and regardless if the condition is true or false. Is this correct? I have not done a proof of concept just slimming it down but I am fairly sure that this is happening.
Comments
PROGRAM_NAME='Directive Test' (***********************************************************) (* FILE_LAST_MODIFIED_ON: 03/01/2016 AT: 16:18:44 *) (***********************************************************) DEFINE_DEVICE dvMaster = 0:1:0 vdvTest = 33001:1:0 DEFINE_CONSTANT DEFINE_TYPE DEFINE_VARIABLE INTEGER nTest DEFINE_LATCHING DEFINE_MUTUALLY_EXCLUSIVE DEFINE_START DEFINE_EVENT CHANNEL_EVENT[vdvTest,1] { ON: { IF( nTest ) { #DEFINE DEFINE_ENABLED } #IF_DEFINED DEFINE_ENABLED SEND_STRING 0,"'nTest: ',ITOA( nTest )" SEND_STRING 0,"'Define enabled went through'" #END_IF } } DEFINE_PROGRAMResults:
What are you trying to accomplish?
I think the way you have this coded the DEFINE_ENABLED will always be defined.
The Compiler does not evaluate IF ( nTest ) at Compile time.
Now obviously that will not work, I have to rethink how I am going to approach this.
Define_Function MonitorFunction(Integer nMonitor, Integer nInput) { Switch(nMonitorProtocol[nMonitor]) { Case MONITOR_TYPE_NEC: NECFunction(nMonitor,nInput) Case MONITOR_TYPE_PLANAR: PlanarFunction(nMonitor,nInput) Case MONITOR_TYPE_PANASONIC: PanasonicFunction(nMonitor,nInput) Case MONITOR_TYPE_SAMSUNG_HOTEL: SamsungHotelFunction(nMonitor, nInput) Case MONITOR_TYPE_PANASONIC_NEW: PanasonicNewFunction(nMonitor, nInput) Case MONITOR_TYPE_VIEWSONIC: ViewsonicFunction(nMonitor, nInput) Case MONITOR_TYPE_SHARP_SPACES_AFTER: Case MONITOR_TYPE_SHARP_SPACES_BEFORE: SharpFunction(nMonitor,nInput,nMonitorProtocol[nMonitor]) Default: { Send_String 0,'Unknown monitor type'} } }Of course, this means I can't use display modules... but no real loss there.
So instead of:
You would have:
And so on. For DATA_EVENTS from the devices, you would do something like:
DATA_EVENT[vdvDISPLAY1] { STRING: { IF(GET_LAST(vdvDISPLAY1) == nACTIVE_DISPLAY) { //DO WHATEVER FEEDBACK HANDLING FROM DISPLAY1 } } }It makes for a bunch of code but makes sense if you have a bunch of identical rooms that vary by display model or type of playback device for instance.
Have a config.axi file with your #define statements:
#define Display_Samsung
#define Bluray_Oppo
#define Switcher_ExtronSIS
etc, etc.....
In your main program file, call this axi file first. Then use compiler directives to instantiate your modules if and only if the specific keyword is defined:
#if_defined Display_Samsung
define_module 'Samsung Display'
#end_if
Hope this helps,
erik