Skip to content

Commit e45c2b6

Browse files
chore: autopublish 2023-03-09T17:20:15Z
1 parent 5a6d72e commit e45c2b6

7 files changed

Lines changed: 158 additions & 13 deletions

File tree

docs/library/configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ without having to worry about older configuration files or user settings affecti
124124
configuration.get_parameters(file_name, parameter_list)
125125
```
126126

127-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/configuration.lua#L202)
127+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/configuration.lua#L200)
128128

129129
Searches for a file with the input filename in the `script_settings` directory and replaces the default values in `parameter_list`
130130
with any that are found in the config file.
@@ -144,7 +144,7 @@ with any that are found in the config file.
144144
configuration.save_user_settings(script_name, parameter_list)
145145
```
146146

147-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/configuration.lua#L245)
147+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/configuration.lua#L243)
148148

149149
Saves the user's preferences for a script from the values provided in `parameter_list`.
150150

@@ -163,7 +163,7 @@ Saves the user's preferences for a script from the values provided in `parameter
163163
configuration.get_user_settings(script_name, parameter_list, create_automatically)
164164
```
165165

166-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/configuration.lua#L280)
166+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/configuration.lua#L278)
167167

168168
Find the user's settings for a script in the preferences directory and replaces the default values in `parameter_list`
169169
with any that are found in the preferences file. The actual name and path of the preferences file is OS dependent, so

docs/library/transposition.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ is ignored.
1414
- [diatonic_transpose(note, interval)](#diatonic_transpose)
1515
- [change_octave(note, number_of_octaves)](#change_octave)
1616
- [enharmonic_transpose(note, direction, ignore_error)](#enharmonic_transpose)
17+
- [enharmonic_transpose_default(note, direction, ignore_error)](#enharmonic_transpose_default)
1718
- [chromatic_transpose(note, interval, alteration, simplify)](#chromatic_transpose)
1819
- [stepwise_transpose(note, number_of_steps)](#stepwise_transpose)
1920
- [chromatic_major_third_down(note)](#chromatic_major_third_down)
@@ -71,13 +72,35 @@ Failure occurs if the note's `RaiseLower` value exceeds an absolute value of 7.
7172
| ----------- | ----------- |
7273
| `boolean` | success or failure |
7374

75+
### enharmonic_transpose_default
76+
77+
```lua
78+
transposition.enharmonic_transpose_default(note, direction, ignore_error)
79+
```
80+
81+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/transposition.lua#L214)
82+
83+
Transpose the note enharmonically in Finale's default direction. This function should be used when performing an
84+
unlinked enharmonic flip in a part. Only a default enharmonic flip unlinks. Any other enharmonic flip appears in the
85+
score as well. This code is based on observed Finale behavior in Finale 27.
86+
87+
| Input | Type | Description |
88+
| ----- | ---- | ----------- |
89+
| `note` | `FCNote` | input and modified output |
90+
| `direction` | `number` | positive = up, negative = down (normally 1 or -1, but any positive or negative numbers work) |
91+
| `ignore_error` (optional) | `boolean` | default false. If true, always return success. External callers should omit this parameter. |
92+
93+
| Return type | Description |
94+
| ----------- | ----------- |
95+
| `boolean` | success or failure |
96+
7497
### chromatic_transpose
7598

7699
```lua
77100
transposition.chromatic_transpose(note, interval, alteration, simplify)
78101
```
79102

80-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/transposition.lua#L221)
103+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/transposition.lua#L264)
81104

82105
Transposes a note chromatically by the input chromatic interval. Supports custom key signatures
83106
and microtone systems by means of a `custom_key_sig.config.txt` file. In Finale, chromatic intervals
@@ -103,7 +126,7 @@ allows for downwards transposition.
103126
transposition.stepwise_transpose(note, number_of_steps)
104127
```
105128

106-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/transposition.lua#L260)
129+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/transposition.lua#L303)
107130

