Home AMX User Forum NetLinx Studio

NS3 Macros

JeffJeff Posts: 374
OK, so now I have macros. What are people using them for, any ideas? I've never been a programmer outside of AMX, so this is an entirely new concept for me and I'm having trouble coming up with a use for them.

J

Comments

  • bcirrisibcirrisi Posts: 148
    I use the same format and variables for most functions and buttons presses I do, so I have a macro that creates them for me. Also saved some channel lineups in there.

    Example of my Button Macro:

    //
    BUTTON_EVENT[dvTP, ]
    {
    PUSH:
    {
    STACK_VAR INTEGER nBtnIdx, nPnlIdx
    nBtnIdx = GET_LAST()
    nPnlIdx = GET_LAST(dvTP)

    //

    }
    }

    Now just fill in the blanks..
  • jjamesjjames Posts: 2,908
    I use functions all the time for formatting code, variables, etc. Say I want to insert a prefix to a bunch of constants, I can make a macro that does that.

    Or I copy and paste a channel line up, I can go through and format them into a constant array by making a macro.
  • How about :
    Build Active System -> File Transfer

    I have one hot key to compile then bring up the file transfer window.
    (I got that from that other control company.)
  • ericmedleyericmedley Posts: 4,177
    How about :
    Build Active System -> File Transfer

    I have one hot key to compile then bring up the file transfer window.
    (I got that from that other control company.)


    I still always do the 'right click' over the code to build active system. And I typically have 4 or 5 systems in file transfer. I need to look at which one is active so I don't accidentally send the code and reboot the wrong master.

    I've never really used any macros myself.
  • DarksideDarkside Posts: 345
    Without drifting too far from the thread topic, I must applaud NSX3. This is such a great leap forward in my view. Awesome new features and bug fixes. Congrats to all.

    It seems that if you create a macro and utilise autocomplete, the macro does not accept the entry.

    For example, if you start recording and want to create, say, a basic define_call chunk of code for example, you would obviously type:

    de (for define) and autocomplete would allow you select define_call. If you hit enter, the editor sees the whole define_call entry, but it is not recorded in the macro - only de.
  • DHawthorneDHawthorne Posts: 4,584
    Interesting ... I never use "Build Active System" at all. I compile all my modules separately, and only the ones that actually changed, then the main program. I find it quicker and easier in the field not to have to wait for it to work through every component of the program when I only made a minor change.

    I would use macros more for complex repetitive editing, for example, going through the code and replacing all the send commands to a particular device with a function call; anything that can't easily be done with a simple search-and-replace.
  • ROOROO Posts: 46
    Macro - Insertion and formating strings

    I tend to document my routines prior to coding, so I've found the copy - paste and format possibilities of the Macro feature very handy.

    Paste a list into the code,
    PC39
    PC40

    copy the struture assignment, sCntrDev.cDevice_Name[156] =

    position the cursor in front of the first line, then turn on the macro record -
    , paste,
    sCntrDev.cDevice_Name[156] = PC39
    PC40
    add single quote since the paste leaves the cursor at the end of the paste
    sCntrDev.cDevice_Name[156] = 'PC39
    PC40
    , endofline add single quote,add ; HOME, down arrrow - stop macro record.
    sCntrDev.cDevice_Name[156] = 'PC39';
    PC40

    Then all I have to do is hit the play current macro, and it walks down the list making the assignments. With the renumber command, I change all the array values in sequence and I have everything done in a few minutes.
    sCntrDev.cDevice_Name[39] = 'PC39';
    sCntrDev.cDevice_Name[40] = 'PC40';

    Haven't tried anything real complex yet, but it's a win already.

    ROO
  • a_riot42a_riot42 Posts: 1,624
    If you need macros to write code then you are writing too much code :)
    Paul
Sign In or Register to comment.