User Tools

Site Tools


This is an old revision of the document!

This page contains some longer scripts that are “feature complete” in terms of their interaction with the Finale user. For shorter script examples, please refer to the page with quick scripts.

Locked Systems Per Page

This script will create page layouts with a predefined number of systems per page, by setting the page break attribute to the measure that should break a page. (Finale will only break a page if the measure with the page break attribute appears first on a system.)

First, the script provides a user input dialog with 3 options:

  • Number of systems per page
  • Start page
  • Max number of pages that should be processed

Please note the syntax for using a static member function in JW Lua, in this case UpdateFullLayout() in the FCStaffSystems class, which can be called using the syntax: finale.FCStaffSystems.UpdateFullLayout().

function plugindef()
   -- This function and the 'finaleplugin' namespace
   -- are both reserved for the plug-in definition.
   finaleplugin.Author = "Jari Williamsson"
   finaleplugin.CategoryTags = "Layout, Page, System, UI"
   return "Locked Systems Per Page", "Locked Systems Per Page",
           "Creates a predefined number of systems per page (by inserting page breaks)."
-- Show user dialog box
local dialog = finenv.UserValueInput()
dialog.Title = "Systems Per Page"
dialog:SetTypes("Number", "Number", "Number")
dialog:SetDescriptions("Number of systems per page:", "Start at page:", "Do it for max no of pages:")
dialog:SetInitValues(6, 1, 999)
local returnvalues = dialog:Execute()
if not returnvalues then return end
local systemsperpage = returnvalues[1]
local currentprocesspage = returnvalues[2]
local maxnoofprocesspages = returnvalues[3]
if (systemsperpage < 1) then
    print ("Input error: Invalid number of systems per page.")
if currentprocesspage < 1 then
    print ("Input error: Invalid start page number.")
local pages = finale.FCPages()
local pageprocesscounter = 0
while true do    
    -- Reload the page layout every time, since the layout contents changes
    if pageprocesscounter > maxnoofprocesspages then break end
    if pages.Count < currentprocesspage  then break end
    -- Create the local-scope variables before any goto:s
    local system = finale.FCStaffSystem()
    local measure = finale.FCMeasure()    
    -- Get the page layout to process
    page = pages:GetItemAt(currentprocesspage - 1)
    local firstsysnumber = page:GetFirstSystem()
    local lastsysnumber = page:CalcLastSystem()
    -- Skip pages with no system layout, such as empty pages    
    if firstsysnumber < 1 then goto continue end    
    if lastsysnumber < 1 then goto continue end
    -- Check if the page contains enough systems to split the contents
    if  (lastsysnumber - firstsysnumber + 1) < systemsperpage then
        print ("Can't continue. Page", page:GetItemNo(), "contains less than", systemsperpage, "systems.")
    -- Load the system where the break should appear    
    system:Load(firstsysnumber + systemsperpage)
    if (system.FirstMeasure < 1) then goto continue end
    -- Change the measure attribute of the first measure to a page break    
    measure.PageBreak = true
    -- Process the next page
    :: continue ::
    currentprocesspage = currentprocesspage + 1
    pageprocesscounter = pageprocesscounter + 1    
jwlua/fullscripts.1377679032.txt.gz · Last modified: 2013/08/28 08:37 by jariw