[system] / trunk / pg / macros / PGinfo.pl Repository:
ViewVC logotype

View of /trunk/pg/macros/PGinfo.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5707 - (download) (as text) (annotate)
Fri Jun 20 14:40:35 2008 UTC (11 years, 7 months ago) by gage
File size: 2269 byte(s)
An experimental collection of macros designed as a first attempt
to make writing sequential problems easier (Davide Cervone principal author)
The rules for using these macros may well change as we gain experience writing
sequential problems.  (See also PGsequentialmacros.pl for some additional, lower level tools.)

    1 
    2 ####################################################################
    3 # Copyright @ 1995-2007 University of Rochester
    4 # All Rights Reserved
    5 ####################################################################
    6 
    7 =head1 NAME
    8 
    9   PGinfo.pl
   10 
   11 
   12 Provides macros for determining the values of the current context in which the problem
   13 is being written.
   14 
   15 =cut
   16 
   17 
   18 loadMacros("MathObjects.pl");
   19 
   20 
   21 
   22 
   23 
   24 =head3  listVariables
   25 
   26 Usage:  listVariables();
   27 
   28 Prints all variables submitted in the problem form and all variables in the
   29 the Problem environment and all of the flag variables in Context().
   30 This is used for debugging and to determine the current
   31 context for the problem.
   32 
   33 =cut
   34 
   35 
   36 sub listVariables {
   37   TEXT($HR,"Form variables",$BR );
   38   listFormVariables();
   39   TEXT($HR,"Environment variables",$BR );
   40   listEnvironmentVariables();
   41   TEXT($HR,"Context flags",$BR );
   42   listContextFlags();
   43 }
   44 
   45 =head4 listFormVariables()
   46 
   47   Called by listVariables to print out the input form variables.
   48 
   49 =cut
   50 
   51 sub listFormVariables {
   52     # Lists all of the variables filled out on the input form
   53   # Useful for debugging
   54     TEXT(pretty_print($inputs_ref));
   55 
   56 }
   57 
   58 =head4 listEnvironmentVariables()
   59 
   60   Called by listVariables to print out the environment variables (in %envir).
   61 
   62 =cut
   63 
   64 
   65 sub listEnvironmentVariables {
   66     # list the environment variables
   67     TEXT(pretty_print(\%envir));
   68 }
   69 
   70 =head4 listContextFlags()
   71 
   72   Called by listVariables to print out context flags for Math Objects.
   73 
   74 =cut
   75 
   76 sub listContextFlags {
   77   my $context = $$Value::context->{flags};
   78   TEXT(pretty_print($context));
   79 }
   80 
   81 =head3 listContext()
   82 
   83   Usage:  listContext(Context())
   84 
   85   Prints out the contents of the current context hash -- includes flags and much more
   86 
   87 =cut
   88 
   89 sub listContext {  # include
   90   my $context = shift;
   91   return TEXT("$PAR Error in listContext:  usage:  listContext(Context()); # must specify a context to list $BR") unless defined $context;
   92   foreach $key (keys %$context) {
   93     next if $key =~/^_/; # skip if it begins with
   94     TEXT($HR, $key, $BR);
   95     TEXT( pretty_print($context->{$key}) );
   96   }
   97 }
   98 
   99 =head3 pp()
  100 
  101   Usage:  pp(Hash );
  102           pp(Object);
  103 
  104 
  105   Prints out the contents of Hash or the instance variables of Object
  106 
  107 =cut
  108 
  109 sub pp {
  110     my $hash = shift;
  111     "printing |". ref($hash)."|$BR". pretty_print($hash);
  112 }
  113 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9