back to main JSFX reference page

JSFX Programming Reference - EEL2 Preprocessor
  • EEL2 Preprocessor

    top  EEL2 Preprocessor

    JSFX (and ReaScript/EEL) in REAPER v6.74+ support the EEL2 preprocessor, which allows generating EEL2 code at compile-time. To make effecient JSFX/EEL2 code, it is often helpful to use named variables rather than memory, and when using a lot of variables it is often harder to write and maintain. The EEL2 preprocessor allows you to generate repetitive code dynamically.

    To use the EEL2 preprocessor, one uses the tags <? and ?> in EEL2 code. Between these tags, a separate EEL2 compiler runs, using a minimal, separate, and non-persistent state, and can generate EEL2 code output using the printf() function.

    Additionally, preprocessor code can suppress passthrough of existing text between its blocks by setting the _suppress variable (allowing for conditional compilation).


    Suppose you have state consisting of 16 values and you wish to clear that state:
      x00=0; x01=0; x02=0; x03=0; x04=0; x05=0; x06=0; x07=0;
      x08=0; x09=0; x10=0; x11=0; x12=0; x13=0; x14=0; x15=0;
    Using the EEL2 preprocessor, you could write this as:
      <? x_size = 16; /* near the start of file, perhaps */ ?>
         // x_size will still be set
         loop(i=0;x_size, printf("x%02d=0;\n", i); i += 1);
    To use _suppress for conditional compilation, one does something along the lines of:
      <? some_config = 1; ?>
      <? some_config < 5 ? _suppress = 1; ?>
      do_some_extra_code() // only compiled if some_config is >= 5
      <? _suppress = 0; ?>
    Note that in the preprocessor the only functions available are built-in EEL2 math/logic functions, and printf().

  •   Home
        Old Versions
        Language Packs
        Theme Development
        Custom Cursors
        JSFX Programming
        Extensions SDK
        Extensions to VST SDK
        Language Pack Template
        User Guide