question about axi files
Charles Law
Posts: 72
Hello Everybody,
Writing include axi files in different places may have different outcomes and sometimes compilation error.
Where should I put the include axi files in my program? any rules?
As there may have variables, constant, define call,etc inside different axi files, how the compiler handle them?
Thanks in advance for any inputs.
Cheers
Charles
Writing include axi files in different places may have different outcomes and sometimes compilation error.
Where should I put the include axi files in my program? any rules?
As there may have variables, constant, define call,etc inside different axi files, how the compiler handle them?
Thanks in advance for any inputs.
Cheers
Charles
0
Comments
Exact, but FUNCTIONS will be found wherever they are included...
Typically the problem with include files is the order of inclusion depending on the cross-references between them. It is easier if one creates either:
- "type" axi, that is, an axi that contains some constants, a struct and functions that act on the struct (with proper DEFINE_XXX). For example I have such an include for a DateTime_Type, with functions like DateTime_now, DateTime_AddSeconds, DateTime_AddWeeks, etc...
This type of include files goes to the top of the code, since they do not reference any variable or device (they are self contained, you can actually COMPILE them successfully on their own). In the code, you use variables of said type.
- "section" axi, that is, an axi that contains all of the device event handlers for a touch panel, or all of your constants, etc (this is the approach AMX used in DXP-HT 1.0 I think). You include these axi in the relevant section of your code.
Once you start mixing up things, it quickly gets complicated and you may need to break up files to make them compile without too much headaches.
Hope this helps
Fred
I disagree. A DEFINE_CALL can be placed in the .axs file or in any include file and the .axs file or any include file can call that call regardless of where the includes are included or in what order the includes are included or in what order the calls are defined.
If there is a variable in a program that is not in scope due to the order or placement of the includes then one option is to write a DEFINE_CALL in the include that is in question to get or set the value of that variable.
That's the part I respectfully disagree with. You don't need to define them before they are called. All you need to do is define them, period, end of story.
For example, if you define DEFINE_CALL #1 and DEFINE_CALL #1 calls DEFINE_CALL #2 and DEFINE_CALL #2 is defined after DEFINE_CALL #1, the code will compile and run just fine. How much wood can a wood chuck chuck....
Fred
[Edited to add the NetLinx precision, never done Axcess so can't comment]
Thanks for the correction.
Other than that, I agree with DHawthorne - to be safe, always declare your sections in Netlinx include files, AND you should also have one after the #INCLUDE line just in case the include changes to a different section than the one it's declared in. (Of course, if it's the last thing in your code this will not be necessary.)
Also, don't ever put a } or ; on the #INCLUDE line, these can cause problems...
Finally, I also prefer putting includes at the top of code, but once you understand the other rules it's really a matter of personal preference.