Statements

Macros are composed of individual statements. Compound statements consisting of two or more statements are enclosed with curly braces { }.  

A statement can be one of the following:

You can stop execution using the stop statement.

If you run a Source Insight command with a dialog box from a macro, the dialog box appears.

Function and variable names are not case sensitive.

Statement syntax is generally the same as in C or Java, except that semi-colons are not required, and are ignored.

Statement Examples

Here are a few example statements:

hbuf = OpenBuf("file.c")    // call internal function OpenBuf

SaveBufAs(hbuf, "filenew.c")  // call internal function SaveBufAs

Select_All    // call user-level command "Select All"

Copy             // call user-level command "Copy"

Line_Up       // call user-level command "Line Up"

x = add2(n)   // call user-defined macro function add2.

Statement Elements

The following table summarizes the macro language statements.

Table 5.1: Macro Statements

Statement

Description

break

Exits a while loop.

if (cond)… else

Tests a condition.

continue

Continues a while loop at the top.

global

Declares a global variable.

return n <or>

return;

Returns n from a function. If a semi-colon follows return, then the nil string is returned.

stop

Stops executing the macro.

strictvars true/false

Turns on or off strict variable decla­rations mode.

var

Declares a function-local variable.

while (cond)

Loops while cond is true.