Section Selection

Functions that apply to selected items, or select items.

Summary

Return typeFunction and summary
intApplyToAllSelectedDiagrams(Score score, function processFunc, boolean printedStavesOnly)
Apply a function to all selected chord diagrams (Diagram objects), individually selected or inside range selection.
intApplyToAllSelectedDynamics(Score score, function filterFunc, function processFunc, boolean printedStavesOnly)
Apply a function to all selected Dynamics, individually selected or inside range selection.
intApplyToAllSelectedFXProcessors(Score score, function processFunc, boolean printedStavesOnly)
Apply a function to all selected FXProcessors, individually selected or inside range selection.
intApplyToAllSelectedGraphicLines(Score score, function processFunc, boolean printedStavesOnly)
Apply a function to all selected graphic lines (Picture objects), individually selected or inside range selection.
intApplyToAllSelectedImages(Score score, function processFunc, boolean printedStavesOnly)
Apply a function to all selected images (Picture objects), individually selected or inside range selection.
intApplyToAllSelectedStaffTexts(Score score, function processFunc, boolean printedStavesOnly)
Apply a function to all selected StaffTexts, individually selected or inside range selection.
 JumpAndSelectBar(Score score, int barN, Staff staffBegin, Staff stafEnd)
Jump to the requested bar number and select it, all staves or the requested staff if not nil.
intSMApplyToAllSelectedSymbols(Score score, function processFunc, boolean excludeSpecials, boolean printedStavesOnly)
Apply a function to all selected symbols, individually selected or continous selection.
SymbolSMFirstSelectedSymbol(Score score, Staff staff, boolean ignoreGhostRest)
Returns the first selected symbol (range or individual selection) of the staff or the whole score.
SymbolSMLastSelectedSymbol(Score score, Staff staff, boolean ignoreGhostRest)
Returns the last selected symbol (range or individual selection) of the staff or the whole score.
intSelectIndividualSymbols(Score score, boolean printedStavesOnly)
From a range selection, select individually all selected symbols.

Functions

SMApplyToAllSelectedSymbols(Score score, function processFunc, boolean excludeSpecials, boolean printedStavesOnly)

Apply a function to all selected symbols, individually selected or continous selection.

MSLibrary's ApplyToAllSelectedSymbols(...) function doesn't handle individually selected symbols, and browse from last to first, which is safe for symbol deletion. This customized browse selected notes on all staves from first to last, not convenient for deletion. It can skips ghost rests and special symbols, handles individual and continuous (range) selection.

