[JW Lua] Read FileInfoText + Display the value of variable
Jari Williamsson
jari.williamsson at mailbox.swipnet.se
Wed Nov 13 22:57:25 CET 2013
On 2013-11-13 18:44, Charles O. Lawrence wrote:
> After loading a couple of FCFileInfoText items in a new default document, I
> tried to use FCPageTexts to read them back. This thinking may be flawed,
> but I thought they would be PageText items as well. The below test script
> shows nothing in the output for the title or composer. I would expect to
> see something within the parentheses in the Enigma Command Tags ^title() and
> ^composer(). What am I missing or getting mixing up and confused?
Data records don't change each other, unless they are subdata in a
larger record. FCPageText is the raw page text connected to the page,
not the printed result of it.
To see the text with expanded text inserts, you need to insert them
manually.
For example in your inner loop, replace the found title tag with the
File Info title string:
if enigmaString:IsEnigmaFileInfoTitle() then
enigmaString.Luastring = titlestr.LuaString
end
After browsing the string for tags, you can transform your
"enigmaStrings" string collection back to a full string with "resultstr
= enigmaStrings:CreateString()".
Another approach would be to skip the splitting/parsing/etc and use the
brute-force method of rawPageText:Replace("^title()",
titlestr.LuaString). But that method would result in strange behaviour
if the File Info text would ever contain the text "^title()".
Best regards,
Jari Williamsson
>
> Thanks,
> Charles
>
>
>
> local fileInfoText = finale.FCFileInfoText()
> local str = finale.FCString()
> local pageTexts = finale.FCPageTexts()
>
> -- save Title and Composer in File Info text inserts
>
> str.LuaString = "My Title is Scripter"
> fileInfoText:SetText(str)
> fileInfoText:SaveAsTitle()
>
> str.LuaString = "My name is Charles"
> fileInfoText:SetText(str)
> fileInfoText:SaveAsComposer()
>
> -- read back and display all page text on page
>
> for pageTexts in loadall(finale.FCPageTexts()) do
> rawPageText = pageTexts:CreateTextString()
> print("Raw Page Text",rawPageText.LuaString)
> local enigmaStrings =rawPageText:CreateEnigmaStrings(true)
> for enigmaString in each(enigmaStrings) do
> print("\tEnigmaString ",enigmaString.LuaString)
> if enigmaString:IsEnigmaFileInfoTitle() then
> print("\t\tFound an EnigmaFileInfoTitle")
> end
> end
> rawPageText:TrimEnigmaTags()
> print("Trimmed Raw Page Text >"..rawPageText.LuaString.."<")
> end
>
>
>
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
>
More information about the JWLua
mailing list