--[[------------------------------------------------------------------------- This NWC user tool can be used to move all instances of an object type to a note that follows it, skipping any rests and bar lines between them. $NWCUT$CONFIG: FileText $ This script supports both clip and file modes, but default to file mode --]]------------------------------------------------------------------------- nwcut.setlevel(0) local mode = (nwcut.getprop('Mode') == nwcut.const.mode_FileText) and 'file' or 'clip' local objType = nwcut.prompt('Enter an object type', '*','TremoloSingle.ms') local objTypeLn = '|User|'..objType local l = objTypeLn:len() local foundCount,changeCount,deleteCount = 0,0,0 local targets = {Note=1,Chord=1,RestChord=1,AddStaff=1} local obj = false local priorItem = false local outObj = function() if not obj then return end if obj ~= priorItem then changeCount = changeCount + 1 end foundCount = foundCount + 1 nwcut.writeline(obj) obj = false end for item in nwcut.items() do local t = nwcut.objtyp(item) if (t=='User') and (item:sub(1,l) == objTypeLn) then if obj then deleteCount = deleteCount+1 end obj = item else if targets[t] then outObj() end nwcut.writeline(item) end priorItem = item end outObj() nwcut.warn(([[ Results for %s (%s mode) Objects found: %d Objects moved: %d Objects deleted: %d ]]):format(objType,mode,foundCount,changeCount,deleteCount))