Andrew Kingston wrote:
> Still on straight 102.42 I'm afraid - must sort out upgrading one of
> these days.
Wow, that's about 3 years old ;)
> I did actually want this behaviour for all users, so if you could let me
> have that code example for the MAIN_Input() section that'd be great.
NOTE: When cutting + pasting the below code,
be sure your email reader's window is wide enough
to prevent wrapping any lines.
I'd recommend defining the following function above the definition
of the MAIN_Input() function:
---- snip
# PEERLESS: MAKE LOCAL HACKS TO THE "LAST SUBMIT" FILE
sub HackLastSubmit()
{
my $err = 0;
my $infile = $G::lastsubmit;
my $outfile = "${G::lastsubmit}.modify";
# OPEN LASTSUBMIT FILE FOR READING
unless ( open(IN, "<$infile") )
{
$err = 1;
ErrorWindow("open $infile for read: $!");
}
# OPEN TMP FILE FOR OUTPUT COPY
unless ( open(OUT, ">$outfile") )
{
$err = 1;
ErrorWindow("open $outfile for write: $!");
}
# REMOVE LINES FROM LASTSUBMIT FILE THAT WE DONT WANT
while ( <IN> )
{
if ( /^\s+JobTitle:/ ) # remove JobTitle lines
{ next; }
print OUT $_; # copy thru all other lines
}
unless ( close(IN) )
{ $err = 1; ErrorWindow("close $infile for reading: $!"); }
unless ( close(OUT) )
{ $err = 1; ErrorWindow("close $outfile for writing: $!"); }
# Apply changes by renaming file over old one (if no errors)
if ( $err == 0 )
{
unless ( rename($outfile, $infile) )
{ ErrorWindow("rename($outfile,$infile): $!"); }
}
# Make sure we remove tmpfile if somehow left behind
unlink($outfile);
}
---- snip
..then adding a call to this new function near the top
of MAIN_Input(), eg:
---- snip
# PRESENT USER WITH INPUT FORM
# Prompts the user for data.
#
sub MAIN_Input()
{
# CREATE DEFAULTS IF NONE
if ( ! -e $G::lastsubmit )
{
if ( CreateDotRushDir() < 0 ) { exit(1); }
my $errmsg = WriteDefaults($G::lastsubmit);
if ( $errmsg ne "" ) { ErrorWindow($errmsg); exit(1); }
}
# CREATE HISTORY FILE IF NONE
open(FD, ">>${G::histfile}"); close(FD);
# PEERLESS: APPLY LOCAL HACKS TO THE LASTSUBMIT FILE
HackLastSubmit(); #### ADD THIS LINE ####
---- snip
That's it.
Since the lastsubmit file is ascii (all files in rush are ascii ;)
you can just hack away at it with normal text editing techniques.
There's actually easier ways to write the above using the predefined
functions LoadInput()/SaveInput() functions in .common.pl, but since
you might have even older submit scripts, I thought it best to
'spell it all out' with explicit code. If you're curious about those
two predefined functions (in .common.pl), you can just peruse the submit
scripts that use them to see how they can be used to modify the file's
contents with regex's.
--
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)
|