Skip to main content
Topic: Fake and Context lines (Read 3699 times) previous topic - next topic

Fake and Context lines

I was experimenting with a copy of Rick's stats.js and noted two new objects that weren't found when a whole staff was copied to the clipboard.  On it's staff via the F2 key, the instrument (acoustic guitar) had a -12 specified for transposition.
Code: [Select · Download]
/*
NWC2 User Tool, Ver 1.0 - Rick G.  Warren's test version
JScript version of nwswStatisticsReport.php
&Command: WScript Scripts\Stats.js
*/

var i, mark = new Date(), s;
/*
objArgs = WScript.Arguments
WScript.Echo("Argument count = " + WScript.Arguments.Count());
for (i=0; i<objArgs.length; i++)
{
    WScript.Echo(objArgs(i))
}
 */
// convert notation clip text to an array of lines
var stdin = WScript.StdIn.ReadAll().split("\r\n");
// init these so they will always report
var d = {"Total Items":0, "Clef":0, "Key":0, "TimeSig":0, "Bar":0, "Note":0, "Chord":0};

// count objects. non-objects are counted as 'undefined'

for (i in stdin){ // i = array index (integer)
s = stdin[i].split("|")[1]; // objType or undefined
if ((s == "Fake") || (s == "Context")) WScript.echo(i + " " + stdin[i]);  // new line
d[s] = (0 | d[s]) + 1; // increment, create keys as needed
}
delete d.undefined; s = ""; // cleanup
for (i in d) d["Total Items"] += d[i];
for (i in d) s += ("    " + d[i] + " ").slice(-6) + i + "\n";

// report to STDOUT, elapsed time to STDERR
WScript.StdOut.Write("Statistics Report:\n\n" + s);
WScript.StdErr.Write("The STDOUT file contains the report.\n" +
  ((new Date() - mark) / 1000).toFixed(2) + " seconds\n");
WScript.Quit(99); // show STDOUT page to user
Does anyone have any insight to these lines (they occurred just after the header) or others?  The Fake line went away if there was no transposition.
Since 1998

Re: Fake and Context lines

Reply #1
These will get you started:
An advanced search using Search for:fake  by User:NoteW*
will find most of the discussion.

For an example of how this information is used, see: nwsw_PitchMod.php
Registered user since 1996

Re: Fake and Context lines

Reply #2
These will get you started:

Many thanks.

FWIW, I've found parameters, arguments, or answers to prompts can't contain a space unless it's in quotes.  If a space is there a new one is created and allowing it would just create another layer of complexity in trying to read it.
Since 1998

Re: Fake and Context lines

Reply #3
FWIW, I've found parameters, arguments, or answers to prompts can't contain a space unless it's in quotes.
This behavior for command line parameters (arguments) goes back to the early days of DOS (and probably CP/M).
I did not know that it applied to prompts. Thanks for the info. I'll need to run some tests to decide if I think is a feature or a bug :)
Registered user since 1996

Re: Fake and Context lines

Reply #4
This behavior for command line parameters (arguments) goes back to the early days of DOS (and probably CP/M).
I did not know that it applied to prompts. Thanks for the info. I'll need to run some tests to decide if I think is a feature or a bug :)
Uncomment the "objArgs" part of my (your) script and add " <PROMPT:Prompt:=*sample>" to the end of the command line.  I am starting to work at converting my mmr.htm page and it won't have an option of "Hide barlines and whole rests"--that would make five parms/arguments.  They will be shorter and run together.
Since 1998