On Feb 29, 8:32 pm, skye riquelme <[email protected]> wrote: > I am wanting to change the text in a large numer of tiddlers....they > follow a simple pattern and the editing of the text is quite straight > forward. But I cant get the script to make the changes to the original > tidller........
If you are just doing this on a one-time basis, you should be able to use http://www.TiddlyTools.com/#TiddlerTweakerPlugin which will let you select multiple tiddlers and then replace text, based on a *pattern*. However, if the purpose of your script is to generalize the process for repeated use, then we need to figure out what is wrong with the code. Let's take it a few lines at a time: > <script> > var ref="???"; * I assume that ??? is replaced by some tag value to match using MatchTagsPlugin > var out=""; > var tids=""; * These aren't actually needed, and can be omitted. > var tids=store.getMatchingTiddlers(ref); * This uses the MatchTagsPlugin-defined function, store.getMatchingTiddlers(). You could also write this using a TWCore function, like this: store.filterTiddlers("[tag["+ref+"]]") > for (var t=0; t<tids.length; t++) { > var title=tids[t].title; > var tags=tids[t].tags; > var who=tids[t].modifier; > var text=tids[t].text; * OK... you're unpacking each tiddler's parts into separate variables for easy reference (see note below) > var firstreplace=text.replace("<<tiddler Format##pdf with:'","| > Link|"); * OK... and then make the substitution in the text * and store the result in 'firstreplace' > ........so the text is currently changed as I want.... but then I > tried... > store.saveTiddler(title, title, newtext, who, null, tags,null); > ...but it does not seem to override the old text..... * you never actually defined the variable 'newtext', so it defaults to NULL, so the text in the tiddler is not changed. You need to use the 'firstreplace' variable that already contains the desired new text content. * also, since you only want to change the text content, and leave everything else the same, you don't need to 'unpack' all those separate variables that you defined above (except for 'text', which you use in "text.replace(...)". Instead, you can simply refer to the tiddler properties directly in the call to saveTiddler(), like this: store.saveTiddler( tids[t].title, tids[t].title, firstreplace, tids[t].modifier, tids[t].modified, tids[t].tags, tids[t].fields); * Note that this usage ensures that *only* the text content of the tiddler is changed, and all other existing tiddler values are passed along as-is, including the author, date, tags and custom fields. That should cover it. Let me know how it goes... enjoy, -e Eric Shulman TiddlyTools / ELS Design Studios ---- WAS THIS ANSWER HELPFUL? IF SO, PLEASE MAKE A DONATION http://www.TiddlyTools.com/#Donations note: donations are directly used to pay for food, rent, gas, net connection, etc., so please give generously and often! Professional TiddlyWiki Consulting Services... Analysis, Design, and Custom Solutions: http://www.TiddlyTools.com/#Contact -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.

