Skip to main content

Messages

This section allows you to view all Messages made by this member. Note that you can only see Messages made in areas you currently have access to.

Messages - jdorocak

1
General Discussion / Re: Chords
Dear Lawrie and  Flurmy,

YAHOO! it worked like magic.

Lawrie, thanks for sticking with me your tool worked great.

Flurmy, thanks for letting me know about yours as well.
2
General Discussion / Re: Chords
Dear Lawrie,

MANY thanks for your kind, attentive response & ALL the IMPORTANT and USEFUL information.

I have:
-installed NWC v2.51a                        == "nwcupd_from_v2.5.5.exe".
-installed User Tools Starter for NWC v2.51a == "nwc2_UserToolStarter_v2_51.exe".

Here are my attempts at invoking your wonderfully useful tool. I remain BAFFLED.  :)

Try 1 Screenshot Sequence [With My Interpretation of "Enter Options"].[3 Screenshots]

-01_Invocation_Screenshot_2015-03-03_07.58.png
<Image Link>
-02_Enter_Options_Screenshot_2015-03-03_08.03.43.png
<Image Link>
-03_Error_Msg_Screenshot_2015-03-03_08.06.10.png
<Image Link>


Try 2 Screenshot Sequence [With Verbatim Copy of Your Answer "command line" "Enter Options"].[2 Screenshots]

-N.B. Invocation looks the same as before.
-04_Verbatim_Enter_Options_Screenshot_2015-03-03_08.07.46.png
<Image Link>
-05_Error_Verbatim_Screenshot_2015-03-03_08.08.37.png
<Image Link>

Try 3 "command line" Screenshot.
-06_command_line_Screenshot_2015-03-03_09.16.29.png
<Image Link>



Thanks for the help in advance.

3
General Discussion / Re: Chords
Dear Lawrie,

This doesn't seem to be working for me. I can't figure out the invocation.
I am using NWC 2.5.5

I tried invoking per my understanding of the help with
    php transpose_chords.php +9 E
Result:
    Unknown parameter "php". Use "help" for more details.

I tried
    transpose_chords.php +9 E
Result:
    Unknown parameter "transpose_chords.php". Use "help" for more details.

I tried
     +9 E
Result:
    Unknown parameter "+9". Use "help" for more details.

I tried
    php\php.exe scripts\adp_TransposeChords.php +9 E   
Result:
    Unknown parameter "php\php.exe". Use "help" for more details.  

I sure could use some help. :)

By the way. Does the HINT refer to the Target Key or the Beginning Key?

Thanks in advance.

Love and peace,

Joe
8
General Discussion / Re: In a repeated section, how can I make Sop. & Alto sound first time & T,B 2nd?
Many many thanks to all replying. I am being educated BIG TIME.

I have some follow up questions.

Flurmy said, "To have a consistent behaviour simply put a parameter reset at the very beginning of the score." How do i do that? :)

Bill Denholm said, "In my experience mpcs must usually be cancelled or they can cause strange behaviour on subsequent replays." How do i do that? :)

Rick G., I looked at your "many special endings :)" example. I like it in that it doesn't use Dynamics. I manipulate Dynamics to emphasize parts in the practice audios I produce. I'll use this in the future providing i can GROK it. :)

This time I used Bill's ppp fff solution.

Thanks again to all.

Love and peace,

Joe

9
General Discussion / Re: In a repeated section, how can I make Sop. & Alto sound first time & T,B 2nd?
Dear Bill,  Flurmy and Haymo,

Thanks for the responses.

Bill, thanks for the solution. I would have never come to that myself.

Flurmy, I have seen the MPC used in John Hooper's work on the NWC Scriptorium. I also have seen it be recommended by folks I trust on this Forum. Thanks for the suggestion.

Haymo, thanks for the non-audio solution. My goal, however, is to produce practice audios for each part. You can see the ones i have done at this link: http://tinyurl.com/epiphany-all-anthems

Thanks again, to all of you.

Love and peace,

Joe

10
General Discussion / In a repeated section, how can I make Sop. & Alto sound first time & T,B 2nd?
Dear NWC Forum,

I have a song i am helping my choir with. In a repeated section, the publisher made a note saying, first time through Sop. & Alto sing, 2nd time through, T & B. Here is the form of the staves:

S: <begin><MasterRtpOpen>S<1stOnly>S<AllVoicesSingCommonHere><MasterRtpClose><MoreSong>
A: <begin><MasterRepOpen>A<1stOnly>A<AllVoicesSingCommonHere><MasterRtpClose><MoreSong>
T: <begin><MasterRepOpen>T<2ndOnly>T<AllVoicesSingCommonHere><MasterRtpClose><MoreSong>
B: <begin><MasterRptOpen>B<2ndOnly>B<AllVoicesSingCommonHere><MasterRtpClose><MoreSong>

I have made many attempts using special endings. No luck.

I'd like to keep the publisher's measure numbers intact so my choir can tell me if I made any mistakes.

Does anyone have any ideas?

Thanks for the help in advance.

Love and peace,

Joe
 
12
User Tools / Python NWC tool to reverse selected notes in a staff.
Here’s the python code. Enjoy. :)

This code needs to import  nwctxt.py see https://github.com/nwsw/nwc2ut-python

Love and peace,
Joe

Code: [Select · Download]
"""joeSelReverse.py Reverses the Notes that are selected in a NoteWorthy Composer staff
 
see:
    https://github.com/nwsw/nwc2ut-python    
"""
 
import sys
# import joeNWCtxtInPythonNew as nwctxt
import nwctxt # see https://github.com/nwsw/nwc2ut-python
import logging
logging.basicConfig(filename='joeNWC_PY.log',level=logging.DEBUG)  # DEBUG => print ALL msgs
 
clip = nwctxt.NWC2Clip()
PlayContext = nwctxt.NWC2PlayContext()
txtItemL = clip.Items
clipItemL = [nwctxt.NWC2ClipItem(txtItem) for txtItem in txtItemL]
first2 = clipItemL[:2]
reversedClipItemL = first2 + list(reversed(clipItemL[2:]))
reversedTextItemL = [item.ReconstructClipText() for item in reversedClipItemL]
 
print clip.GetClipHeader()
for textItem in reversedTextItemL[2:]:
    #print "clipItem.GetObjType()= %s, type(clipItem.GetObjType())= %s, "%(clipItem.GetObjType(), type(clipItem.GetObjType()))
    print textItem
print clip.GetClipFooter()
 
 
# TO DEBUG uncomment below to report to NWC STDOUT DIALOG & to CAUSE NO STAFF MODIFICATION
# sys.exit(nwctxt.NWC2RC_REPORT)
14
User Tools / Re: May I please have some help with creating a Python NWC User Tool?
OK here's the answer. It DID work from a NWC User Tool.

When I run it from a NWC User Tool, apparently the Current Working Directory:
    IS NOT <path>\NoteWorthy Composer 2\Scripts\
    BUT IS <path>\NoteWorthy Composer 2\

Mystery Solved.

I have published a small description of how to do this on my blog under:
How 2 Create a Python NWC User Tool

Thanks for being a GREAT Forum.

Love and peace,
Joe  
    
15
User Tools / May I please have some help with creating a Python NWC User Tool?
Dear NWC Forum,

Thanks for being a great place to share info. I am trying to write my first User Tool. It will be in Python. It is very simple. It copies a clip to a file.

I am using NWC 2.5.5 & have installed version 2.5 of the NWC2 User Tool Starter Kit.
Here's some system info from About Starter Kit:
System => Windows NT cmptrName 5.1 build 2600 (Windows XP Professional Service Pack 3) i586
Build Date => Sep 17 2009 19:13:11
Compiler => MSVC9 (Visual C++ 2008)
Architecture => x86
Configure Command => cscript /nologo configure.js  "--disable-all" "--enable-cli" "--enable-zlib"
Server API => Command Line Interface


Here is my simple Python program to copy a clip to a file:
import sys
instr = sys.stdin.read()
f = open('joesFirstTestOut.txt', 'w'); f.write(instr); f.close()


When I run it from a windows prompt, it works :
C:\...Scripts>python joesFirst.py<joesFirstTestIn.txt


When I run it from a NWC User Tool, there is NO CHANGE in joesFirstTestOut.txt.

My User Tool Description Dialog has been set with 2 alternatives with the same results as above:
Alt-1
group: joe
name: joesFirst.py
command: python scripts\joesFirst.py
input type: clip text
options:
    compress input:         [ ]
    returns file text:      [ ]
    long task handling:     [ ]
    prompts for user input: [ ]

