Returning Values

In order to be of any use, a plugin will need to make modifications to your song or library file. You can, if you want, make these inside your function. However, we don't suggest you do. The API can change in the future. Plus, many settings rely on other basic MMA settings which are easy to miss. Much more robust is the method of creating string(s) with native (or even other plugin) commands and returning the to the main script.

This is easy to do.

Just create a list of commands and push them onto the programs input stack. Examine the hello/plugin.py module for actual code, but as a summary you'll need to:

  1. Create lines for each line of code. In our example we use the array ``ret'' and simply append each line to the array.

  2. Process each of the lines into an acceptable format. This is easy, it's just a matter of converting the string to a list of words. In our example we do:

    ret = [l.split() for l in ret]

  3. Finally, return the value to the input queue.

    gbl.inpath.push(ret, [gbl.lineno] * len(ret))

    here we set the line number of each returned line to be the same as the current line being processed. Note: we're assuming that your plugin has imported ``gbl'' as detailed above.

Bob van der Poel 2016-06-11