Published: March 24, 2014Last Updated: June 6, 2017

Variable Dumper Macro

Macro Monday – a new macro to dig into every Monday!

For quick and simple debugging of code at runtime, I will often use a print or
log statement to check what a variable is set to. This macro quickly creates the
boilerplate for the print statement according to the language I am currently
editing.

## Examples

Given this piece of JavaScript code:

~~~javascript
window.myvariable = someFunction(x, y, z);
~~~

if you place your caret anywhere in the *myvariable* word, then invoke the
macro, you’d see a *console.log()* statement on the next available line:

~~~javascript
window.myvariable = someFunction(x, y, z);
console.log(‘window.myvariable: ‘, window.myvariable);
~~~

and when using Python code, the macro would generate a *print()* statement
instead:

~~~python
window.myvariable = someFunction(x, y, z)
print(‘window.myvariable: %r’ % (window.myvariable, ))
~~~

### Installation

To install the macro simply hit the download button below, then drag the downloaded
file into your [Komodo toolbox](https://docs.activestate.com/komodo/latest/toolbox.html).
Once in your toolbox double click the macro to activate it. The macro will
automatically activate itself the next time you start Komodo, you only need to
do this manually the first time.

### Related Materials

* [Komodo Developer Extension](https://community.activestate.com/node/1824)
– play around with JavaScript or Python code in the context of the Komodo window
* [Komodo Macro API](https://docs.activestate.com/komodo/latest/macroapi.html)
– to programatically interact with the Komodo editor
* [Editor API](http://www.scintilla.org/ScintillaDoc.html)
– the Komodo editor provides a wrapper around the Scintilla API

Todd Whiteman

Todd Whiteman

Todd Whiteman is the Development Lead for Komodo IDE. He works adeptly with Mozilla, Python and JavaScript to ensure that Komodo IDE is the IDE of choice for development teams. Todd has been working on Komodo IDE for nearly 6 years, adding components such as the Vi Key Bindings, Distributed Source Code Control, 64-bit Linux builds as well as Remote SSH support into Komodo IDE.