Alt-2
group: joe
name: joesFirst.py
command: python scripts\joesFirst.py
input type: clip text
options:
    compress input:         [ ]
    returns file text:      [ ]
    long task handling:     [X]
    prompts for user input: [ ]

        
Does anyone have any suggestions?
Thanks in advance.
Love and peace,
Joe
17
Instrument Trees / Using Instrument Trees
Dear NWC Forum,

I am using NWC 2.5.5.

Recently i was trying to get a staff to sound like a harp. Because of my dyslexia, i missed seeing the predefined instrument Orchestral Harp in the String section of the Default Instrument Tree. So i clicked Change List and looked in the Classic Instrument Tree.

I didn't see harp in the General MIDI section. Neither did i see it in the Roland GS section. Finally I found Harp-1 in the MT-32 section and chose it as the Instrument for the staff. However, when i played the notes on the staff they sounded like a trumpet.

Here's my question. What else do i have to do to get the staff to sound like a harp using the Harp-1 voice in the MT-32 section of the Classic Instrument Tree? [I have already discovered and used the Orchestral Harp in the String section of the Default Instrument Tree, but I want to know what the steps are to enable the MT-32 voices and other voices in other Instrument Trees.]

Thanks in advance.

Love and peace,

Joe
18
User Tools / Re: Convert (from nwctxt to xml) and back (from xml to nwctxt)
Dear David, Lawrie and Rich,

My original motivation in coding these routines was to get nwctxt into xml, let's call it "nwcxml", so I could manipulate the nwcxml and do multistaff operations on it and return the nwcxml to nwctxt for re-import into NWC. (Whew!)

Anyway I have been vaguely aware of MusicXML and I do think it would be a good idea to
convert to and from full spec. MusicXML files.

I believe this could be a big undertaking based on the sigh it caused virtuoso kahman:
At some point, someone should write a converter to/from MXML...sigh.

I have started a SourceForge open source project at https://sourceforge.net/projects/rtcnwctxt-xml/ Here is the Project Description:
Quote
BASIS FOR AN OPEN SOURCE PROJECT to convert NoteWorthy Composer files from/to MusicXML. Two Python 3 programs for NoteWorthy Composer files in nwctxt format. 1. nwctxt2xml.py - Converts nwctxt into XML 2. xml2nwctxt.py - Converts XML into nwctxt

Let's see if I/we can drum up some participation from others to make useful progress. By the way, I'm not sure that all musical concepts expressible in MusicXML are expressible in NWC. My intent is to have some fun with this and as I say, make useful progress. I hope all who participate will have the same outlook.

Here is the MusicXML wiki page link. http://en.wikipedia.org/wiki/MusicXML And here is the MusicXML definition page from RecordCare, the driving force behind MusicXML. http://www.recordare.com/xml.html

Thanks for the interest and encouragement.
19
User Tools / Re: Convert (from nwctxt to xml) and back (from xml to nwctxt)
Dear Rich,

Thanks ever so much for your gracious reply. I braced myself for this effort being only useful to me. It makes me very glad that someone else thinks it might be useful as well. :)

I'll look into the issue you described and report back.

Thanks again for the encouragement.

20
User Tools / Convert (from nwctxt to xml) and back (from xml to nwctxt)
I have written two Python 3 programs:
  1. nwctxt2xml.py  - Converts nwctxt into XML
  2. xml2nwctxt.py  - Converts XML into nwctxt

I have done about a dozen "round trip" tests. All results ran OK. Here is a round trip test:
  1. nwctxt2xml.py converts mySong.nwctxt to mySong.xml
  2. xml2nwctxt.py converts mySong.xml to mySong-out.nwctxt
  3. If fileCompare (mySong.nwctxt, mySong-out.nwctxt) = "files are identical"  -> OK

Having said that, these programs are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. They are subject to the GNU General Public License 3. See each source code listing.

You can download a zip distribution file at https://sourceforge.net/projects/rtcnwctxt-xml/

The zip distribution contains 4 files:
  0. readme.txt    
  1. nwctxt2xml.py  - Converts nwctxt into XML - Python 3.1 source code
  2. xml2nwctxt.py  - Converts XML into nwctxt - Python 3.1 source code
  4. GPL-3.txt         - GNU GENERAL PUBLIC LICENSE Version 3 details

Contact me at JoeCodeswell@gmail.com

