Home AMX User Forum NetLinx Studio
Options

I'm trying to make an include ...

Hi everyone,

I made a program to control a Lighting Device and worked very well. Now I want to create my personal library.

So ... what I have to do?

When I create a *.axi file, I simple cut and paste my original program on the new *.axi file.


Sorry my English ... I hope you understand something :S

Thanks! ;)

2Fast

Comments

  • Options
    ericmedleyericmedley Posts: 4,177
    That's about it.

    You can cut/paste the whole working program into a newly created .axi file and name the file whatever.

    You must then remember to put an 'INCLUDE" statement in your main program file.

    Here's an Example. in this case I've made an Include file to keep track of all Comcast Cablevision channel numbers and names. It is called Comcast_Channels.axi
    PROGRAM_NAME='Horton-110'
    (***********************************************************)
    (***********************************************************)
    (*  FILE_LAST_MODIFIED_ON: 04/05/2006  AT: 09:00:25        *)
    (***********************************************************)
    (* System Type : NetLinx                                   *)
    (***********************************************************)
    (* REV HISTORY:                                            *)
    (***********************************************************)
    
    [b]#INCLUDE 'Comcast_Channels' [/b]
    ***********************************************************)
    (*          DEVICE NUMBER DEFINITIONS GO BELOW          *)
    (***********************************************************)
    DEFINE_DEVICE
    
    etc...
    
    

    You can use either INCLUDE or #INCLUDE. the non-# version is backwards compatability with older AXCESS language. They both do the same thing.
  • Options
    TurnipTruckTurnipTruck Posts: 1,485
    Remember that the .axi file cannot reference devices defined only in your .axs file.
  • Options
    2Fast2Fast Posts: 90
    Thanks for your help ericmedley! :)

    One more question. If I made a project by Visual Architect, can I put my include or only make custom changes in Custom.axi generated?

    I made one project with many metting rooms and for each room I made one file .axi and worked well, my problem with include is on this project generated by Visual Arch...

    Thank you again!

    ;)


    Edit:
    Even when I cut and paste my program in this file the same error returns:[dvTP1] not defined .. but I defined dvTP1 in .axs file. I don't understanting why ....
  • Options
    Spire_JeffSpire_Jeff Posts: 1,917
    Remember that the .axi file cannot reference devices defined only in your .axs file.


    Are you referring the main program, or a module?

    You should be able to refer to a device listed in the main program, but the way that the compiler handles includes, you have to be careful. The compiler essentially (at least to the best of my knowledge) just cuts out the include statement and pastes in the code from the include file. This means that you have to put your include statement below the device definitions if you want to refer to the devices. It also means that you have to be aware of the order of declaring include files if you are referring to variables or devices defined in other includes.

    It would be nice if the compiler consolidated the specific sections before compiling, but as of the last I checked, it doesn't.

    When it comes to Functions and Calls, it does not matter when or where they are declared, because the compiler will search all code for them.

    Jeff
  • Options
    2Fast2Fast Posts: 90
    Thanks Jeff!

    Nice sign :)
  • Options
    ericmedleyericmedley Posts: 4,177
    Edit:
    Even when I cut and paste my program in this file the same error returns:[dvTP1] not defined .. but I defined dvTP1 in .axs file. I don't understanting why ....

    How to do this depends upon a lot of things. (If I'm doing it the way you describe, which I don't too often) I typically put all the device definitions that I'll be using in the include, 'In the include'

    So, for example,

    If you have a

    dvTP_1 = 10001:01:0 in the main program, I'd go ahead and put another definition in the .axi file of the same device but use a differnt (unique) name

    So, in the .axi files
    dvTP_1_include_name = 10001:01:0

    any stuff you do in the include to dvTP_1_include_name will go to dvTP_1.

    As I said, I don't do it the way your attempting very often; only when I know for certain I'm creating a device that will in no way communicate or be called upoin in any other section of the program outside the include file.

    Another more elegant way to do this without all the self-management of where device X is in the include vs. the main is to create a DEV array and manage it that way. That way you only need to fill in the cross referencing data one time and it'll work every time you use the include.

    This speaks to one of the advantages of an inlcude vs a module. In an include you can still use variables from the main program in the include's code. They won't show up as legit variables (turn to the color you chose for variables in your editor preferences, mine are red-bold text) in the text editor, but they still work. That's why I'd suggest creating a DEV array to do all your device stuff. That way you can go pretty seamlessly between the main program and include. There's no magic in this. It's simply because, as was stated earlier in the thread, an include is simply code that gets pasted into the main code upon compliling. It's as if you cut/pasted the code in at the last second before hitting 'build'.

    Hope that helps.
    e
Sign In or Register to comment.