Macro: 'memory' effect

2 views
Skip to first unread message

DVDK

unread,
Sep 18, 2008, 12:13:58 AM9/18/08
to TiddlyWiki
Hello,

Hope the title is an accurate description.

I recently wrote my own macro/plugin, which works well, but only every
second time. The macro allows to read in a master table from a
tiddler, and displays a 'trimmed' version (selected columns, selected
rows based on column value) of this table in the tiddler where the
macro is called.

I've added the excerpt from the problematic code below, complete with
alert() messages: basically I'm storing the Tiddler text in a variable
originalTable, and then run a stored procedure and assign result to
variable tableHeader. What I see in the alert() output is the Tiddler
being read is correct, but the tableHeder variable is 'null' every
second time. (and then I get an exception calling the split() method
of course)

I don't understand, as the variable are 'local', and I have checked
via alert() the content of master Tiddler and variable originalTable,
just before the macro code ends, and the values seem correct.

Am I missing something fundamental about Javascript or TiddlyWiki
workings here ?

Kind Regards, Dmitri.


// GET HEADER
var originalTable = store.getTiddlerText(tiddlerName);
alert(originalTable);
var tableHeader = /^\|([^\n]*)\|h$/mg.exec(originalTable);
alert(tableHeader);
var headers = tableHeader[1].split("\|");
var newTable = originalTable.substring(0,tableHeader.index);
alert(originalTable);


FND

unread,
Sep 18, 2008, 10:40:06 AM9/18/08
to Tiddl...@googlegroups.com
N.B.:
Coding-related questions should be discussed on the developers group:
http://groups.google.com/group/TiddlyWikiDev/

> I recently wrote my own macro/plugin, which works well, but only every

> second time. [...]


> The macro allows to read in a master table from a tiddler, and
> displays a 'trimmed' version

This is hard to diagnose without an example to play with - can you
provide us with a demo?
Also, this macro would certainly be interesting to other users.


-- F.

DVDK

unread,
Oct 24, 2008, 12:49:06 AM10/24/08
to TiddlyWiki
Done!

And you can find code here, although, as mentined, the 'memory' effect
does not play up.

http://dvdk.tiddlyspot.com/

Ta, DVDK.
Reply all
Reply to author
Forward
0 new messages