All the best,

Joe

PROGRAM DOC BRIEFS

1. nwctxt2xml.py

  Copyright © 2009 Joe Dorocak (JoeCodeswell@gmail.com)
  Subject to GNU General Public License 3 (see source code listing)
  
nwctxt2xml.py converts nwctxt into XML

Requires: Python 3.1+
Usage:   nwctxt2xml.py infile.nwctxt outfile.xml
Example: nwctxt2xml.py mySong.nwctxt mySong.xml


nwctxt2xml.py Converts
  From: nwctxt format
  To:   Joe Dorocak's xml format. See below for XML structure:
    <jNoteWorthyComposer>
      <SongInfo></SongInfo>
      <PgSetup></PgSetup>
      <jFonts><Font></Font></jFonts>
      <PgMargins></PgMargins>
      <jStaves>
        <jStaff>
          <AddStaff></AddStaff>
          <StaffProperties></StaffProperties>
          <StaffInstrument></StaffInstrument>
          <Clef></Clef>  
          <Key></Key>
          <Tempo></Tempo>    
          <Note></Note>    
          <Chord></Chord>    
          <Bar></Bar>            
        </jStaff>            
      </jStaves>
    </jNoteWorthyComposer>
  
  Note: The xml elements <jFonts>, <jStaves> and <jStaff> were added to those
          elements directly derived from the nwctxt format.

      
2. xml2nwctxt.py

  Copyright © 2009 Joe Dorocak (JoeCodeswell@gmail.com)
  Subject to GNU General Public License 3 (see source code listing)

xml2nwctxt.py converts XML into nwctxt

Requires: Python 3.1+
Usage:   xml2nwctxt.py infile.xml outfile.nwctxt
Example: xml2nwctxt.py mySong.xml mySong.nwctxt


xml2nwctxt.py Converts
  To:     nwctxt format
  From:   Joe Dorocak's xml format. See below for XML structure:
    <jNoteWorthyComposer>
      <SongInfo></SongInfo>
      <PgSetup></PgSetup>
      <jFonts><Font></Font></jFonts>
      <PgMargins></PgMargins>
      <jStaves>
        <jStaff>
          <AddStaff></AddStaff>
          <StaffProperties></StaffProperties>
          <StaffInstrument></StaffInstrument>
          <Clef></Clef>  
          <Key></Key>
          <Tempo></Tempo>    
          <Note></Note>    
          <Chord></Chord>    
          <Bar></Bar>            
        </jStaff>            
      </jStaves>
    </jNoteWorthyComposer>

    Note: The xml elements <jFonts>, <jStaves> and <jStaff> were added to those
            elements directly derived from the nwctxt format.

21
User Tools / Re: What is the character encoding of .nwctxt files?
Dear Rick and Bob,

Thanks for the help. Character encoding indeed has to do with how all the characters including the £ sign are coded in bits. Not all characters that we want to encode these days can be held in a single byte (0-255). Here's a link to an excellent wikipedia article on the subject. http://en.wikipedia.org/wiki/Character_encoding .

My purpose in asking the question was to defeat a bug I was getting while testing a Python based nwctxt2xml.py & xml2nwctxt.py set of programs for NWC2.

I recently converted from Python 2.5 to Python 3 which uses Unicode UTF-8 enncoding. I have run a dozen "round trip" tests on the following nwctxt files, and all tested OK. Some of these tested bad using Python 2.6. My, possibly mistaken, conclusion is that nwctxt files use UTF-8 encoding. 

Here is a round trip test:
  1. nwctxt2xml.py converts mySong.nwctxt to mySong.xml
  2. xml2nwctxt.py converts mySong.xml to mySong-out.nwctxt
  3. If fileCompare mySong.nwctxt, mySong-out.nwctxt = "files are identical"  -> OK