108131
Transposes the note by the input number of steps and simplifies the spelling.
109132
For predefined key signatures, each step is a half-step.
@@ -125,7 +148,7 @@ each step is the smallest division of the octave defined by the custom key signa
125148
transposition.chromatic_major_third_down(note)
126149
```
127150

128-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/transposition.lua#L279)
151+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/transposition.lua#L322)
129152

130153
Transpose the note down by a major third.
131154

@@ -139,7 +162,7 @@ Transpose the note down by a major third.
139162
transposition.chromatic_perfect_fourth_up(note)
140163
```
141164

142-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/transposition.lua#L290)
165+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/transposition.lua#L333)
143166

144167
Transpose the note up by a perfect fourth.
145168

@@ -153,7 +176,7 @@ Transpose the note up by a perfect fourth.
153176
transposition.chromatic_perfect_fifth_down(note)
154177
```
155178

156-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/transposition.lua#L301)
179+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/transposition.lua#L344)
157180

158181
Transpose the note down by a perfect fifth.
159182

docs/library/utils.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ A library of general Lua utility functions.
1313
- [calc_alphabet(num)](#calc_alphabet)
1414
- [clamp(num, minimum, maximum)](#clamp)
1515
- [ltrim(str)](#ltrim)
16+
- [ltrim(str)](#ltrim)
17+
- [ltrim(str)](#ltrim)
1618

1719
### copy_table
1820

@@ -177,3 +179,39 @@ Removes whitespace from the start of a string.
177179
| Return type | Description |
178180
| ----------- | ----------- |
179181
| `string` | |
182+
183+
### ltrim
184+
185+
```lua
186+
utility_functions.ltrim(str)
187+
```
188+
189+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L177)
190+
191+
Removes whitespace from the end of a string.
192+
193+
| Input | Type | Description |
194+
| ----- | ---- | ----------- |
195+
| `str` | `string` | |
196+
197+
| Return type | Description |
198+
| ----------- | ----------- |
199+
| `string` | |
200+
201+
### ltrim
202+
203+
```lua
204+
utility_functions.ltrim(str)
205+
```
206+
207+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L185)
208+
209+
Removes whitespace from the start and end of a string.
210+
211+
| Input | Type | Description |
212+
| ----- | ---- | ----------- |
213+
| `str` | `string` | |
214+
215+
| Return type | Description |
216+
| ----------- | ----------- |
217+
| `string` | |

docs/rgp-lua.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ print (math.random(1, 10))
6262

6363
### The 'finale' namespace
6464

65-
All functionality that accesses Finale through the [Lua/PDK Framework](https://pdk.finalelua.com/) resides within the `finale` namespace. (Namespaces use the dot separator.)
65+
All functionality that accesses Finale through the [Finale PDK Framework](https://pdk.finalelua.com/) resides within the `finale` namespace. (Namespaces use the dot separator.)
6666

6767
For example:
6868

@@ -80,6 +80,18 @@ local sel_rgn = finenv.Region()
8080

8181
It also allows for direct interaction with the Lua plugin itself. A full description of available functions and properties can be found on the [finenv properties](/docs/rgp-lua/finenv-properties) page.
8282

83+
### The 'luosutils' library
84+
85+
_RGP Lua_ (starting in version 0.66) optionally preloads an embedded version of the [`luaosutils`](https://github.com/finale-lua/luaosutils) library. This is a library of functions specifically written to help Lua scripts running on Finale. It allows them to interact with the host operating system or the Finale executable in ways that are not directly supported by either the Lua language or the PDK Framework.
86+
87+
For _RGP Lua_ to preload `luaosutils`, set `finaleplugin.LoadLuaOSUtils = true` in your `plugindef` function. _RGP Lua_ does not load the library into a global namespace, however. You must explicitly `require` it into a varable of your choosing similar to what is shown in the following example.
88+
89+
```lua
90+
local osutils = require('luaosutils')
91+
```
92+
93+
The advantage to this approach is that you do not need to change the body of your script if you wish to use an external version of `luaosutils` instead of the version embedded in _RGP Lua_. Simply disable the `LoadLuaOSUtils` option in `plugindef` and the script will pick up the external version instead, provided it is in your `cpath` list. (_RGP Lua_ automatically adds the script’s running folder path to the `cpath` list.)
94+
8395
### The 'socket' namespace
8496

8597
_RGP Lua_ contains an embedded version of [`luasocket`](https://aiq0.github.io/luasocket/index.html). You can elect for it to be available in the `socket` namespace in one of the following ways.
@@ -126,7 +138,7 @@ If you are planning to use the standard installation of `luasocket`, you may be
126138

127139
### The 'utf8' namespace
128140

129-
Lua 5.3 added a standard `utf8` library for parsing utf8-encoded strings. Especially with the addition of SMuFL font support in Finale 27, parsing utf8 characters is an essential requirement for Finale scripts. _RGP Lua_ (beginning in version 0.63) embeds the utf8 library from Lua 5.3 back-ported into Lua 5.2. The [Lua 5.3 Reference Manual](https://www.lua.org/manual/5.3/manual.html) describes how to use these functions. Any code you write for this version of `utf8` is source-compatible with Lua 5.3 and beyond.
141+
Lua 5.3 and higher added a standard `utf8` library for parsing utf8-encoded strings. Especially with the addition of SMuFL font support in Finale 27, parsing utf8 characters is an essential requirement for Finale scripts. _RGP Lua_ embeds the `utf8` library from Lua 5.4.4 back-ported into Lua 5.2. The [Lua 5.4 Reference Manual](https://www.lua.org/manual/5.4/manual.html) describes how to use these functions. Any code you write for this version of `utf8` is source-compatible with Lua 5.4 and beyond. (This version is also backwards compatible with Lua 5.3 code.)
130142

131143
Dialog Boxes
132144
------------
@@ -274,10 +286,14 @@ end
274286

275287
`dumpproperties()` creates a table consisting of all available properties for an object and their values. The keys in the table is the property names; the values in the table are the property values. Use the `pairsbykeys()` iterator (see below) to get the properties sorted in alphabetical order.
276288

289+
The first parameter to the function is an instance of a PDK Framework class.
290+
291+
The second parameter is optional, but can be used to specify if properties from base classes should be included as well. If omitted, properties from base classes are not included.
292+
277293
```lua
278294
page = finale.FCPage()
279295
page:Load(1)
280-
properties = dumpproperties(page)
296+
properties = dumpproperties(page, true) -- true: include base class properties
281297
for k, v in pairsbykeys(properties) do
282298
print (k, "=", v)
283299
end
@@ -325,7 +341,7 @@ end
325341

