Tips & Tricks > What was sung, when?

 


rschwein
11/6/2006 3:06:43 PM

If you have found yourself wishing you could easily determine which songs have been sung as part of SSP programs, here's a little perl script that will do that for you.

You may need to install perl (its free) on your projection machine to run this. But the perl that's delivered with WindowsXP should be able to handle it.

The program reads through the c:\Documents and Settings\All Users\Documents\R-Technics\SongShow Plus\Programs directory (where the programs are stored by default), examines the file modification date for each program, and then lists the date and titles of each song in the program.

It's not particularly elegant, but gives a quick response and lets you see that, yes, you HAVE done "Just and I Am" eight times in the last year...

Rick Schwein

 

#! perl
# by Rick Schwein, New Covenant Community Church, Audubon NJ
#
# this program reads thru a SongShowPlus programs directory and prints out the date stamps
# for programs, and each song title in the program.
#
# capture and sort by title for a report on how often various songs are sung.
#

$programs = "C:/Documents and Settings/All Users/Documents/R-Technics/SongShow Plus/Programs";
opendir (DIR, $programs) or die;

while ( $entry = readdir(DIR) ) {
	next unless ($entry =~ /\.ssprog/);		#examine only ssp files
	$filetime = (stat("$programs/$entry"))[9];	#get file modification time
	$progdate = sprintf ("%02d/%02d/%04d", (localtime( $filetime ))[4]+1, (localtime( $filetime ))[3], (localtime($filetime))[5] + 1900) ; #make it month/day
	open PROG, "$programs/$entry";
	binmode PROG;
	@songs = ();							#read the program file into an array
	$songs = join //,@songs;					#collapse it
	@songs = split "\x0d", $songs;			#re-array it on carriage-returns
	$topline = shift @songs;					#pick off the first line
	($key) = $topline =~ m/\{(.+?)\}/;		#and get the 36-byte ID string.
	foreach ( @songs ) {							#this makes it easier to identify the song titles
		next if $_ !~ /$key/ ;					#some lines don't have the key, so skip 'em
		$line = $_ ;
		$line =~ s/$key.+// ;					#strip everything after the key
		$line = reverse $line ;					#flip it
		$line = substr($line,9) ;				#toss the next 9 characters
														# \x6 usually marks the beginning of a title
		if ( $line =~ /\x6/ ) {	$line = substr($line,0,index($line,"\x6")+1)} ;
														#i don't care about the "collections" label (MYSTUFF.)
		if ( $line =~ /\./ ) { $line = substr($line,0,index($line,'.')+1) };
		$line =~ s/\W+?\b(.+)/$1/;				#strip off any other non-character bits
		$line = reverse $line;					#flip it back forwards
		$line =~ s/\W+?\b(.+)/$1/;				#a little more trimming ...
		print "$progdate\t$line\n" ;			#and it's done!
	}
}

osborn4
11/6/2006 3:30:36 PM
This looks cool. I can't wait to try it. We are in our CCLI reporting period, and we keep forgetting to turn on CCLI report recording in SSP.

Thanks.

rschwein
11/6/2006 3:44:56 PM
Hope it works well for you! We *just* finished our reporting period, and I wish I'd thought of doing this then.


IMPORTANT NOTE: a couple of the lines got translated somehow when I pasted them into the web interface for the original post. The program will die unless the lines are corrected:
the line calling the "stat" routine needs to say ...
$filetime = (stat("$programs/$entry"))[9];
the subscript is [9]

The next line calls the "localtime" function three times. It needs to say...
$progdate = sprintf ("%02d/%02d/%04d", (localtime( $filetime ))[4]+1, (localtime( $filetime ))[3], (localtime($filetime))[5] + 1900) ;

the subscripts are [4]+1, [3], and [5]+1900




rschwein
11/6/2006 3:49:25 PM
AArgh! where the code shows up as H] it should be left square bracket, 9, right square bracket
where it is B] it should be left square bracket, 4, right square bracket.
where it is A] it should be left square bracket, 3, right square bracket.
where it is Γ] it should be left square bracket, 5, right square bracket.

if this still doesn't translate properly, let me know and I will e-mail you the zipped file.

iamgap
11/8/2006 9:12:23 PM

how do you execute it?


osborn4
11/9/2006 8:28:09 AM
I'm a little rusty on my perl, but here's my rendition (haven't tried it yet)

Save the code in a file with a .pl extension, e.g. usage.pl

You could double click the .pl at this point and it would run, but the window would go away and not lwe you see the result.

So, go to a command line window, navigate to the directory where you saved the .pl file and execute

perl usage.pl

Or whatever you named the .pl.

You should be able to redirect the output to a text file, using standard DOS conventions.

But you do need perl installed for it to work.

rschwein
11/9/2006 9:11:48 AM
Joel is correct ...

Perl does need to be installed. I was mistaken that some version is part of the core product of windows.

Save the (corrected) program into a file as Joel says.

Execute it from a command line by typing
perl programname.pl

That will display the results in the command window.
To capture the results in a file you can manipulate, perhaps importing into a spreadsheet
perl programname.pl > songssung.txt


iamgap
11/10/2006 9:57:14 AM

When I ran this, it didn't produce any data in the txt file. Anything about my situation that I can provide to help troubleshoot?


rschwein
11/10/2006 11:02:51 AM
First you should verify that your SSP programs are in the directory
C:\Documents and Settings\All Users\Documents\R-Technics\SongShow Plus\Programs

If the files are on a different drive ... maybe a network drive ... edit the path appropriately.
(But use forward slashes '/' instead of backslashes '\' in the path.)

You also might modify the line of the program that starts "opendir" slightly so that it says:
opendir (DIR, $programs) or warn "Problem: $!" ;

Rick


iamgap
11/10/2006 5:18:14 PM

location of programs
C:\Documents and Settings\All Users\Documents\R-Technics\SongShow Plus\Programs

example of name
Program - Nov04.ssprog

still no joy. Even with the opendir (DIR, $programs) or warn "Problem: $!"; statement.


Lee
11/13/2006 6:04:32 AM
Posted By iamgap on 11/10/2006 5:18 PM
...still no joy. Even with the opendir (DIR, $programs) or warn "Problem: $!"; statement.
Your problem is typical with reverse engineering; not every possible format is included in the Perl.

I used Notepad to look at my Nov 5 and Nov 19 ssprog files and made these observations:

1. A Perl comment says an ID key of 36 chars, some of mine are 45 chars between braces (although that shouldn't affect the script).
2. In Nov 5 only 1 of the 5 songs have the title included in the ssprog file, for Nov 19 2 of 4 songs have the title. I think it depends which database the songs reside in.
3. The Nov 5 ssprog file is 20,464 bytes, more binary info than ASCII, and plenty of Properties sections and lists of colors and other stuff. The Nov 19 program (which doesn't have backgrounds applied yet) is only 4474 bytes and has no property structures or file path names.

I'll bet the Perl script works only with the SongShow database, and I'm not sure how it'll work with programs using layered backgrounds and effects.

To post messages to the forums you must be signed in to a user account.
An error has occurred. This application may no longer respond until reloaded. Reload 🗙