Skip to main content
Topic: Writing user scripts (Read 6137 times) previous topic - next topic

Writing user scripts


Is there any tutorial/documentation on this subject or is it a matter of deducing stuff from the various PHP examples?  Any info very welcome!

Andrew S.

Re: Writing user scripts

Reply #1
G'day Andrew,
depends on what ya wanna do.

If you want to create your own tools to do specific jobs then you need to have some programming skills in a language that will allow you to manipulate the 'clip text'.

E.G:
  • The 'official' support is via a version of php that is installed with the user tool starter kit available from http://ntworthy.com/nwc2/usertools/
  • There have also been a number of useful tools written using windows scripting.

Otherwise, if you simply want to perform some manipulation of your music it is possible there is a tool already created that will do the job.

While there are many, one of the most powerful is "GlobalMod".  This tool is written in php and is installed with the starter kit.  It is very useful but requires a some understanding of the clip text format.

If you run the tool with a 'help' (no quotes) parameter it will give you a quick rundown of its command/parameter structure.  Another useful tool is "Variable Dump for Developers", also installed with the kit.  This one will help you figure out the parameters that you want to change with GlobalMod and how to format them (things like case are important).

Then there is "Parts", "Transpose Chords", "Multi Bar Rest" and many more, not all of which have been submitted to the Scripto.  A very good source of user tools and discussion on user tools is the NewsGroup - Signup here: https://www.noteworthysoftware.com/newsgroup/signup.php

Additional user tools are available from the Scripto as well as a couple of useful guides:
http://nwc-scriptorium.org/nwc2scripts.html
http://nwc-scriptorium.org/ftp/nwc2scripts/generaldiscussion.pdf
http://nwc-scriptorium.org/ftp/nwc2scripts/invocationinstructions.pdf

Hopefully this is what you're after
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: Writing user scripts

Reply #2
There are also some good PHP tutorials out there.

For starters, W3Schools has a good little tutorial.

If you need some solid reference, there is an official PHP Documentation at the PHP web site.

Good luck writing user scripts.  (I'm still having trouble writing one that seperates the notes in a chord!)

Re: Writing user scripts

Reply #3
Thanks guys.  Obviously a few plagiarisable examples of PHP manipulating would be jolly handy if like me you haven't used it before.  What I was particularly wondering though is whether the mechanism is defined, e.g:
    - What are contents of STDIN passed by NWC?
    - What return codes should be set by the script and how does NWC react?

Re: Writing user scripts

Reply #4
    - What are contents of STDIN passed by NWC?
    - What return codes should be set by the script and how does NWC react?
These are questions you have to plagiarize existing scripts to figure out.

I think the contents of STDIN is NWC Clip Text.

Re: Writing user scripts

Reply #5
G'day kahman,

Good luck writing user scripts.  (I'm still having trouble writing one that seperates the notes in a chord!)


The 'parts' tool does exactly this.
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

 

Re: Writing user scripts

Reply #6
I wanted to reply to this, but didn't know where all the resources were. Thanks Lawrie for pointing A63 in the right direction.
Andrew, in response to what the contents of STDIN are, try:
(Assuming you have installed the NWC User Tools thingy)

Alt-F8 (or Tools | User Tool)
Variable Dump for Developers (that's what you are!)
It gives a dialog showing STDIN, STDOUT and STDERR. STDIN is what you're interested in.
It's (virtually) identical to what is pasted when you copy a clip and paste it into - say - Notepad.

If I had my development of my User Tools all over again, I would probably not have used php but vbscript or similar (it's all one big mish-mash in windows scripting anyway) so that I could have created dialogs and had persistent settings. php makes both of those difficult/clunky.
If you do want to develop stuff in PHP, please feel free to modify my scripts to your heart's content. Just retain the history and stuff at the top of the script, that's all. I'm very very keen for others to develop scripts for NWC. I think it is a very powerful tool which is still under-utilised. One thing which restricts it is lack of access to all of a score.

PS: The Noteworthy Scriptorium has lots of helpful stuff with scripts, starting at http://nwc-scriptorium.org/nwc2scripts.html

PPS: w.r.t. return codes, check C:\Program Files\NoteWorthy Composer 2\Scripts\lib\nwc2clips.inc (or wherever it's installed). In short...
define("NWC2RC_SUCCESS",0); // Standard output is processed..contents in standard error is presented as a warning
define("NWC2RC_ERROR",1);   // Standard error is shown to the user
define("NWC2RC_REPORT",99); // Standard output is shown to the user

HTH,
Andrew

Re: Writing user scripts

Reply #7
Or you could search NWC2's help file for "User tools". The description of error codes and prompts is extensive.

Windows' Clipboard viewer will show you what the tool gets for STDIN with 2 exceptions:
  • A single item doesn't have begin/end tag lines
  • If nothing is selected, the tool gets the entire staff in STDIN
Registered user since 1996