--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/4df83c11-95fb-4336-b54a-48e420ea503c%40googlegroups.com.
But the important realization is that macros/variables are not all stored in place but are rather context-dependent, i.e. are a collection of variables defined at any of the parents of the current context. Which is probably not news to any of you :) but it's what tripped me up.
Thanks, that's been useful. I had a wrong mental model of how macro storage worked which made me look in the wrong places. In case anyone ever happens to find this while doing the same in the future, I ended up writing this function (to be called from a widget's member function):function getVariables(widget)
{
var node = widget;
var result = [];
while (node) {
if ($tw.utils.hop(node, "variables") ) {
result = result.concat(Object.getOwnPropertyNames(node.variables));
}
node = node.parentWidget;
}
return result;
}
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/72c84bda-3436-4d38-8e30-389dc6688419%40googlegroups.com.
> On Fri, May 29, 2020 at 11:07 PM PMario <pmar...@gmail.com> wrote:> That's OK, if you need it that way. .. But accessing variables, that are _not_ "own properties",> should use the JavaScript prototype chain. So you should be able to directly access a given> variable, if you want to. This should give you much faster access.Just to check if I understand correctly - what you're saying is how to access a specific variable when you already know its name, right?
To get all variables that are defined, the method I posted is the only way, right?
Outside java script there is now the Is variable operator.
Tony