Introduction
When you want to create a macro that will serve as a sophisticated template of your code, you usually need to do something like this:
ActiveDocument.Selection = _
"list<" + CType + "*>::const_iterator i, iEnd = " + CName + ".end();"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "for(i = " + CName + ".begin(); i != iEnd; i++)"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "{"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "}"
ActiveDocument.Selection.NewLine
This is terrible to write and even more terrible to understand and fix, especially when you have to do long code macro. Better looking way would be to do this:
ActiveDocument.Selection = _
"list<" + CType + "*>::const_iterator i, iEnd = " + _
CName + ".end();" & vbLf & vbLf & vbLf & _
"for(i = " + CName + ".begin(); i != iEnd; i++)" & vbLf & vbLf & _
"{" & vbLf & vbLf & _
"}" & vbLf & vbLf & _
However, as comfortable as it is to look upon, converting regular text to this form does take time.
Automation
This is where the little MacroText application becomes useful. Let's say I want to convert a code - template list loop - to a macro template:
Now all I need to do is to press the "Convert" button and walla:
Now all that is left to do is to copy the converted text to a macro, add the appropriate msgboxes to gather info, for example, let's say they are DataType
and ListName
. So we do the following from VC++:
Replace int
with & DataType &
. Replace m_List
with & ListName &
.
And here is the result:
"list<" & DataType & ">::const_iterator i, iEnd = " & _
ListName & ".end();" & vbLf & "" & vbLf & _
"for(i = " & ListName & ".begin(); i != iEnd; i++)" & vbLf & _
"{" & vbLf & _
"}"
For whom
The program is especially useful for creating template macros - The macros in which you have to repeat the same type of code over and over with slight changes. While some add-ins come with "templates" ability, I found them all lacking, either in execution and in comfort of use, compared to the macros I can make with MacroText.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.