[JW Lua] PageText not playing ball

Dave Foster fozder at me.com
Thu Oct 17 12:11:40 CEST 2013


Hi Jari and all,

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:

-- Get the collection of PageText objects
local pageTexts = finale.FCPageTexts()

-- Create a new PageText object
local newText = finale.FCPageText()

-- Here I'm wildly setting properties in case one of them is missing and essential!
newText.FirstPage = 1
newText.LastPage = 1
newText.VerticalPos = -72
newText.HorizontalPos = 1
-- newText.HorizontalAlignment = 0 -- Calling this crashes Finale
newText.VerticalAlignment = 0
newText.PageEdgeRef = true

-- Create a new string object, set it to the desired text, with Enigma tags for font, size and nfx (whatever that is)
local textObject = finale.FCString()
textObject:AppendLuaString("^font(Arial Black,4096)^size(24)^nfx(0)It Works!")

-- Set the string as the TextBlock on the new Page Text object (and check that it has via the console)
print(newText:SaveNewTextBlock(textObject))

newText:saveNew(1)

So I get the error

   -- This function and ..."]:41: attempt to call method 'saveNew' (a nil value)

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?

Cheers,

Dave



On 16 Oct 2013, at 11:00, jwlua-request at jwmusic.nu wrote:

>> Next challenge - create some text - this doesn't seem to get anything to show up, either on the page or in the FCPageTexts:
>> 
>> local newText = finale.FCPageText()
>> newText:SetFirstPage(1)
>> newText:SetLastPage(1)
>> newText:SetVerticalPos(-72)
>> newText:SetHorizontalPos(1)
>> local textObject = newText:CreateTextString()
>> textObject:AppendLuaString("^font(Arial Black,4096)^size(24)^nfx(0)It Works!")
>> newText:SaveTextBlock(textObject)
>> 
>> Any thoughts?
> 
> 1. If you do "print(newText:SaveTextBlock(textObject))", you'll see that 
> it returns false. Replace "SaveTextBlock" with "SaveNewTextBlock". Since 
> you're creating a new page text, you cannot replace a text pool item 
> that doesn't exist. You should even be able to do "local textObject = 
> finale.FCString()" in this case as well, since "CreateTextString()" will 
> never return any text.
> 2. After the Enigma text block has been saved, save the page text 
> object. Add "newText:SaveNew(1)" at the end and the text will appear.





More information about the JWLua mailing list