How to list Context flags

From WeBWorK_wiki
Revision as of 07:16, 14 August 2012 by Dpvc (talk | contribs) (Fix some formatting)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

There is an explanation of the purpose of many of these flags at Context flags.

Listing Context Flags using PGLabs

You can obtain a complete list of contextFlags from one of the current contexts using the PGLabs and this code snippet:

Context("Vector");
TEXT(Context()->{name}, $BR);
TEXT(pretty_print(Context()->{flags}));

You could also load in one of the customized contexts such as contextCurrency.pl

loadMacros("contextCurrency.pl");
Context("Currency");
Context()->flags->set(trimTrailingZeros=>1);
TEXT(Context()->{name}, $BR);
TEXT(pretty_print(Context()->{flags}));

which will produce the output below. Notice that the trimTrailingZeros flag has been set to 1 (the default is 0 ).


Currency
HASH(0xc8c1988)

allowBadFunctionInputs

=>

 0

allowBadOperands

=>

 0

allowEmptyStrings

=>

 1

allowMissingFunctionInputs

=>

 0

allowMissingOperands

=>

 0

allowWrongArgCount

=>

 0

checkUndefinedPoints

=>

 0

forceCommas

=>

 0

forceDecimals

=>

 0

formatStudentAnswer

=>

 evaluated

granularity

=>

 1000

ignoreEndpointTypes

=>

 0

ijk

=>

 0

ijkAnyDimension

=>

 1

infiniteWord

=>

 infinity

limits

=>

 ( -2 , 2 , )

max_adapt

=>

 100000000

max_undefined

=>

 

noExtraDecimals

=>

 1

num_points

=>

 5

promoteReals

=>

 1

reduceConstantFunctions

=>

 1

reduceConstants

=>

 1

reduceSets

=>

 1

reduceSetsForComparison

=>

 1

reduceUnions

=>

 1

reduceUnionsForComparison

=>

 1

resolution

=>

 

showExtraParens

=>

 1

tolType

=>

 absolute

tolerance

=>

 0.005

trimTrailingZeros

=>

 1

useBaseTenLog

=>

 0

useFuzzyReals

=>

 1

zeroLevel

=>

 1e-14

zeroLevelTol

=>

 1e-12

Listing Context Flags in an existing WeBWorK question

  • Set your Context, e.g.
Context("Your Context Here");  #  or don't do anything to see flags from the current context
  • Enter the text
TEXT(pretty_print(Context()->{flags}));
  • View the problem

See also

The file PGinfo.pl has other macros that can be used in a PG problem to discover what flags and constants are defined in the current environment type:

loadMacros("PGinfo.pl");
listVariables();

This will print (too much) information -- but it's useful for debugging and for learning the language.

See http://webwork.maa.org/doc/cvs/pg_CURRENT/macros/PGinfo.pl.html