Here is the output log of my dozen tests:
Code: [Select · Download]
test: 001 time: Fri Aug 07 13:48:51 2009 file: ambeaut.nwctxt       -> OK  
test: 002 time: Fri Aug 07 13:48:54 2009 file: bosgbaa.nwctxt       -> OK  
test: 003 time: Fri Aug 07 13:48:55 2009 file: hillhbr.nwctxt       -> OK    
test: 004 time: Fri Aug 07 13:48:56 2009 file: hussaut.nwctxt       -> OK    
test: 005 time: Fri Aug 07 13:49:39 2009 file: JesusLM.nwctxt       -> OK   
test: 006 time: Fri Aug 07 13:49:39 2009 file: mozhall.nwctxt       -> OK   
test: 007 time: Fri Aug 07 14:01:02 2009 file: ocanada.nwctxt       -> OK   
test: 008 time: Fri Aug 07 14:01:02 2009 file: wamr01-intrt.nwctxt  -> OK  
test: 009 time: Fri Aug 07 14:01:22 2009 file: wamr02s-dies.nwctxt  -> OK 
test: 010 time: Fri Aug 07 14:01:43 2009 file: wamr07-lacri.nwctxt  -> OK   
test: 011 time: Fri Aug 07 14:01:49 2009 file: wamr10-sanct.nwctxt  -> OK  
test: 012 time: Fri Aug 07 14:01:55 2009 file: wamr12-agnus.nwctxt  -> OK  

I am going to post my code, open source, so folks can use it under another thread. If I made a mistake in my UTF-8assumption, they'll find it and hopefully let me know so I can fix the code. Thanks for the help.

Joe
22
User Tools / What is the character encoding of .nwctxt files?
Hi Folks,

I'm trying to make a Python based nwctxt2xml.py & xml2nwctxt.py set of programs for NWC2. I have been reasonably successful so far, but in doing more extensive round trip testing, I see problems with characters like 'é' and 'ä'. So what is the character encoding for .nwctxt files? Is it UTF-8, UTF-16, iso8859-1, iso8859-2, ..., ? Thanks for the help in advance.

All the best.

Joe :)
23
User Tools / Re: Python NWCTXT parser
Here is a wrapper script I wrote so that I could save your output as a file. I have used your output in a file as input to a Python script that converts it to XML. The converter is posted under:
"nwcPythonTxt to xml converter" https://forum.noteworthycomposer.com/?topic=6860.0
Thanks for your good work. I find I am much more productive in Python. Here is the code, which is mostly yours. Thanks again.

Code: [Select · Download]
#Joe Dorocak's small additions to kahman's :
#pyNWC-a .nwctxt syntax parser (I/O) in python
#Created by NWC forum user kahman.
#Use it however you please.  Feel free to modify it, but please return all modifications to the forum.
#See below for known bugs.
#If you want to "translate" it into another computer language, feel free to do so.  If you want to modify it, feel free to do so.
#Basically, what it does is you can give it a line of code and it will process it by | and :, so |Note|Dur:4th|Pos:0 becomes the line of code ['Note', {'Dur': '4th', 'Pos': '0'}]
#If anyone makes any modifications, post them here.
#At some point, someone should write a converter to/from MXML...sigh.
#Oh, and at some point, I'll work on a program to convert from this back to NWCTXT.
#If you find a bug, please post it here.
#Known bugs:
#   *Cannot import lyrics that have line-breaks in them.
"""
nwcTxtParse.py Translates NWCTextFormat to PythonListDictFormat

Usage:   nwcTxtParse.py infileName    outfileName
Example: nwcTxtParse.py mySong.nwctxt mySong.py
"""


def parsefile(_file):
    "parse one file"
    _file=_file.split('\n') #split the file by line
    for x in range(len(_file)):    #for each remaining line,
        _file[x]=parseline(_file[x])   #parse it seperately
    while 1:    #until error occurs
        try:
            _file.remove(None)  #remove a None from the list
        except ValueError:  #if there is no None,
            break   #break
    return _file

def parseline(line):
    "parse one line"
    output=[]
    if line=='':    #if line is blank,
        return None     #destroy it
    elif line[0]=='#':  #or if it's a comment,
        return None     #destroy it
    elif line[0]=='!':  #or if it's start/end marker,
        return None     #destroy it
    line=line.split('|')    #split the line by |
    output.append(line[1])   #set what object it is
    output.append({})
    for x in line[2:]:  #then for each property/value
        y=(x.split(':')) #split it into property and value
        output[1][y[0]]=y[1]    #and add these to the dictionary
    return output

def writefile(tree):
    "write a file"
    output='!NoteWorthyComposer(2.0)\n'   #start empty output
    for x in tree:  #for each line
        output=output+writeline(x)+'\n' #process it seperately
    output=output+'!NoteWorthyComposer-End'
    return output

