See it online at
http://www.multieditsoftware.com/TheDev/v07_i04_2010.htm
Multi-Edit Newsletter, May 2010

  May 2010
"The Developer News"

 

 


 

Holiday Closure
scroll to top of page here

Introduction from the CEO

file documents image Hello and welcome to the May Developer News!

- Chad Williams


Hello and welcome to the May edition of the Developer News!

In this issue I'd like to take a moment to let everyone know that we are still working hard towards the completion of Multi-Editx. In the coming weeks we'll provide more information regarding this new build, what to expect and when to expect it! At this time we expect to begin our Beta phase in June so be sure to keep your eyes peeled and watch for next month's edition for all the details.

Despite being hard at work with our Alpha phase and responding to customer support issues, Clay Martin has provided a great article on how to add macros to a template. If you are currently utilizing the Templates within Multi-Edit, don't miss out Clay's article for steps and examples on adding more power to your Templates.

Finally I would like to end with a quick note on our upcoming holiday closure. On May 31st 2010 we will be observing the Memorial Day holiday and our offices will be closed. We will resume our normal operating hours on Tuesday June 1st. If you require any assistance with placing an order you can always select from one of our many resellers. A complete list of authorized Multi-Edit resellers can be found at: http://www.multiedit.com/reselinx.php


Until next time,

Chad Williams, CEO
Multi Edit Software, Inc.

chadw@multieditsoftware.com

 

website placement image
scroll to top of page here

Support Notes

file documents image Adding Macros to Templates



Clay Martin

Templates allow you to save a lot of keystrokes. In a previous article we talked about getting more out of templates using some of the metacommands. In this article we will look at another of the metacommands that allow you to execute a CMAC macro.

Once you have invoked the macro with the template it could present a dialog so that you can select options for what will be expanded. Or it could also look at the state of the editor, such as, is a block of text selected? ; is the cursor at the end of a line? ; is the file empty? Based on the state of the editor or the user's choices the macro can provide different output.

In this example we will create a template that executes a macro that will do different things based on the editor's state. What we want to happen is this. If a block is selected we will place comment start and end around the block and mark the beginning and end with "debug start" and "debug end". For this example we will overlook the possibility that there may be comments enclosed in the block that would mess with the block being commented out. Ideally we would want to change any open/close comments enclosed in the block into some other character(s), and also have another macro that would remove the comments from the block and restore the interior comments.

If we were being really slick, we would not hardcode the comment characters, but pull them from the language definition. Now the other functionality for this template-macro is that if the user did not select a block of text, we will just add an end of line comment to the end of the current line like: " //DEBUG". So our finished macro will allow us to comment out a block of code, while marking it so that we could locate these blocks later by searching for "debug", and just mark a line of code as debug, again so we can find and remove this temporary debug stuff later.

First the macro, we will place it in our tools.s file (you know the CMAC file where you keep all the tools you write):



void debugit( ) trans
{
  /* save the current state */
  int oldrefresh = REFRESH;
  /* turn off for speed */
  REFRESH = 0;
  /**Set undo so user can undo the change**/
  PUSH_UNDO;

  if ( BLOCK_STAT != 0) {             //have a block selected
        /**Get the starting and ending lines of the text to box**/
        int startline = BLOCK_LINE1;
        int endline = BLOCK_LINE2;
        /* add the end comment */
        GOTO_LINE(endline);
        EOL;
        CR;
        TEXT("DEBUG END */") ;(
        /* add the starting comment */
        GOTO_LINE(startline)(;
        UP;
        EOL;
        CR;
        TEXT("/* DEBUG START") ;
        /* put the cursor at the beginning of the block */
        DOWN;
        GOTO_COL(1);
  }
  else {        // no block selected
        /* go to the end of the current line */
        EOL;
        TEXT(" //DEBUG ") ;
        /* reposition the cursor at the begining of the line */
        GOTO_COL(1);
       }
 /* restore state and redraw the screen */
 REFRESH = oldrefresh;
 REDRAW;
}//debugit

Compile the CMAC file, no errors right? Now we need to create the template. Go to Tools | Edit Templates. Press the insert button. Lets name the template debugit and press OK.

Then in the result box add this:

<!tools^debugit>

The "tools" tell ME where to find the macro, "debugit" is the name of the macro and we use the "^" character to separate the two just like you would using Macro | Run. The <!  > is the format of the run macro metacommand. Close the edit template dialog, and we are ready to go. So select some code and press ALT+F9, then start typing "debugit" depending on your templates' names you should see the template debugit highlighted before you type the b in debugit. Then hit enter. You should see:

/* DEBUG START
selected code;
selected code;
selected code;
selected code;
DEBUG END */

Now try putting your cursor on a line of code and press ALT+F9, then start typing "debugit", then Enter as before. You should see:

Some debug code; //DEBUG

So now you can supercharge your templates by executing macros from within them. Of course if your macro does not require a block to be selected, you can have your template space expand. You can find out more about writing your own macros by looking over the fine set of tutorials written by David Deley located in the forums:

http://forums.multiedit.com/viewtopic.php?f=9&t=359



Support Staff
Multi Edit Software, Inc.

support@multieditsoftware.com


Send any support questions or Bug Reports to
support@multieditsoftware.com
or by using Help | Create Bug Report from within Multi-Edit.
You may also post your questions on our support forums at: http://www.multiedit.com/forums

 

 

If your e-mail application has trouble viewing this
in an HTML format,
you can also view it online at:
http://www.multieditsoftware.com/TheDev/v07_i04_2010.htm

 
scroll to top of page here  
website placement image

 
All other brands and products are trademarks of their respective holder(s).
Copyright © 2010 Multi Edit Software Incorporated. All rights reserved.