326342
`eachentry()` feeds a `for` loop with all the note entry objects in a region, without saving them back. Mirror entries are processed with `eachentry()`.
327343

328-
First parameter to this function is the region to process, where you could use `finenv.Region()` to get the current selection.
344+
The first parameter to this function is the region to process, where you could use `finenv.Region()` to get the current selection.
329345

330346
The second parameter is optional, but can be used to indicate the note entry layer(s) to load in Finale. The default is to load all visible layers. These values are available:
331347

docs/rgp-lua/finaleplugin-properties.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ finaleplugin.NoStore = true
4444

4545
Default is `false`.
4646

47+
#### ExecuteAtStartup\* (boolean)
48+
49+
If this value is `true` _RGP Lua_ executes the script during Finale initialization. The script executes after the Finale application has completely finished initializing and is ready for user input. However, there is no guarantee in which order scripts will run if multiple scripts have requested to execute at startup. Some other 3rd-party plugins (notably TGTools, Patterson Plugins, and JWLuaMenu) rearrange Finale's menus at this time, and there is no guarantee in which order they run.
50+
51+
You can check if a script is running at startup with `finenv.QueryInitializationInProgress()`. Only the primary script runs at startup. If the script specifies `AdditionalMenuOptions`, the additional options are added to Finale's plugin menu, but they do not run at startup.
52+
53+
You can set `IncludeInPluginMenu` to `false` to suppress the script from Finale's plugin menu. In this case the script *only* runs at startup.
54+
55+
Example:
56+
57+
```lua
58+
finaleplugin.ExecuteAtStartup = true
59+
```
60+
61+
Default is `false`.
62+
4763
#### HandlesUndo\* (boolean)
4864