def writeline(line):
    "write a line"
    output='|'  #start empty output
    output=output+line[0]
    for x in line[1].keys():
        output=output+'|%s:%s' %(x, line[1][x])
    return output


import sys

N_ARGS = 2 

def main(argv=None):
if argv == None: argv=sys.argv
args = argv[1:]  #NOTE: args[0] != argv[0] == <full path to example.py>
if len(args) != N_ARGS or "-h" in args or "--help" in args:
print __doc__
sys.exit(2)

f = open(args[0], 'r'); s = f.read(); f.close()        # get the input file into s
s2 = parsefile(s)                                      # translate s into s2
f = open(args[1], 'w'); f.write(str(s2)); f.close()    # write str(s2) into the output file
print 'Translated ' + str(args[0]) + ' yielding ' + str(args[1])


if __name__ == '__main__':
sys.exit(main())


Thanks again.
All the best :)

Joe
24
User Tools / nwcPythonTxt to xml converter
Here is a Python script I wrote after reading NWC Virtuoso, kahman's post:
Python NWCTXT parser - https://forum.noteworthycomposer.com/?topic=6097.0
My script converts kahman's Python List/Dictionary output to XML. I did it so that I could study the structure of an nwctxt file using a data folding text editor. The XML structure is my own home grown version based on what I inferred from kahman's Python Data Structure. I have done minimal testing so use it with caution. Please let me know what you think. Please post any additions here. You can use this script as you like. Here is the code:

Code: [Select · Download]
"""
nwcPy2nwcXml.py Translates
FROM: nwcPythonListDictFormat (kahman's nwctxt to python converter pyNWC-a output)
TO: jdorocak's homegrown xml (So I can use data folding in a text editor.) :)

Usage:   nwcPy2nwcXml.py infileName  outfileName
Example: nwcPy2nwcXml.py mySong.py   mySong.xml
Author:  Joe Dorocak
License: Use this as you please. :)
         Use with caution - I have done minimal testing. No warranty is implied. :)
"""

class ConvertToXML():
    """
    Converts
        FROM: nwcPythonListDictFormat (NWC Virtuoso kahman's nwctxt to python converter pyNWC-a output)
        TO: jdorocak's homegrown xml (So I can use data folding in a text editor.) :)
    rs == resultString; il == indentationLevel; aprs(il,str) == appendToResultString(indentationLevel,strToAppend)
    data == string output of kahman's nwctxt to python converter
    ix == index of current pythonListDict item;
    joe's xml syntax for nwctxtPy files inferred from analysis of data (i added elements named j*):

    <jNwctxtPy>
        <SongInfo count=1></SongInfo>
        <PgSetup count=1></PgSetup>
        <jFonts><Font count=12></Font></jFonts>
        <PgMargins count=1></PgMargins>
        <jStaves>
            <jStaff>
                <AddStaff count=1></AddStaff>
                <StaffProperties count=2></StaffProperties>
                <StaffInstrument count=1></StaffInstrument>
                <Clef count=n></Clef> 
                <Key count=n></Key>
                <Tempo count=n></Tempo>
                <Note count=n></Note>
                <Chord count=n></Chord>
                <Bar count=n></Bar>
            </jStaff>
    </jStaves>
    </jNwctxtPy>
    """
    def __init__(self, indata):
        """
        data == data to be converted.  FROM: nwcPythonListDictFormat (kahman's nwctxt to python converter pyNWC-a output)
        rs == resultString; converted data jdorocak's homegrown xml (So I can use data folding in a text editor.) :)
        """
        self.data = eval(indata)
        self.data.append(['End', {'Joe': 'End', 'Pos': 'Whatever'}])
        self.rs = ''         

    def toxml(self):
        self.aprs(0,'<jNwctxtPy>')


        #SongInfo
        self.aprs(1,'<SongInfo count=1>')
        ix = 0
        print len(self.data)
        for k,v in self.data[ix][1].iteritems():
            self.aprs (2,'<' + k + '>' + str(v) + '</' + k + '>')
        self.aprs (1,'</SongInfo>')

        #PgSetup
        self.aprs (1,'<PgSetup count=1>')
        ix = 1
        for k,v in self.data[ix][1].iteritems():
            self.aprs (2,'<' + k + '>' + str(v) + '</' + k + '>'   )
        self.aprs (1,'</PgSetup>')

        #Fonts
        self.aprs (1,'<jFonts>')
        for ix in range(2,14):
            self.aprs (2,'<Font count=12>')
            for k,v in self.data[ix][1].iteritems():
                self.aprs (3,'<' + k + '>' + str(v) + '</' + k + '>'   )
            self.aprs (2,'</Font>')
        self.aprs (1,'</jFonts>')

        #PgMargins
        self.aprs (1,'<PgSetup count=1>')
        ix = 15
        for k,v in self.data[ix][1].iteritems():
            self.aprs (2,'<' + k + '>' + str(v) + '</' + k + '>'   )
        self.aprs (1,'</PgSetup>')



        self.aprs (1,'<jStaves>')
        self.aprs (2,'<jStaff>')
        #AddStaff
        ix = 16
        for ix in range(ix,len(self.data)-1):
            #if self.data[ix+1][0] == 'AddStaff': self.aprs (2,'<jStaff>')    #ix+1 needed to add ['End',{'Joe':'whatever'}]
            self.aprs (3,'<'+ self.data[ix][0] +'>')
            for k,v in self.data[ix][1].iteritems():
                self.aprs (4,'<' + k + '>' + str(v) + '</' + k + '>'   )
            self.aprs (3,'</'+ self.data[ix][0] +'>')
            if self.data[ix+1][0] == 'AddStaff': #ix+1 needed to add ['End',{'Joe':'whatever'}]
                self.aprs (2,'</jStaff>')  
                self.aprs (2,'<jStaff>')

        self.aprs (2,'</jStaff>')
        self.aprs (1,'</jStaves>')


        self.aprs(0,'</jNwctxtPy>')
        return self.rs

    def aprs(self, il, strToAppend):
        """aprs(il,str) == appendToResultString(indentationLevel,strToAppend)"""
        self.rs = ''.join([self.rs, il*2*' '+strToAppend+'\n'])
        #print il*2*' '+strToAppend
   

