After studying a user tool I downloaded a while ago (mmr.js from Warren Porter), I wanted to try to write a tool myself. So I downloaded a Java Script Editor and started to experiment.
After many trials and errors, I decided to first write a template script, that I could use as a starting point for developing a specific tool. When testing it, I discovered the different behaviour of the User Tool Environment, depending of the input type and return format.
So I ended up with 3 different templates: 1 for tools with input type 'Clip Text' (and also 'Clip Text' as the only allowed return format), 1 for input type 'File Text' and return format 'File Text' and 1 for input type 'File Text' and Return Format 'Clip Text'.
You can find these template files in attachment. (After download, change the extention 'txt' to 'js'.)
I used each of these templates to write a user tool, which you will will find in seperate posts.
Any comments are welcome.
P.S. You can find these tools also on my website http://opagust.wordpress.com
Thank you,
will try to make time to check 'em out soon.
Thank you. And I have to thank Rick G for getting me off the ground. Probably the most useful thing I discovered was a way to covert a web page to a js tool with minimal changes to the working part of the script. Browsers have a variety of consoles and debugging tools to quickly identify and fix problems before sharing them with the world.
Hmmm, seems to be a private website and requires a logon and password.
Oops, didn't know that. I thought the logon and password was only necessary for me writing in it. Found the setting and changed it to public. Should be solved now.
I added following function to the templates: GetProp, SetProp, RemoveProp, GetOpt, SetOpt, RemoveOpt
This is not quite a "template" but shows how I now create a Javascript user tool. Starting with something like rubato.html (https://nwc-scriptorium.org/wp/rubato.html) I have access to more detailed error messages and debugging tools when working out the problems. I'm showing it here just as a comparison with the .js version. Once done, many things are already in place to convert it to a user tool (http://www.wjporter.com/nwc/rubato.js).
Thanks to Rick G for pointing me in the right direction.
I discovered some bugs in the new functions SetProp and SetOpt (for operators other then "=") , and also in the function ModPositions (handling accidentals, chords with "pos2" and option "Stem" in Restchords).
Updates will follow as soon as possible.
I corrected the bugs. Furthermore I isolated the common functions in a seperate file 'functions.js' and removed them from the templates. So in the future I won't have to change three templates for 1 change.
See attached files (and don't forget to change the extension into 'js' after downloading.
I discovered and corrected 2 typos in function GetOpt ('optarry' and 'optary' instead of 'optarray').
I added 2 functions to the tool 'Functions': GetLineProp and SetLineProp, wich I used in my new tool 'MetronomeStaff' (see https://forum.noteworthycomposer.com/?topic=8963.msg63692#msg63692)