4965
Both _JW Lua_ and _RGP Lua_ (by default) automatically run scripts within an undo block named according the undo string returned by the `plugindef()` function. However, it is possible for a script to notify _RGP Lua_ that it will handle undo blocks on its own by setting this value to `true`. One primary reason a script might enable this option is to open a modeless dialog window. Example:
@@ -54,6 +70,30 @@ finaleplugin.HandlesUndo = true
5470

5571
Default is `false`.
5672

73+
#### IgnoreReturnValue\* (boolean)
74+
75+
_RGP Lua_ displays to the user any non-nil value returned by a script, regardless of whether an error occurred. You can suppress this display when there is no error by setting this value to `true`. Example:
76+
77+
```lua
78+
finaleplugin.IgnoreReturnValue = true
79+
```
80+
81+
Default is `false`.
82+
83+
#### IncludeInPluginMenu\* (boolean)
84+
85+
If this value is `false`, _RGP Lua_ does not include the script in Finale's plugin menu. A typical case where your might do this is in combination with `ExecuteAtStartup` set to `true`. This would allow your script to run at startup but not be accessible for the user to run from the menu.
86+
87+
This value applies only to the primary menu option. Any additional menu items specified with `AdditionalMenuOptions` *are* included in Finale's plugin menu.
88+
89+
Example:
90+
91+
```lua
92+
finaleplugin.IncludeInPluginMenu = false
93+
```
94+
95+
Default is `true`.
96+
5797
#### LoadAsString\* (boolean)
5898

5999
Setting this value to `true` tells _RGP Lua_ to load the script into an internal string and then send it to Lua. One reason to do this might be if the script file contains an embedded `NULL` character. This option would cause the Lua interpreter to stop at the `NULL`. It overrides the **Load As String** setting in the [configuration dialog](/docs/rgp-lua/rgp-lua-configuration).
@@ -74,6 +114,16 @@ finaleplugin.LoadLuaSocket = true
74114

75115
Default is `false`.
76116

117+
#### LoadLuaOSUtils\* (boolean)
118+
119+
Setting this value to `true` tells _RGP Lua_ to pre-load its embedded version of `luaosutils` package. Note that you must still `require` it to use it. See the [this link](/docs/rgp-lua#the-luaosutils-library) for more information.
120+
121+
```lua
122+
finaleplugin.LoadLuaOSUtils = true
123+
```
124+
125+
Default is `false`.
126+
77127
#### MinFinaleVersion (number)
78128

79129
The minimum version of Finale that can run the script. The number should match that returned by `finenv.FinaleVersion`. _JW Lua_ reads this value every time a script runs and displays an error message if the running Finale version is too low. _RGP Lua_ reads the value once and omits it from Finale's Plug-in menu if the running Finale version is too low. Examples:

docs/rgp-lua/finenv-properties.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,24 @@ if not success then
188188
end
189189
```
190190

191+
#### QueryInitializationInProgress\* (function)
192+
193+
A function that returns `true` if the script is currently running at Finale startup. You can request your script to run at startup with `finaleplugin.ExecuteAtStartup = true` in your `plugindef` function.
194+
195+
|Output Type|Description|
196+
|------|------|
197+
|boolean|True if Finale startup in progress.|
198+
199+
Example:
200+
201+
```lua
202+
if finenv.QueryInitializationInProgress() then
203+
-- execute expensive global variable initialization here
204+
finenv.RetainLuaState = true -- retain their values so that it only happens once
205+
return
206+
end
207+
```
208+
191209
#### QueryInvokedModifierKeys\* (function)
192210

193211
A function that returns `true` if the input modifier key(s) were pressed when the menu item was invoked that started the script. The input value is any combination of [COMMAND\_MOD\_KEYS](https://pdk.finalelua.com/class_____f_c_user_window.html#af07ed05132bac987ff3acab63a001e47). You can create combinations by adding together the key codes.

src/lib/lib/script-data.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)