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.www.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