IF_Defined
jjames
Posts: 2,908
Okay, I need some real world examples of IF_DEFINED, and want to know the limitations of it.
I can use it on variables? Devices? Arrays? How do I use it? The "Help" seems a bit . . . unhelpful?
I can use it on variables? Devices? Arrays? How do I use it? The "Help" seems a bit . . . unhelpful?
0
Comments
In my module I delcare: The defines are just any arbitrary name you make up and now that name is defined.
The include files contains section of code I want to pull into my module which could be constants, variable , functions or the entire file or any part of the file if you want.
In the one file I'm including I do: In the other file I'm including I do: I the first example the code is excluded because I don't define VAV_AUTOUPDATE_INCLUDE until after I do the include which I think means I really didn't need to define afterwards. I may have realized that back then and was just to lazy to remove it. That was the only example with #IF_DEFINED used with includes probably because it doesn't really make sense.
The second and for me the most common use is to do the include after you define a name.
Other that that #IF_DEFINE can be used in include file around device declarations so they can be listed in the include file and the main file so you have them in both files but you don't get a compiler error since they are only included in the first instance.
In the include file: This should also allow these devices to be high lighted and auto-completed in the local code even though they are really read into the compiler in your main code.
Ok, never thought of that. One of the reason's I don't use a lot of include files is because I still need the color coordination and auto-complete to be efficient. This will help out a lot..
Just don't show examples out of your viewstat schedule module! I'm still not quite sure how it compiles. Throw an include in, it calls two modules, one of which includes the original include you included in your main code! All them full of #IF's and #IF_NOT's.
Kevin D.
I don't presently use the #IF_NOT's or #IF_'s to actually include vars, constant, function etc in my .axi files for the editor high-lites and auto-complete but in giving it some more thought last night when I should have been sleeping made me wonder why I wasn't. A simple #DEFINE Global Declarations at the begining of the main code and then I can repeat any var, constant, structure, function I want in any include file for referance, hi-lighting & auto-complete and it will only get pulled in by the compiler once after placing the #IF_NOT's where needed.
I'll be damn.. I was confused in the begining and after I got it working I never tried removing the include from my main code. What do you know, it still compiled after I removed it. Well the good news is your IFs and IF_NOTs will still let it compile if you double up your includes..
Kevin D.
Something like this:
DEFINE# dvDTR_LGR = 05001:01:00
#IF_DEFINED dvDTR_LGR
dv_DTR[]=
{
dvDTR_LGR
}
#END_IF
Somewhere in code.....
#IF_DEFINED dv_DTR
DATA_EVENT[dv_DTR]......
That's kinda what I was looking for. But if all these definitions only work for includes, etc. I'll have to change the way I do code. *Sigh*
This may also work using #IF_DEFINED
Play around and see what happens.
1. Debugging on different model master. My testbed is a NI-3100, but I have many real-world NI-700s. Would also be useful if I had to deal with NXI masters.
2. Configuring a generic program for specific installations.
3. Managing common include files where the compiler can't cope with it being included from more than one file. ("Device/variable already declared..." errors.) Particularly useful on my global file. Roger McLean
Swinburne University