Special features

Line continuation

In ipt a line continuation is allowed everywhere and is considered as a single whitespace character. In Igor Pro 9 a line continuation is allowed in most places but not all places. There is no documentation where those places are.

Comma fixing

ipt can fix missing or superfluous commas in most places:

// before
print a b, c

// after
print a, b, c

Code indentation

ipt format will fix code indentation:

Function test()
if(1)
print "Hello"
endif
End
Function test()
    if(1)
        print "Hello"
    endif
End

Alignment

ipt format will align code to the same vertical column:

variable   abc = 1         // set to one
string     def = "test"    // set to test
WAVE/Z/C/D wv  = {1, 2, 3} // init
variable   abc
string    &def
WAVE/Z/C/D wv
Constant    ABC         = 1
StrConstant SOME_STRING = "null"

Never touches original line continuation

ipt format keeps the original line continuation from the source code and will also align the continued lines.

A snippet from MIES
ASSERT_TS(ParamIsDefault(prop) + ParamIsDefault(var) + ParamIsDefault(str) == 2                 \
          || (!ParamIsDefault(prop)                                                             \
              && (((prop == PROP_MATCHES_VAR_BIT_MASK || prop == PROP_NOT_MATCHES_VAR_BIT_MASK) \
                   && (ParamIsDefault(var) + ParamIsDefault(str)) == 1)                         \
                  || (prop == PROP_GREP && !ParamIsDefault(str) && ParamIsDefault(var))         \
                  || (prop == PROP_WILDCARD && !ParamIsDefault(str) && ParamIsDefault(var))     \
                 )),                                                                            \
          "Invalid combination of var/str/prop arguments")

Intentional compile error trigger

A common way to provoke a compile error in procedure code is to use an invalid identifier for #define starting with * and then having the error message. These triggers are ignored by ipt and won’t create errors.

// in main Procedure file:
#define COVERAGE
#define THREADED

// at the top of a code file:
#if defined(COVERAGE) && defined(THREADED)

// compile error trigger variant 1
#define **error** Don't allow coverage with multi thread together
// compile error trigger variant 2
#define *** Don't allow coverage with multi thread together

#endif

Disabling formatting for specific code regions

You can turn off code formatting by adding the comment // IPT_FORMAT_OFF in a single line that does not contain any other code. Doing this will keep all original formatting until a single line with // IPT_FORMAT_ON was found.

Before
if(var)
    print 1,2,     3
    // IPT_FORMAT_OFF
    print 1,2,     3
endif

print 1,2,     3
// IPT_FORMAT_OFF
print 1,2,     3
// IPT_FORMAT_ON
print 1,2,     3
After formatting
if(var)
    print 1, 2, 3
    // IPT_FORMAT_OFF
    print 1,2,     3
endif

print 1, 2, 3
// IPT_FORMAT_OFF
print 1,2,     3
// IPT_FORMAT_ON
print 1, 2, 3

For good style it is recommended to always add a matching // IPT_FORMAT_ON for each // IPT_FORMAT_OFF.

Type flag checks

ipt does check all wave and function flags if they are used in a valid combination. Invalid ones are reported as errors.

// will be reported as an error, there are no complex text waves
WAVE/C/T wv
// will be reported as an error, you are specifying a 32bit and 64bit wave
// at the same time
WAVE/I/L wv
// will be reported as an error, they are no integer text waves
WAVE/I/T wv
// will be reported as an error, you can only use one of them
WAVE/Z/ZZ wv

// this is fine
WAVE/Z/C/U/I wv
// this is fine
Function/S funcName()
End

// this is an error
Function/A funcName()
End

Automatic removal of code marker

If you regularly execute code in the Igor command line, you have probably seen the character at the start of your command in the history output:

print 123
  123

If you copied this character by accident into your code file, ipt does automatically remove it to have a clean output as it does nothing.

Automatic case fixing

ipt does automatically fix the casing of specific parts in the code to have a uniform output:

  1. All operation and argument flags are changed into upper case:

    // from
    Make/free wv
    
    // into
    Make/FREE wv
    
  2. All primitive types like int64, variable and string are changed into lower case:

    // from
    INT64 num
    VARiable var
    strING str
    
    // into
    int64 num
    variable var
    string str
    
  3. All complex types like WAVE, DFREF, FUNCREF and STRUCT are changed into all caps.

  4. All language keywords are changed into their documented casing (in most cases this is PascalCase). For example function into Function and MACRO into Macro.

Automatic function and macro ending fix

In Igor Pro you can end functions and macros with End or EndMacro and it doesn’t complain if the wrong one was used. ipt does fix this so that all functions always end with End and all macros end with EndMacro.