Skip to main content
Topic: 3 ruby scripts (Read 8794 times) previous topic - next topic

3 ruby scripts

Here are 3 ruby scripts.


########################################

=begin

File name is
readfromfile.rb

select a staff and run this script
and select a file from prompt
then this will replace the staff with the file content

current directory is
C:\Program Files\Noteworthy Software\NoteWorthy Composer 2

Config directory is
C:\Documents and Settings\Administrator\Local Settings\Application Data\Noteworthy Software\nwc2\Config

add the following command line into Config file

Ruby Read from file=ruby.exe scripts\readfromfile.rb <PROMPT:Enter input file name:=|file1.xml|file2.xml>

=end

ifile = "temp/" + $*[0]  # $* is arguments
#ifile = "test.xml"
#ofile = "test9test.xml"
xml = open(ifile).read
#ofile = File.new(ofile, "w")
#ofile.print ifile
#ofile.close
print xml
exit 0


########################################

=begin

File name is
dump2file.rb

select a staff and run this script
and select a file from prompt
then this will dump the staff into the file

current directory is
C:\Program Files\Noteworthy Software\NoteWorthy Composer 2

Config directory is
C:\Documents and Settings\Administrator\Local Settings\Application Data\Noteworthy Software\nwc2\Config

exit 99  -- mini window
exit 0 -- nwc score editor

add the following command line into Config file

Ruby Dump 2 File=ruby.exe scripts\dump2file.rb <PROMPT:Enter output file name:=|file1.xml|file2.xml>

=end

ofile = "temp/" + $*[0]  # $* is arguments

ofile = File.new(ofile, "w")

STDIN.read.split("\n").each do |a|
   ofile.print a + "\n"
end

ofile.close

exit 0


#################################

=begin

File name is
stdinprint.rb

select a staff and run this script
then this will dump it into mini window

current directory is
C:\Program Files\Noteworthy Software\NoteWorthy Composer 2

Config directory is
C:\Documents and Settings\Administrator\Local Settings\Application Data\Noteworthy Software\nwc2\Config

without "exit" or with exit 0, output will replace the selection
  insertion(no selection) point will repace all starves
with "exit 99", output will be displayed in the mini window

add the following command line into Config file

Ruby STDIN Print=ruby.exe scripts\stdinprint.rb

=end

print "This is a text"
STDIN.read.split("\n").each do |a|
   print a
end

exit 99   #Standard output
#exit 0   #nwc score output