Please send questions to
st10@humboldt.edu .
#!/usr/bin/perl -w
#######################################################
# funct_play2
#
# try to permit a CS 131 student to "play" with simple C++
# functions easily. (written for Section 2, HTDP for C++);
# third of hopefully-several such introductory tools related
# to writing functions early; funct_play0 did not prompt for
# contract, purpose, and examples, but funct_play1 does!
# This will add better support for named constants, I hope,
# and better automatic handling of #include's for other
# functions called within this function.
#
# written by: Sharon M. Tuttle, st10@humboldt.edu
# last modified: 6-05-05 - emailing portion commented out
# (remove #email# comments if you would
# LIKE an e-mailed record of each student's
# sessions using this tool --- changing
# st10\@humboldt.edu
# to YOUR desired e-mail address)
# 9-14-03
#######################################################
#----------------------------------------------------------
# subroutine to ensure that a y or n answer is given
#----------------------------------------------------------
sub get_y_or_n
{
chomp(my $response = <STDIN>);
while (($response ne "y") && ($response ne "n"))
{
print "please respond with y or n: ";
chomp($response = <STDIN>);
}
return $response;
}
#------------------------------------------------------------
# subroutine to finish up the mail message (record of
# student's use of this tool) and send it to me;
# (1 parameter: a message you'd like to add to the end of the
# student's record before it is sent)
#-----------------------------------------------------------
sub finish_record
{
my($closing_note) = @_;
print RECORD "\n";
print RECORD " $closing_note\n";
print RECORD "\n";
chomp(my $end_time = `date`);
print RECORD " (end time: $end_time)\n";
print RECORD "\n";
close RECORD;
# thanks to Jeremy Miller for the how-to-email-in-Perl
# example...
open (MAIL, "|/usr/lib/sendmail st10\@humboldt.edu")
|| &HTMLdie("Couldn't send the mail!");
open RECORD, "< funct_play2_record"
or die "Cannot open funct_play2_record for reading: $!";
while (<RECORD>)
{
chomp(my $line = $_);
print MAIL "$line\n";
}
close (RECORD);
close (MAIL);
unlink funct_play2_record;
}
sub grab_dependencies
{
my($funct) = @_;
open F_FILE, "< ${funct}\.cpp"
or die "Cannot open ${funct}\.cpp: $!";
while (<F_FILE>)
{
chomp($line = $_);
if (($line =~ /#include "(.*)\.h"/) && ($1 ne $funct))
{
$addl_obj_files .= "$1\.o ";
print "LOOK! $addl_obj_files\n";
&grab_dependencies("$1");
}
}
close F_FILE;
}
#-----
# [email portions commented out 6-5-05, using #email#]
# PART 1: setting up the beginning of an e-mailed record
# of the student's use of this script
#-----
use File::Basename;
# grab info about who, where, and when for this execution ---
# to be included in email to me...
chomp(my $who = `whoami`);
chomp(my $where_path = `pwd`);
my $where = basename $where_path;
# create a file to eventually be mailed to me with a "record"
# of this student's attempts
#email#open RECORD, "> funct_play2_record"
#email# or die "Cannot open funct_play2_record for writing: $!";
#email#print RECORD "Subject: [cs131] funct_play2 from $who\n";
#email#print RECORD "\n";
#email#print RECORD "$who is running funct_play2 in directory: $where\n";
#email#print RECORD " (whole path: $where_path)\n";
chomp(my $start_time = `date`);
#email#print RECORD " (start time: $start_time)\n";
#email#print RECORD "\n";
#-----
# PART 2: is this a NEW function, or one that is being returned to?
# Either way, you can start by getting the name of the function-of-
# interest, I think;
#-----
print "\n";
print "--------------------------\n";
print "Welcome to funct_play2! \n";
print "--------------------------\n";
print "\n";
my $funct_name = "";
my $other_desired_funct_names = "";
my $funct_header = "";
my $also_for_hdr_file = "";
# default include statements that tester program eventually needs, too
my $include_stmts = "#include <iostream>\n#include <cmath>\n" .
"using namespace std;\n\n";
# Will additional .o files be needed for the compilation of the eventual
# test program? OR for this one? Just in case, start that
# empty string here;
my $addl_obj_files = "";
print "What is the NAME of the function you wish to work on?\n";
print "\n";
print "function name: ";
chomp($funct_name = <STDIN>);
#email#print RECORD "function being worked on: $funct_name\n";
print "\n";
print "Is $funct_name a NEW function? (not already existing?)\n";
print " (note: if you say n (for no), then this script assumed that this\n";
print " function is in a file in the current working directory named\n";
print " ${funct_name}\.cpp)\n";
print "\n";
print "answer y if it is NEW, or n if it EXISTS: ";
my $reply;
chomp($reply = &get_y_or_n());
#-----
# PART 3: if function is NEW
#-----
if ($reply eq "y")
{
print "\n";
#email# print RECORD " ...and it is a NEW function\n";
# HERE PLEASE --- I need to grab info to build #include's for NEW function,
# AND for eventual TEST program I'd like to build to USE this function.
# BUT --- how can I get AFTER if already exists? Grrr!
# should I simply SEPARATE expr_play2 from this (so you simply cannot
# test here at all? Ask for all those involved over there? MIGHT it work?)
# at this point, I know that certain #include's will be necessary for
# the eventual test program generated by this Perl script. I'll start
# these here, so that I can add to it if the user wants to use
# functions they've defined previously in the new function.
# for debugging purposes...
#print "initial \#include statements:\n";
#print "--------------------------\n";
#print "$include_stmts";
#print "--------------------------\n";
# for debugging purposes...
#print "initial .o files:\n";
#print "--------------------------\n";
#print "$addl_obj_files\n";
#print "--------------------------\n";
#-----
# PART 3a: Are there any existing functions (currently limited
# to the current working directory) that the student wishes to
# be able to use in his/her new function? If so, get their names
# from the student, and set up what is required for their use
# in the new function to come.
#-----
print "\n";
print "WITHIN your new function $funct_name,\n";
print " are there any ALREADY-created C++ functions (in the current\n";
print " working directory) which you would like to be able to USE?\n";
print " (type y if so, n if not)\n";
print "\n";
print "your answer: ";
$reply = &get_y_or_n();
# IF user answers yes, then get the names of already-created
# functions, set up for their use in the new function to come
if ($reply eq "y")
{
#email# print RECORD " ...and it WILL use some other functions:\n";
print "\n";
print "NOTE #1: do not try to continue with $funct_name until\n";
print " you have ALREADY successfully compiled those \n";
print " functions that $funct_name uses!\n";
print "\n";
print "Enter the name of an already-created function (created \n";
print " in the current directory), or q to quit:\n";
print "\n";
print "OLD function name: ";
chomp(my $old_funct = <STDIN>);
while ($old_funct ne "q")
{
#email# print RECORD " $old_funct";
my $old_funct_source = "${old_funct}\.cpp";
my $old_funct_hdr = "${old_funct}\.h";
# make sure that the source code for this function exists
if (! -e $old_funct_source)
{
print "\n";
print " There is no source code file $old_funct_source\n";
print " for function $old_funct; this function cannot\n";
print " be used in your new function.\n";
print "\n";
#email# print RECORD "... but NO source for it here!\n";
}
# make sure that the header file for this function exists
elsif (! -e $old_funct_hdr)
{
print "\n";
print " There is no header file $old_funct_hdr\n";
print " for function $old_funct; this function cannot\n";
print " be used in your new function.\n";
print "\n";
#email# print RECORD "... but NO header for it here!\n";
}
else
{
# if reach here, BOTH the .cpp and .h files exist for
# this function;
#email# print RECORD "... and BOTH .cpp, .h are here\n";
# IF there is not currently a .o file for this function,
# attempt to create one;
if (! -e "${old_funct}\.o")
{
my $ret_val = system("g++ -c $old_funct_source");
if (($ret_val != 0) || (! -e "${old_funct}\.o"))
{
print "\n";
print "Beware --- there was a problem trying to create\n";
print " a .o file for $old_funct.\n";
print "\n";
#email# print RECORD " (but could NOT create .o)\n";
}
}
# at this point, either a .o file exists for this
# function, or we have attempted to create one;
# add #include for this function to those for eventual
# test program for new function
$include_stmts .= "#include \"$old_funct_hdr\"\n";
# add object file for this function for use in eventual
# compilation of eventual test program for new function
$addl_obj_files .= "${old_funct}\.o ";
# add name for this function for use to list in possible-
# functions when testing later
$other_desired_funct_names .= "\n$old_funct";
# print CONTENTS of .cpp, .h files to mail record;
#email# print RECORD " CONTENTS:\n";
#email# print RECORD "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
#email# $header_guts = `cat ${old_funct}.h`;
#email# print RECORD "$header_guts\n";
#email# print RECORD "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
#email# $funct_guts = `cat ${old_funct}.cpp`;
#email# print RECORD "$funct_guts\n";
#email# print RECORD "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
}
print "\n";
print "Enter the next name of an already-created function \n";
print " (created in the current directory), or q to quit:\n";
print "\n";
print "OLD function name: ";
chomp($old_funct = <STDIN>);
}
}
# print statements verifying that DID build desired #includes and .o
# based on old functions student wants new function to be able to use
#
#print "\n";
#print "AFTER old-funct loop, here are the resulting include statements\n";
#print "and object files:\n";
#
#print "newest set of \#include statements:\n";
#print "--------------------------\n";
#print "$include_stmts";
#print "--------------------------\n";
#
#print "newest set of .o files:\n";
#print "--------------------------\n";
#print "$addl_obj_files\n";
#print "--------------------------\n";
#-----
# PART 3b - finally, let's grab the new function, the whole purpose of
# this script...! 8-) prompt them for the necessary "pieces"
#-----
#-----
# design recipe step 1.1: write the CONTRACT for the function
#-----
print "\n";
print "--- Entering the new function $funct_name ---\n";
#email# print RECORD " trying to enter new function $funct_name\n";
print "\n";
print "***** DESIGN RECIPE STEP 1.1: *****\n";
print "Enter the contract for the function $funct_name, using format:\n";
print " $funct_name : parameter_type parameter_type ... -> return_type\n";
print "\n";
print "Contract: $funct_name : ";
chomp(my $funct_contract = <STDIN>);
# oh, let's tack on a label so they'll KNOW it's the contract...
$funct_contract = "Contract: $funct_name : " . $funct_contract;
print "\n";
print "Your contract for $funct_name is:\n";
print "--------------------------------------------------------\n";
print "$funct_contract\n";
print "--------------------------------------------------------\n";
#email# print RECORD " Contract: $funct_contract\n";
#-----
# design recipe step 1.2: write the HEADER for the function
#-----
print "\n";
print "***** DESIGN RECIPE STEP 1.2: *****\n";
print "Enter the header for the function, using the format:\n";
print " return_type $funct_name (param_type param_name, ...)\n";
print "\n";
print "Function header:\n";
chomp($funct_header = <STDIN>);
# not doing much error checking yet --- but can at least make sure that
# the header contains the function name within it *somewhere*!
while (! ($funct_header =~ /$funct_name/))
{
print "\n";
print "A function header must contain the name of the function!\n";
print "Please enter the function header again, including $funct_name\n";
print " this time:\n";
print "Function header:\n";
chomp($funct_header = <STDIN>);
}
print "\n";
print "Your header for $funct_name is:\n";
print "-------------------------------------------------\n";
print "$funct_header\n";
print "-------------------------------------------------\n";
#email# print RECORD " Header: $funct_header\n";
#-----
# design recipe step 1.3: write the PURPOSE STATEMENT for the function
#-----
print "\n";
print "***** DESIGN RECIPE STEP 1.3: *****\n";
print "Enter a purpose statement for the function $funct_name, \n";
print " \"a brief comment of what the function is to compute\" [HtDP,\n";
print " p. 18]; including the parameter names.\n";
print "(enter a line containing NOTHING but q and typing the Enter key\n";
print " to show when your purpose statement is complete):\n";
print "\n";
print "Purpose: ";
my $next_line = <STDIN>; # I want to KEEP the newline, true?
my $purpose_stmt = "Purpose: ";
while (! ($next_line =~ /^\s*q\s*$/))
{
$purpose_stmt .= $next_line;
$next_line = <STDIN>;
}
print "\n";
print "Purpose statement:\n";
print "---------------------------------------------------------------\n";
print "$purpose_stmt";
print "---------------------------------------------------------------\n";
#email# print RECORD " $purpose_stmt\n";
#-----
# design recipe step 2: write EXAMPLES for the function
# (for now, this will just be text put in a comment. Later,
# perhaps I can read it in in such a way as to "plug in" those
# calls into the generated test program?)
#-----
print "\n";
print "***** DESIGN RECIPE STEP 2: *****\n";
print "Enter at least one example call of function $funct_name\n";
print " including input(s) and the expected output given those\n";
print " input(s); for example,\n";
print " my_funct(3, 4) should return 12\n";
print " my_funct(0, 0) should return -3\n";
print "(enter a line containing NOTHING but q and typing the Enter key\n";
print " to show when you have entered all of your examples):\n";
print "\n";
print "Examples: ";
$next_line = <STDIN>; # I want to KEEP the newline, true?
my $examples = "Examples: ";
while (! ($next_line =~ /^\s*q\s*$/))
{
$examples .= $next_line;
$next_line = <STDIN>;
}
print "\n";
print "Examples:\n";
print "---------------------------------------------------------------\n";
print "$examples";
print "---------------------------------------------------------------\n";
#email# print RECORD "$examples\n";
#-----
# ASIDE before design recipe step 3 --- any NAMED CONSTANTS you want
# to declare?
#-----
print "\n";
print "BEFORE you type in ${funct_name}'s body --- are there any\n";
print " NEW named constants that you want to CREATE?\n";
print " (answer y or n):\n";
print "\n";
print "your reply: ";
$reply = &get_y_or_n();
while ($reply eq "y")
{
print "\n";
print "type in your new named constant declaration: \n";
print "\n";
print "new declaration: \n";
my $new_const_decl = <STDIN>;
$also_for_hdr_file .= $new_const_decl;
print "\n";
print "do you have another named constant declaration?\n";
print " (enter y or n):\n";
print "\n";
print "your reply: ";
$reply = &get_y_or_n();
}
print "\n";
print "NOTE --- if a named constant was already declared for an\n";
print " OLD function that $funct_name calls, then it SHOULD be \n";
print " visible for use in $funct_name, too...\n";
#-----
# design recipe step 3: write the BODY of the function
#-----
print "\n";
print "***** DESIGN RECIPE STEP 3 *****\n";
print "Enter the body of the $funct_name (the part following the header),\n";
print " being sure to include the { and } that should enclose it.\n";
print "(enter a line containing NOTHING but q and typing the Enter key\n";
print " to show when ${funct_name}\'s body is complete):\n";
print "\n";
print "Enter body following the header:\n";
print "\n";
print "$funct_header\n";
$next_line = <STDIN>; # I want to KEEP the newline, true?
my $funct_body = "";
while (! ($next_line =~ /^\s*q\s*$/))
{
$funct_body .= $next_line;
$next_line = <STDIN>;
}
print "\n";
print "${funct_name}\'s body:\n";
print "----------------------------------------------------------------\n";
print "$funct_body";
print "----------------------------------------------------------------\n";
#email# print RECORD "$funct_body\n";
#-----
# PART 3c: "build" the .cpp file and .h file for the function,
# and try to compile it
#-----
# create a file to contain the new C++ function
open FUNCT_FILE, "> ${funct_name}\.cpp"
or die "Cannot open ${funct_name}\.cpp for writing: $!";
print FUNCT_FILE "/*--------------------------------------------------\n";
print FUNCT_FILE "created by $who at ";
chomp(my $funct_create_time = `date`);
print FUNCT_FILE "$funct_create_time\n";
print FUNCT_FILE "--------------------------------------------------*/\n";
print FUNCT_FILE "$include_stmts";
# IF user added any named constants, AND I want to add them to
# $funct_name.h, then don't I have to INCLUDE $funct_name.h here,
# too?
# (BUT --- there should ONLY be such if $also_for_hdr_file is NON-empty,
# I think...)
if ($also_for_hdr_file ne "")
{
print FUNCT_FILE "#include \"${funct_name}\.h\"\n";
}
print FUNCT_FILE "\n";
print FUNCT_FILE "/*--------------------------------------------------\n";
print FUNCT_FILE " $funct_contract";
print FUNCT_FILE "\n";
print FUNCT_FILE " $purpose_stmt";
print FUNCT_FILE "\n";
print FUNCT_FILE " $examples";
print FUNCT_FILE "--------------------------------------------------*/\n";
print FUNCT_FILE "$funct_header\n";
print FUNCT_FILE "$funct_body";
print FUNCT_FILE "\n";
close FUNCT_FILE;
#email# print RECORD " ${funct_name}\.cpp created\n";
#-----
# since now have function .cpp file --- better create its initial
# .h file, too (so don't have to parse .cpp yet to create it
# later!)
#----
open HDR_FILE, "> ${funct_name}.h"
or die "Cannot open ${funct_name}.h for writing: $!";
print HDR_FILE "/*--------------------------------------------------\n";
print HDR_FILE " header file for function $funct_name\n";
print HDR_FILE " created by $who at ";
chomp(my $hdr_create_time = `date`);
print HDR_FILE "$hdr_create_time\n";
print HDR_FILE "--------------------------------------------------*/\n";
print HDR_FILE '#ifndef' . " ${funct_name}_H\n";
print HDR_FILE '#define' . " ${funct_name}_H\n";
print HDR_FILE "\n";
# and --- we're trying to put any "new" named constant declarations
# here...
# (BUT --- there should ONLY be such if $also_for_hdr_file is NON-empty,
# I think...)
if ($also_for_hdr_file ne "")
{
print HDR_FILE "$also_for_hdr_file\n";
}
print HDR_FILE "$funct_header;\n";
print HDR_FILE "\n";
print HDR_FILE '#endif' . "\n";
close HDR_FILE;
#email# print RECORD " ${funct_name}\.h created\n";
}
#-----
# PART 4: if working on function CREATED EARLIER...
#----
else
{
# what if you created this function earlier, and are now correcting it?
# You surely don't want to type the purpose, header, etc. in again!
# So --- perhaps we could simply open it, in that case;
# if a .cpp file with this function's name does not exist ---
# complain and exit
if (! -e "${funct_name}\.cpp")
{
print "\n";
print "Could not find file ${funct_name}.cpp in the current\n";
print " directory --- goodbye.\n";
#email# &finish_record("tried to work with EXISTING function $funct_name" .
#email# " whose .cpp didn't exist");
exit(1);
}
system("pico ${funct_name}\.cpp");
# print resulting contents of function definition into record
#email# print RECORD "\n RESULT AFTER EDITING $funct_name:\n";
#email# print RECORD "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
#email# $header_guts = `cat ${funct_name}.h`;
#email# print RECORD "$header_guts\n";
#email# print RECORD "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
#email# $funct_guts = `cat ${funct_name}.cpp`;
#email# print RECORD "$funct_guts\n";
#email# print RECORD "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
print "Do you want to edit ${funct_name}\.h?\n";
print "(please enter y or n): ";
$reply = &get_y_or_n();
if ($reply eq "y")
{
system("pico ${funct_name}\.h");
#email# print RECORD "\n RESULT AFTER EDITING $funct_name HEADER ONLY:\n";
#email# print RECORD "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
#email# $header_guts = `cat ${funct_name}.h`;
#email# print RECORD "$header_guts\n";
#email# print RECORD "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
}
}
#-----
# PART 5 - whew! Have either entered new function, or modified an
# old one --- ready to compile if reach here, either way!
#-----
print "\n";
print "COMPILING ${funct_name}\.cpp...\n";
print "-----------------------------------------------------------------\n";
my $ret_val = system("g++ -c ${funct_name}\.cpp");
# I am hoping very hard that a return value of 0 means the compilation
# was successful;
if ($ret_val == 0)
{
print "${funct_name}\.cpp COMPILED! 8-)\n";
#email# print RECORD " ${funct_name}\.cpp compiled!\n";
#email# print "Now you can try to RUN it using expr_play2...\n";
}
else
{
print "\n";
print "---------------------------------------------------------\n";
print "${funct_name}\.cpp DIDN'T compile! 8-(\n";
print " (above are the C++ compiler's error messages...)\n";
print "edit ${funct_name}\.cpp and then try funct_play2 again,\n";
print " (or call funct_play2 again, and tell it function DOES\n";
print " already have a file in the current directory...)\n";
print "\n";
#email# &finish_record(" ${funct_name}.cpp did not successfully compile\n");
exit(1);
}
#-----
# PART 6: enter desired expressions? OR build a program that asks for
# each parameter, and then dynamically calls? (Might the latter be more
# efficient? Each new "expr" using the function then wouldn't require
# another recompile! But, gotta parse out # of arguments --- that's
# for next version, I think.)
#-----
#
# question: actually include the function within the main(), or #include
# a .h file for it? But for the latter, I'd need to create a .h as well
# as a .cpp for each function, and then change the compilation command
# accordingly; hmm.
#
# hm; first, let's just paste the raw code in.
# to do this, I can solicit the header and body, put it in a .cpp file
# named based on the function name, and then use the header to build
# the function definition, and the .cpp file to build the function
# declaration after main() --- right?
# (wonder how slow this'll be? shudder...)
#
# (and I may just #include it, after all, after looking at multi-file
# example in c++_reference directory. Hmm.)
#
# IF they give me a header --- CAN a function declaration include parameter
# names? Can a .h file? (Is this not required, or not allowed?)
# the student must enter the purpose statement for their function
# first --- might this get them into the habit of coming up
# with a purpose statement early on? It's worth a shot...
# now that all is set up --- permit expressions to be
# entered for evaluation (hopefully including some
# involving the newly-created functions!)
#print "\n";
#print "Enter a C++ expression involving:\n$funct_name" .
# (won't this fail, now? if old funct, no longer asking what it uses!)
# (BUT won't new .h approach help? I'm not sure...)
# "$other_desired_funct_names" .
# "\n...and type enter\n";
#print " (or type q to quit):\n";
#chomp(my $expr = <STDIN>);
# shall we create each expression's program in a separate file,
# or not? Hmm... For now, yes.
#my $expr_ct = 0;
# BEFORE start trying to handle expressions, though --- I may need
# .o files for functions USED by my new function!
# IF it was new --- I've got 'em ($addl_obj_files)
# IF not --- I don't! BUT I might be able to CONSTRUCT them...
#if ($addl_obj_files eq "")
#{
# &grab_dependencies($funct_name);
## open FUNCT_FILE, "< ${funct_name}\.cpp"
## or die "Cannot open ${funct_name}\.cpp: $!";
##
## # look for #include's with "dependencies"
##
## while (<FUNCT_FILE>)
## {
## chomp($line = $_);
##
## if (($line =~ /#include "(.*)\.h"/) && ($1 ne $funct_name))
## {
## $addl_obj_files .= "$1\.o ";
## print "LOOK! $addl_obj_files\n";
##
## }
## }
##
## close FUNCT_FILE;
#}
# keep handling expressions until the user wishes to quit
#while ($expr ne 'q')
#{
# print "\n";
# $expr_ct++;
# create a C++ program to execute this expression
# open TESTER, "> try_expr$expr_ct.cpp"
# or die "Cannot open try_expr$expr_ct.cpp for writing: $!";
# this will include other functions they've mentioned wanting
# to use --- is that okay? THEN need to tack new function's
# .h file, too!
# print TESTER "$include_stmts";
# print TESTER "#include \"${funct_name}\.h\"\n";
# print TESTER "\n";
# print TESTER "int main()\n";
# print TESTER "{\n";
# print TESTER " cout << \"value of $expr: \" << endl;\n";
# print TESTER " cout << $expr << endl;\n";
# print TESTER "}\n";
# print TESTER "\n";
# close TESTER;
# this need to include .o file for new function, doesn't it?
# my $ret_val = system("g++ -o try_expr$expr_ct try_expr$expr_ct.cpp " .
# "$addl_obj_files ${funct_name}\.o");
# I am hoping very hard that a return value of 0 means the compilation
# was successful;
# if ($ret_val == 0)
# {
# system("try_expr$expr_ct");
# print RECORD " GOOD: ";
# }
# else
# {
# print "*****************************************************\n";
# print "Are you sure that $expr is truly a C++ arithmetic\n";
# print " expression (with no variables)?\n";
# print "Chances are good that it is not; the above are C++\n";
# print " compiler messages. Save them and show them to \n";
# print " your prof if you have questions.\n";
# print "*****************************************************\n";
# print RECORD " BAD: ";
# }
# # save a record of this attempt (to be emailed to me at the
# # end of this loop...)
# my $when = `date`;
# print RECORD " tried expression #$expr_ct: $expr at $when\n";
# # clean up --- remove latest expression's C++ files
# unlink "try_expr$expr_ct.cpp";
# if ($ret_val == 0)
# {
# unlink "try_expr$expr_ct";
# }
# print "\nEnter next C++ expression and type enter\n";
# print " (or type q to quit):\n";
# chomp($expr = <STDIN>);
#}
#email#&finish_record("reached end of funct_play2 script");
print "\nQuitting funct_play2 ... goodbye.\n\n";
# end of funct_play2