Doubt regarding this.getTiddler

47 views
Skip to first unread message

Bala Chandra

unread,
May 12, 2018, 7:00:44 AM5/12/18
to TiddlyWikiDev
Say i store values in two tiddlers and i want to add those values through a javascript macro in tiddlywiki. So i tried the following, but it keeps showing that this.getTiddler is not a function. I would like to understand how to do it.

    exports.name = "add";

    exports.params = [{
        name: "var1"
    }, {
        name: "var2"
    }];

    exports.run = function(var1, var2) {

        var t1=$tw.utils.parseFields(this.getTiddler(var1).fields.text);
        var t2=$tw.utils.parseFields(this.getTiddler(var2).fields.text);
        var t3=t1+t2;
        return t3;

    }
})();

PMario

unread,
May 12, 2018, 7:44:50 AM5/12/18
to TiddlyWikiDev

On Saturday, May 12, 2018 at 1:00:44 PM UTC+2, Bala Chandra wrote:
Say i store values in two tiddlers and i want to add those values through a javascript macro in tiddlywiki. So i tried the following, but it keeps showing that this.getTiddler is not a function. I would like to understand how to do it.

    exports.name = "add";

    exports.params = [{
        name: "var1"
    }, {
        name: "var2"
    }];

    exports.run = function(var1, var2) {

        var t1=$tw.utils.parseFields($tw.wiki.getTiddler(var1).fields.text);    // <--- see $tw.wiki instead of this. ..
        var t2=$tw.utils.parseFields($tw.wiki.getTiddler(var2).fields.text);    // may do the trick


BUT .. I didn't test the code.

-m

Bala Chandra

unread,
May 12, 2018, 8:34:35 AM5/12/18
to TiddlyWikiDev
I have seen and tried that .. its not about that .. its just that i want to learn about how i can retrieve information from a tiddler and use it in a macro ...

PMario

unread,
May 12, 2018, 8:38:57 AM5/12/18
to TiddlyWikiDev
Hi,

I did also mess with your code... But forgot to remove the "Quote" marks. .. Have a closer look at my first reply!

-m
Reply all
Reply to author
Forward
0 new messages