[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 4828 - (download) (as text) (annotate)
Sun Mar 4 21:06:17 2007 UTC (12 years, 11 months ago) by gage
File size: 2121 byte(s)
Use this macro package to define macros for
examining the current environment.  Useful for
creating problems and for debugging.

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9