Section Reflection
MyrScript reflection Reflective programming or reflection is the ability of a script to examine, introspect, and modify its own structure.
In other words, these functions answer questions like 'What are the properties of a Staff?'
These functions are not included in SMUtils, because rarely needed, and SMReflection.mys file is auto-generated.
- Usage
IncludeOnce("SMReflection") local tab = ReflectionGetFields("Staff") for i=1,getn(tab) do print(tab[i].." = ".. tostring(FrontScore().FirstStaff[tab[i]])) end
Summary
| Return type | Function and summary |
|---|---|
| table | ReflectionGetFields(string obj) Get the properties (fields) of a MyrScript objects, like NumberOfBars for Score object. |
| table | ReflectionGetMethods(string obj) Get the functions (methods) of a MyrScript objects, like EditComments for Score object. |
| table | ReflectionGetObjects() Return list of MyrScript objects: Application, Score, Staff, Instrument... |
| table | ReflectionGetStaticFunctions() Get list of static functions, that are not part of object, like PurgeStringStyle, BinAnd... |
Functions
ReflectionGetObjects()
Return list of MyrScript objects: Application, Score, Staff, Instrument...
- Return
- table: table
ReflectionGetStaticFunctions()
Get list of static functions, that are not part of object, like PurgeStringStyle, BinAnd...
- Return
- table: table
ReflectionGetFields(string obj)
Get the properties (fields) of a MyrScript objects, like NumberOfBars for Score object.
| Parameter | Type | Default | Description |
|---|---|---|---|
| obj | string | Object, e.g. "Score", "Staff", "Instrument" |
- Return
- table:
nilif obj doesn't exist
ReflectionGetMethods(string obj)
Get the functions (methods) of a MyrScript objects, like EditComments for Score object.
| Parameter | Type | Default | Description |
|---|---|---|---|
| obj | string | Object, e.g. "Score", "Staff", "Instrument" |
- Return
- table:
nilif obj doesn't exist