Updated the gist on reading and writing KM variables to avoid dependence on (try ... catch)
error handling when checking whether a variable exists.
// Get a reference to a Keyboard Maestro variable (existing or new)
function kmVar(k) {
var kme = Application("Keyboard Maestro Engine"),
vs = kme.variables,
vks = vs.where({name:k});
return vks.length ? vks[0] :
vs.push(kme.Variable({'name': k})) && vs[k];
}