ParameterTypeDefaultDescription
scoreScore score
processFuncfunction Function with two Symbol and Staff arguments, which returns true (= 1) if symbol has been processed, -1 to stop the process. Other returned values are ignored, process continue to next symbol.
excludeSpecialsbooleanfalseExclude ghost rest, mesure repeat (%, %2, %4), and unison in divisi (//)?
printedStavesOnlybooleanfalseIf true selected symbols on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible.
Return
int: Number of processed symbols
Error
if score is not a Score or processFunc is not a function.
See
SMApplyToAllSymbols

JumpAndSelectBar(Score score, int barN, Staff staffBegin, Staff stafEnd)

Jump to the requested bar number and select it, all staves or the requested staff if not nil.

Try to position the selected bar near the center of the screen, unlike Score.JumpToBar(...) which also doesn't select.

ParameterTypeDefaultDescription
scoreScore score
barNint Bar number, must be lower or equal to Score.NumberOfBars
staffBeginStaffnilIf not nil, first or only staff to select, instead of all staves.
stafEndStaffnilIf not nil, last staff to select
Error
if barN > score.NumberOfBars or staff is not nil and not a Staff.

SMFirstSelectedSymbol(Score score, Staff staff, boolean ignoreGhostRest)

Returns the first selected symbol (range or individual selection) of the staff or the whole score.

This function is more accurate than Staff.FirstSelectedSymbol, handles individual selection, and the 3rd argument allows you to ignore ghost rests.

Note: like Staff.FirstSelectedSymbol, the returned symbol may not be included in actions applied to selection (in Edit menu). If the range selection is after the note head but before next note, it is considered as selected by MyrScript, whereas actions in Edit menu won't apply to it.

ParameterTypeDefaultDescription
scoreScore score
staffStaff If nil, look for selected symbol on all staves and return the one that begins the first (least symbol.Time)
ignoreGhostRestboolean If first selected symbol is a ghost rest, go forward until another kind of symbol is found
Return
Symbol: or nil if selection contains no symbol

SMLastSelectedSymbol(Score score, Staff staff, boolean ignoreGhostRest)

Returns the last selected symbol (range or individual selection) of the staff or the whole score.

This function is more accurate than Staff.LastSelectedSymbol, handles individual selection, and the 3rd argument allows you to ignore ghost rests.

Note: like Staff.LastSelectedSymbol, the returned symbol may not be included in actions applied to selection (in Edit menu). If the range selection is after the note head but before next note, it is considered as selected by MyrScript, whereas actions in Edit menu won't apply to it.

ParameterTypeDefaultDescription
scoreScore score
staffStaff If nil, look for selected symbol on all staves and return the one that ends the last (greatest symbol.Time + symbol.Duration)
ignoreGhostRestboolean If last selected symbol is a ghost rest, go backward until another kind of symbol is found
Return
Symbol: or nil if selection contains no symbol

SelectIndividualSymbols(Score score, boolean printedStavesOnly)

From a range selection, select individually all selected symbols.

In Page mode, if a staff is selected but not printed, the second argument tells if its symbols should be selected individually or not.

ParameterTypeDefaultDescription
scoreScore score
printedStavesOnlybooleantrueThis has no effect in Scroll mode
Return
int: Number of selected symbols, -1 if symbols are already selected individually and no selection is made.

ApplyToAllSelectedDynamics(Score score, function filterFunc, function processFunc, boolean printedStavesOnly)

Apply a function to all selected Dynamics, individually selected or inside range selection.

This browses selected Dynamics on visible (printed) staves from first to last, .

ParameterTypeDefaultDescription
scoreScore score
filterFuncfunction Dynamic are tempo, pedal, ottava or... dynamics. The filter function, if not nil, is here to apply processFunc on the Dynamics you want.
This function accepts on Dynamic argument and returns true to be processed.
You can use DynamicIsTempo, DynamicIsPedal, DynamicIsVelocity or DynamicIsOttava or create your own filter.
nil means no filter, all kind of Dynamics are processed.
processFuncfunction Function with two Dynamic and Staff arguments, which returns true (= 1) if Dynamic has been processed, -1 to stop the process. Other returned values are ignored, process continue to next.
printedStavesOnlybooleanfalseIf true selected Dynamics on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible.
Return
int: Number of processed Dynamics
Error
if arguments are not valid.
Example


 local nb = ApplyToAllSelectedDynamics(FrontScore(), DynamicIsTempo, function(dyn,staff)
    print(dyn.TempoValue); return true
  end, false)
 print(nb .. " tempo found.")

ApplyToAllSelectedStaffTexts(Score score, function processFunc, boolean printedStavesOnly)

Apply a function to all selected StaffTexts, individually selected or inside range selection.

This browses selected StaffTexts on visible (printed) staves from first to last, excluding rehearsal mark (target) texts.

ParameterTypeDefaultDescription
scoreScore score
processFuncfunction Function with two StaffText and Staff arguments, which returns true (= 1) if text has been processed, -1 to stop the process. Other returned values are ignored, process continue to next.
printedStavesOnlybooleanfalseIf true selected texts on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible.
Return
int: Number of processed texts
Error
if arguments are not valid.

ApplyToAllSelectedFXProcessors(Score score, function processFunc, boolean printedStavesOnly)

Apply a function to all selected FXProcessors, individually selected or inside range selection.

This browses selected FXProcessors on visible (printed) staves from first to last. Those attached to instruments are not processed.

ParameterTypeDefaultDescription
scoreScore score
processFuncfunction Function with two FXProcessor and Staff arguments, which returns true (= 1) if FX has been processed, -1 to stop the process. Other returned values are ignored, process continue to next.
printedStavesOnlybooleanfalseIf true selected FXs on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible.
Return
int: Number of processed FXs
Error
if arguments are not valid.

ApplyToAllSelectedGraphicLines(Score score, function processFunc, boolean printedStavesOnly)

Apply a function to all selected graphic lines (Picture objects), individually selected or inside range selection.

This browses selected graphic lines on visible (printed) staves from first to last.

ParameterTypeDefaultDescription
scoreScore score
processFuncfunction Function with two Picture and Staff arguments, which returns true (= 1) if graphic line has been processed, -1 to stop the process. Other returned values are ignored, process continue to next.
printedStavesOnlybooleanfalseIf true selected lines on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible.
Return
int: Number of processed graphic lines
Error
if arguments are not valid.

ApplyToAllSelectedImages(Score score, function processFunc, boolean printedStavesOnly)

Apply a function to all selected images (Picture objects), individually selected or inside range selection.

This browses selected images on visible (printed) staves from first to last.

ParameterTypeDefaultDescription
scoreScore score
processFuncfunction Function with two Picture and Staff arguments, which returns true (= 1) if image has been processed, -1 to stop the process. Other returned values are ignored, process continue to next.
printedStavesOnlybooleanfalseIf true selected images on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible.
Return
int: Number of processed images
Error
if arguments are not valid.

ApplyToAllSelectedDiagrams(Score score, function processFunc, boolean printedStavesOnly)

Apply a function to all selected chord diagrams (Diagram objects), individually selected or inside range selection.

This browses selected chord diagrams on visible (printed) staves from first to last.

ParameterTypeDefaultDescription
scoreScore score
processFuncfunction Function with two Diagram and Staff arguments, which returns true (= 1) if digram has been processed, -1 to stop the process. Other returned values are ignored, process continue to next.
printedStavesOnlybooleanfalseIf true selected images on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible.
Return
int: Number of processed diagrams
Error
if arguments are not valid.