#!/usr/bin/perl
#
#NAME
#  ABCinit - ABC initial file.
#
#SYNOPSIS
#
#  ABCinit lo [hi [by]]
#
# Initialize a set of files for the O'Neill's Project.
# 

($me = $0) =~ s".*/"";
$V = $ENV{"V_$me"} || $ENV{"D_$me"} || 2;

$lo = shift;
$hi = shift || $lo;
$by = shift || 1;
unless (defined $lo) {
	print STDERR "Usage: $0 hi [lo [by]]\n" if $V>0;
	exit 1;
}
print "$me: lo=$lo hi=$hi.\n" if $V>1;

file:
for ($n = $lo; $n <= $hi; $n += $by) {
	print "$me: n=$n.\n" if $V>2;
	$f = sprintf("%04d.abc",$n);
	unless (open(F,">$f")) {
		print STDERR "$me: Can't write \"$f\" ($!)\n" if $V>0;
		next file;
	}
	print "$me: f=\"$f\"\n" if $V>1;
	print F "X: $n\n";
	print F "T: ______\n";
	print F "T: ______\n";
	print F "B: O'Neill's $n\n";
	print F "%M: \n";
	print F "L: 1/8\n";
	print F "Z: 1999 by John Chambers <jc\@trillian.mit.edu>\n";
	print F "N: \"______\"\n";
	print F "N: \"Collected by ______\"\n";
	print F "%N: \n";
	print F "K: C\n";
}
