[JW Lua] PageText not playing ball

Charles O. Lawrence charlesolawrence at bellsouth.net
Fri Oct 18 17:16:31 CEST 2013


Herbert,

 

I think Jari needs to explain what is going on here.

 

If you specify FirstPage and LastPage as 0 like you did, then the SaveNew
argument seems to be the page number where the text will be placed, as you
say.

 

However if the FirstPage and LastPage are set to a range, then the SaveNew
argument seems to need to be 0.  If FirstPage and LastPage are set to the
same non-zero number, then the SaveNew argument seems to need to be that
same number or 0.

 

So, Jari, what is really going on here?!

 

Charles

 

 

 

 

 

From: JWLua [mailto:jwlua-bounces at jwmusic.nu] On Behalf Of Herbert van Essen
Sent: Friday, October 18, 2013 10:11 AM
To: The JW Lua script plug-in.
Subject: Re: [JW Lua] PageText not playing ball

 

Charles,


Thank you for the welcome!

I found it: you have to change the last line in:
newText:SaveNew(currentprocesspage)

Now I can go on...

Thanks,

Herbert

 




Hartelijke groet,

Herbert
(06-29455445)

 

2013/10/18 Charles O. Lawrence <charlesolawrence at bellsouth.net
<mailto:charlesolawrence at bellsouth.net> >

Herbert,

 

Welcome aboard!  I have not tried this yet, but here is what I think you
need to do.  Of course, Jari will set us straight.

 

The PageAssignment does not specify which page you want your text on, but
rather one of three settings 0->ALL pages, 1->ODD pages, or 2->EVEN pages.
To specify an individual page, you have to set BOTH FirstPage AND LastPage
to the individual page number you want, or to a range of pages.  I haven't
figured out how to specify score or parts yet either.

 

I will try it later, but I have to be away from my workstation right now.

 

Charles Lawrence

 

 

 

 

 

From: JWLua [mailto:jwlua-bounces at jwmusic.nu
<mailto:jwlua-bounces at jwmusic.nu> ] On Behalf Of Herbert van Essen
Sent: Friday, October 18, 2013 4:37 AM
To: The JW Lua script plug-in.


Subject: Re: [JW Lua] PageText not playing ball

 

Hello Jari and all,

I am following you since LUA started and now I am trying something myself.

How about placing text on the page that is selected?

Or place text on many or all pages?

Here is an example of placing text on a given page:

function plugindef()
   -- This function and the 'finaleplugin' namespace
   -- are both reserved for the plug-in definition.
   finaleplugin.Author = "Herbert van Essen"
   finaleplugin.CategoryTags = "Text, Page, System, UI"
   return "Place text on page X", "Place text on page X",
           "Creates a predefined text on page X."
end

-- Show user dialog box
local dialog = finenv.UserValueInput()
dialog.Title = "Place text"
dialog:SetTypes("Number")
dialog:SetDescriptions("page number:")
dialog:SetInitValues(1)
local returnvalues = dialog:Execute()
if not returnvalues then return end


local currentprocesspage = returnvalues[1]

if currentprocesspage < 1 then
    print ("Input error: Invalid start page number.")
    return 
end

local pages = finale.FCPages()
local pageprocesscounter = 0

   -- 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 = 0
newText.LastPage = 0
newText.PageAssignment = currentprocesspage
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)
 

It doesn't work like that; Can you give me a hint to get this right?      

How can I get the PageAssignment to load at the currentprocesspage?

And what are setting properties for? They are doing nothing as far as I can
see.

 

Thanks,

Herbert 




2013/10/17 Dave Foster <fozder at me.com <mailto:fozder at me.com> >

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
<mailto: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.


_______________________________________________
JWLua mailing list
JWLua at jwmusic.nu <mailto:JWLua at jwmusic.nu> 
http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu

 


_______________________________________________
JWLua mailing list
JWLua at jwmusic.nu <mailto:JWLua at jwmusic.nu> 
http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20131018/fcb5da36/attachment-0002.html>


More information about the JWLua mailing list