This problem has been fixed for nwc-conv.exe version 2.1c
I have removed some non-germane threads.
I can't get
nwc-conv.exe to accept STDIN when I Exec it from script.
Caution: if you run the code below, break out of it ASAP with
CTRL+C.
Otherwise, it will create a huge file in your temp folder (and eventually fill your disk).
If I run the above with CScript, the "sort" works, but it hangs with "nwc-conv", requiring
CTRL+C to exit.
Similar results with WScript.
Since sort.exe works, I conclude that there must be a problem with nwc-conv.exe
I'm using WinXP Pro and Windows Script Host Version 5.7
Any help would be appreciated. If someone could get it to work with PHP, that would be helpful.
Hi Rick,
You are giving nwc-conv a "clip" when it is expecting a "song". The start and end lines for a song are different from a clip, and a song is expected to first contain song header info followed by one or more pairs of staff header info and its staff clip. In particular, nwc-conv wants the song header info in your case (to return INFO), and it's "hanging" because it's happily waiting for the song header info (or perhaps even for just the song start line).
I have created various include files and tools for processing entire songs (as opposed to single clips), and would be happy to help you more offline.
Randy
I don't think so. A "clip" would look like this:
Yep, you're right about that. I saw the "(2.0)" and compared it to my "song" header constant, which doesn't have the version/issue, and assumed you were using a clip header. But I forgot that my song class adds the version/issue to the constant later, just like the NWC clip class adds it. My bad.
But I still stand by the issue of the missing song header (along with the missing staff headers). A song header consists of SongInfo/PgSetup/PgMargins/Font items, and staff headers consist of AddStaff/StaffInstrument/StaffProperties items. You must give nwc-conv a proper song syntax, with a leading song header, and with every clip prefaced by a staff header.
That is not my experience. This is a perfectly valid nwctxt file:
If you save it to a file, you can open it with NWC and/or get its INFO with nwc-conv
Well strike two for me. I'm amazed that NWC will allow *all* song header and *all* staff header info to default! I've had no trouble with running nwc-conv from a PHP script, and I'd assumed it was because I was supplying all the header info. But it works for me even with no headers whatsoever. So this must be a VBS-specific issue?
VBS isn't case-significant, is it? I see one of your StdIn's is Stdin, but it's that way for the sort example too, so that can't be it? Does writing a blank line after the song footer line help any? Is VBS something available in Windows by default, or does it have to be installed somehow? Can't test any theories without it.
It will even work with:
I have no trouble running nwc-conv from a VBS script, so long as the first parameter is not "NWC" or "NWCTXT".
No and no.
Yes. wscript.exe and cscript.exe
Or you can get it here:
http://www.microsoft.com/downloads/details.aspx?familyid=47809025-D896-482E-A0D6-524E7E844D81&displaylang=en
IMO, there is a bug in nwc-conv.exe
If, on the commandline, I type:
a rather large file:
nwccnvi1.NWCTXT is created in my temp folder. In looking at the file, it appears that nwc-conv reads the STDIN, and writes it out to the above file, but then continues to write 0xFF to the file until I manually terminate it with
CTRL+C. Not nice. A Console program should not do this in response to having data piped to it.
Ah, now I see the problem. You are using piping to supply STDIN, whereas I've always used file redirection:
works fine, but:
fails as you say. It may be that nwc-conv is watching for an EOF character coming from the stream, when instead (or additionally) it should be checking the FEOF status. With file redirection, the file is naturally supplying an EOF character (actually even before the end of file usually, due to padding out to a block size). With piping, the stream sets a status to indicate no more characters available (at that time, as more may come in from the stream subsequently), but does not artificially generate an EOF character. I think it is typical for GETCHAR to infinitely return hex FF's when the FEOF status is set.
Look's like we agree.
This appears to describe the problem: http://en.wikipedia.org/wiki/C_file_input/output#EOF_pitfall
Quite a PITA for me to code around. I had to write the string out to a file, verify that it is all readable, use Run instead of Exec, and then delete the file.
Thanks for looking at it.
Looks like I had it backwards - it was checking for FEOF status but not for EOF char. It's always safest to check for both, and exit if either occurs, to cover all bases.
This is caused by an apparent bug in our compiler's rather old std library. A fix will be available in the next User Tool Starter Kit. In the mean time, it is attached to this reply.
Update on 28-May-2010: NWC-CONV.EXE Version 2.1c can currently be found in the latest beta of the NWC2 User Tool Starter Kit.
Thanks. Much improved. I can now generate a song file from nwctxt.
I can also generate nwctxt from a song, but only if it is less than 255 bytes. For longer strings, nwc-conv generates an error.
An obscure problem, not worth any more investigation.
What I am trying to do is convert a song to nwctxt and strip out all of the defaults. An example <here> (https://forum.noteworthycomposer.com/?topic=7284.msg50430#msg50430).
This requires that I know what NWC will do if a line is missing or a property is removed.
Ideally, I would like to use: nwc-conv NWCTXT NWCTXT
to convert "stripped" nwctxt to "default" nwctxt. Armed with that knowlege, I can take everything out of nwctxt that is not needed. But that option is not allowed.
Pending further inspiration, it appears that this tool will remain unpublished.
I do not understand what you are saying here.
I'm not sure why you would want to put effort into something like this, but you can do what you want in two steps, assuming the NWCTXT yields a valid NWC file:
nwc-conv NWCTXT NWC | nwc-conv NWC NWCTXT
If a pipe is used within Exec(), STDOUT cannot be read programatically.
As for the 255 byte limit, if I have string that is the contents of a song file, I can write it to STDIN but I get an error from nwc-conv if the string is longer than 255 bytes. I don't know if it is a script problem or a nwc-conv problem.
What kind of error? The stdin/out of NWC-CONV has no particular size limits. It seems to work fine with 1.5 MB versions of Tina Billett's 1812 overture saved as NWCTXT.
After half a day of hacking, I figured it out. The problem is Windows Script Host's ReadAll() function.
It returns a string that it says is the correct length, and for 256 bytes after the first NullChar that it encounters, contains the correct data. But for longer strings, all the data after the first NullChar is garbage. If it always contained garbage, or returned the correct length, I would have understood the problem in a few minutes. Grrr...
The workaround is to use:
strSong = .StdOut.Read(&h7FFF)
or for large strings:
Do Until .StdOut.AtEndOfStream
strSong = strSong & .StdOut.Read(&h7FFF)
Loop
See the attachment
It seems to work just fine. If you feed it garbage, it errs (as I would expect).
When receiving piped or redirected input data, NWC-CONV creates a file from it. As you figured out, this error was trying to tell you that the input passed to NWC-CONV was corrupt or invalid.