import sys

N_ARGS = 2 

def main(argv=None):
    if argv == None: argv=sys.argv
    args = argv[1:]  #NOTE: args[0] != argv[0] == <full path to example.py>
    if len(args) != N_ARGS or "-h" in args or "--help" in args:
        print __doc__
        sys.exit(2)

    f = open(args[0], 'r'); s = f.read(); f.close()          # get the input file into s
    cx = ConvertToXML(s)                                     # make a new converter for s
    sXml = cx.toxml()                                        # translate s into sXml
    f = open(args[1], 'w'); f.write(sXml); f.close()    # write str(s2) into the output file
    print 'Translated ' + str(args[0]) + ' yielding ' + str(args[1])


if __name__ == '__main__':
    sys.exit(main())


I have posted the addition I did to kahman's code to save his output in a file, at his post: https://forum.noteworthycomposer.com/?topic=6097.0


All the best. :)
Joe
25
User Tools / Re: Must a User Tool act only on a single staff?
Dear Rick and Lawrie,

Thanks to you both for your easily understood replies. I have been reading many of both of your posts in other parts of the Forum and I agree with the consensus, you are both Virtuosi. :)

Using SendKeys is something of a "dark art." Routines that work perfectly on Win98, fail miserably on WinXP.

I totally agree. That is why I am investigating User Tools. I wrote a chord composer using SendKeys to NWC from the VB based UI. I asked one of my fellow choir members who has NWC to test it for me. It failed miserably on her XP machine. There are Windows Administration ways to get around this but it seems to be different for Vista, XP and who knows about Win 7. :..)

BTW, just after I posted my original question, I happened to click on the "Tool for layering??" subject, started by fathafluff. Your responses in there spoke my question as well. Have either of you guys considered starting a sticky subject that might be titled "Toward a NWC Scripting Programmer's Manual Wiki"? You could collect a bunch of your responses to newbies like me in there. If you wanted, you could encourage others to participate.

Anyway, thanks to both of you for your virtuosity.

Joe D.
:)
26
User Tools / Must a User Tool act only on a single staff?
I'm a newbie to NWC User Tools. I'd like to know if I can write a User Tool to do things to more than one staff. For example, I have used VB and SendKeys to copy a set of bars in NWC Window-1, and append it to all the staves in Window-2.

Is the entire NWC object model (Windows, Stave collection, MIDI settings, etc.) exposed to the User Tools interface? Thanks in advance.

Joe D
:)