[JW Lua] Help with understanding an error message needed

Robert Wildling robertwildling at gmail.com
Sat May 14 13:49:11 CEST 2016


The documentation offers this example:

-- Process single item:
local staff = finale.FCStaff()
if staff:Load(1) then
   -- (The variable 'myID' must be defined here)
   staff.ItemNo = myID
   -- ('itemno' must be defined here)
   local myBooleanResult = staff:Load(itemno)
end

But what type of object is "itemno"? How do I have to define it???

*Robert M Wildling*

*composer | pianist | music engraver | progammer*
Göllnergasse 19/30 || A-1030 Vienna
ph: +43 676 6089613
@: robertwildling at gmail.com

2016-05-14 13:09 GMT+02:00 Robert Wildling <robertwildling at gmail.com>:

> Hi,
>
> a script loops over all staves of a score and logs some message to the
> console about found attributes, among them the staff's full name. But 2
> weird things happen:
>
> 1. it lists empty entries and I have no idea, where they come from. In one
> case, there was an instrument change (and it seems this script cannot read
> a staff name of an instrument change staff...) and two others from a
> multi-staff instrument (harp). But still there are 5 more logs of staves
> that have no name and are not in the score. I even tried to DeepDelete
> them, but to no avail...
> Is it possible that Finale remembers staves that were in the score at some
> earlier stage, but were deleted via ScoreManager at a later point?
>
> 2. The function is called like this: loadStaves(30). Depending on whether
> there is an attribute sent along, the script decides if it should loop over
> all staves (id == nil ... LoadAll() .. ) or over the specific one (
> Load(id) ). But the "found id" part of the script throws this error:
>
>     -- This function and ..."]:41: attempt to call method 'Load' (a nil
> value)
>
> According to the Class browser, though, the syntax is correct.
> Nevertheless, the Load method  will not even accept a number that is
> entered manually...
>
> Any ideas what I am doing wrong here?
> Thanks!
> Robert
>
>
>
> This is the script:
>
> ****************************
> function loadStaves( id )
>     local staffNameFull = finale.FCString()
>     local staffNameAbbr = finale.FCString()
>
>     if ( id == nil )  then
>         print ( "ID = not given, so get all staves")
>         local staves = finale.FCStaves()
>         staves:LoadAll()
>
>         for staff in each(staves) do
>             staffNameFull = staff:CreateTrimmedFullNameString()
>             staffNameAbbr = staff:CreateTrimmedAbbreviatedNameString()
>
>             print("ItemNo: ", staff:GetItemNo(),
>                     " ---> Staff name full: ", staffNameFull.LuaString,
>                     " - abbr: ", staffNameAbbr.LuaString
>             )
>
>             if ( staffNameFull.LuaString == ""
>                  and staffNameAbbr.LuaString == ""
>                  and staff:GetItemNo() == 30)
>             then
>                 print("      empty... delete this... or not?");
>                 local bool = staff:DeepDeleteData()
>                 print(bool)
>                 staves:SaveAll()
>             end
>         end
>
>    else
>        print("ID = ", id, ", process only that staff, type = ", type(id))
>        local staff = finale.FCStaves();
>        if staff:Load(id) then
>            staffNameFull = staff:CreateTrimmedFullNameString()
>            staffNameAbbr = staff:CreateTrimmedAbbreviatedNameString()
>            print("Staff name full: ", staffNameFull.LuaString, " - abbr:
> ", staffNameAbbr.LuaString )
>         end
>     end
> end -- end function loadStaff
>
> loadStaves(29)
> ************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20160514/185ae0bf/attachment.htm>


More information about the JWLua mailing list