[JW Lua] Snippet Exchange: Search and replace in all Page Texts

Bart Visser bartvisser at me.com
Fri Mar 14 14:54:56 CET 2014


Hi,

I've promised to post a few snippets, but thus far I've only did it once. So, here's another one.

This snippet searches for a string or a pattern (in all page-texts) and replaces it with another string.

If you have any comments or ways to improve this, please let me know. I hope it's useful for someone who's just getting into JW Lua.

Cheers,


Bart

function replace_text(search_string, replace_string)
	local page_texts = finale.FCPageTexts()
	page_texts:LoadAll()

	for page_text in each(page_texts) do
		local str = page_text:CreateTextString()
		if str:ContainsLuaString(search_string) then
			str:Replace(search_string, replace_string)
			page_text:SaveTextString(str)
		end
	end
end




More information about the JWLua mailing list