NS3 Macros
Jeff
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
J
0
Comments
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..
Or I copy and paste a channel line up, I can go through and format them into a constant array by making a macro.
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.
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.
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.
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
Paul