DVDK
unread,Sep 18, 2008, 12:13:58 AM9/18/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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);