<div dir="ltr"><div><div><div><div><div><div><div>Hello Jari and all,<br><br></div>I am following you since LUA started and now I am trying something myself.<br></div>How about placing text on the page that is selected?<br>
</div>Or place text on many or all pages?<br><br></div>Here is an example of placing text on a given page:<br><br>function plugindef()<br>   -- This function and the 'finaleplugin' namespace<br>   -- are both reserved for the plug-in definition.<br>
   finaleplugin.Author = "Herbert van Essen"<br>   finaleplugin.CategoryTags = "Text, Page, System, UI"<br>   return "Place text on page X", "Place text on page X",<br>           "Creates a predefined text on page X."<br>
end<br><br>-- Show user dialog box<br>local dialog = finenv.UserValueInput()<br>dialog.Title = "Place text"<br>dialog:SetTypes("Number")<br>dialog:SetDescriptions("page number:")<br>dialog:SetInitValues(1)<br>
local returnvalues = dialog:Execute()<br>if not returnvalues then return end<br><br><br>local currentprocesspage = returnvalues[1]<br><br>if currentprocesspage < 1 then<br>    print ("Input error: Invalid start page number.")<br>
    return <br>end<br><br>local pages = finale.FCPages()<br>local pageprocesscounter = 0<br><br>   -- Get the collection of PageText objects<br>local pageTexts = finale.FCPageTexts()<br><br>-- Create a new PageText object<br>
local newText = finale.FCPageText()<br>-- Here I'm wildly setting properties in case one of them is missing and essential!<br>newText.FirstPage = 0<br>newText.LastPage = 0<br>newText.PageAssignment = currentprocesspage<br>
newText.VerticalPos = -72<br>newText.HorizontalPos = 1<br>-- newText.HorizontalAlignment = 0 -- Calling this crashes Finale<br>newText.VerticalAlignment = 0<br>newText.PageEdgeRef = true<br><br>-- Create a new string object, set it to the desired text, with Enigma tags for font, size and nfx (whatever that is)<br>
local textObject = finale.FCString()<br>textObject:AppendLuaString("^font(Arial Black,4096)^size(24)^nfx(0)It Works!")<br><br>-- Set the string as the TextBlock on the new Page Text object (and check that it has via the console)<br>
print(newText:SaveNewTextBlock(textObject))<br><br>newText:SaveNew(1)<br> <br></div><div>It doesn't work like that; Can you give me a hint to get this right?      <br></div>How can I get the PageAssignment to load at the currentprocesspage?<br>
</div><div>And what are setting properties for? They are doing nothing as far as I can see.<br></div><div><br></div>Thanks,<br><br></div>Herbert <br><div class="gmail_extra"><br clear="all"><br><br><div class="gmail_quote">
2013/10/17 Dave Foster <span dir="ltr"><<a href="mailto:fozder@me.com" target="_blank">fozder@me.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Jari and all,<br>
<br>
Many thanks for your tips, especially on optimising my string concatenation and using dot properties. I'm still struggling to get my new PageText object to show up, either on screen or in the FCPageTexts collection - here's where I'm at:<br>

<br>
-- Get the collection of PageText objects<br>
local pageTexts = finale.FCPageTexts()<br>
<br>
-- Create a new PageText object<br>
local newText = finale.FCPageText()<br>
<br>
-- Here I'm wildly setting properties in case one of them is missing and essential!<br>
newText.FirstPage = 1<br>
newText.LastPage = 1<br>
newText.VerticalPos = -72<br>
newText.HorizontalPos = 1<br>
-- newText.HorizontalAlignment = 0 -- Calling this crashes Finale<br>
newText.VerticalAlignment = 0<br>
newText.PageEdgeRef = true<br>
<br>
-- Create a new string object, set it to the desired text, with Enigma tags for font, size and nfx (whatever that is)<br>
local textObject = finale.FCString()<br>
textObject:AppendLuaString("^font(Arial Black,4096)^size(24)^nfx(0)It Works!")<br>
<br>
-- Set the string as the TextBlock on the new Page Text object (and check that it has via the console)<br>
print(newText:SaveNewTextBlock(textObject))<br>
<br>
newText:saveNew(1)<br>
<br>
So I get the error<br>
<br>
   -- This function and ..."]:41: attempt to call method 'saveNew' (a nil value)<br>
<br>
so looks like I'm not using saveNew() in the correct way - I've tried using it on the collection (i.e. pageTexts:saveNew(newText)) but that's not it either. Any ideas?<br>
<br>
Cheers,<br>
<br>
Dave<br>
<br>
<br>
<br>
On 16 Oct 2013, at 11:00, <a href="mailto:jwlua-request@jwmusic.nu">jwlua-request@jwmusic.nu</a> wrote:<br>
<br>
>> Next challenge - create some text - this doesn't seem to get anything to show up, either on the page or in the FCPageTexts:<br>
>><br>
>> local newText = finale.FCPageText()<br>
>> newText:SetFirstPage(1)<br>
>> newText:SetLastPage(1)<br>
>> newText:SetVerticalPos(-72)<br>
>> newText:SetHorizontalPos(1)<br>
>> local textObject = newText:CreateTextString()<br>
>> textObject:AppendLuaString("^font(Arial Black,4096)^size(24)^nfx(0)It Works!")<br>
>> newText:SaveTextBlock(textObject)<br>
>><br>
>> Any thoughts?<br>
><br>
> 1. If you do "print(newText:SaveTextBlock(textObject))", you'll see that<br>
> it returns false. Replace "SaveTextBlock" with "SaveNewTextBlock". Since<br>
> you're creating a new page text, you cannot replace a text pool item<br>
> that doesn't exist. You should even be able to do "local textObject =<br>
> finale.FCString()" in this case as well, since "CreateTextString()" will<br>
> never return any text.<br>
> 2. After the Enigma text block has been saved, save the page text<br>
> object. Add "newText:SaveNew(1)" at the end and the text will appear.<br>
<br>
<br>
_______________________________________________<br>
JWLua mailing list<br>
<a href="mailto:JWLua@jwmusic.nu">JWLua@jwmusic.nu</a><br>
<a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu" target="_blank">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a><br>
</blockquote></div><br></div></div>