CHAPTER 5
Macro Language Guide
Source Insight provides an interpreted C-like macro language, which is useful for scripting commands, inserting specially formatted text, and automating editing operations.
Here is an example of a macro function that shows a message box.
macro HelloWorld()
{
msg("Hello World!") // message box appears with "Hello World"
}
Macros are saved in a text file with a
.em
extension. The macro source files can be added to your project, or to any project on the Project Symbol Path, or to the Base project. Once a macro file is part of the project, the macro functions in the file become available as user-level commands in the Key Assignments or Menu Assignments dialog boxes.
There is a library of built-in macro functions for accessing Source Insight objects, such as file buffers, or windows. You can call these built-in functions from your own macro functions.
Basic Syntax Overview
Source Insight’s macro language is designed to be easy to write and require minimal housekeeping. The syntax has been kept fairly simple.
Identifier Names
Identifier names are used to identify variables and functions.
•
Identifier names are not case sensitive. For example,
Open
and open
are the same.
•
Identifier names must begin with a letter A to Z or a to z or an underscore (_), followed by zero or more letters, underscores and digits. Examples are isOpen
,
MyThing2
, and open_file
.
•
Identifier names cannot contain punctuation characters such as @ or % or dot(.).
Indentation and White Space
White space means a tab or a space character. White space is generally ignored, except when it is used to delimit identifiers and operators. Lines are that completely blank are ignored. You can use any indentation style you like, as Source Insight ignores it.
Source Insight 4 User Guide 365