How to list Context flags: Difference between revisions
(Fix some formatting) |
|||
| (6 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
There is an explanation of the purpose of many of these flags at [[ | There is an explanation of the purpose of many of these flags at [[Context flags]]. | ||
== Listing Context Flags using PGLabs == | == Listing Context Flags using PGLabs == | ||
| Line 6: | Line 6: | ||
Context("Vector"); | Context("Vector"); | ||
TEXT(Context()->{name}, $BR); | TEXT(Context()->{name}, $BR); | ||
TEXT(pretty_print( Context()->{flags} )); | TEXT(pretty_print(Context()->{flags})); | ||
You could also load in one of the customized contexts such as <code>contextCurrency.pl</code> | You could also load in one of the customized contexts such as <code>contextCurrency.pl</code> | ||
| Line 14: | Line 14: | ||
Context()->flags->set(trimTrailingZeros=>1); | Context()->flags->set(trimTrailingZeros=>1); | ||
TEXT(Context()->{name}, $BR); | TEXT(Context()->{name}, $BR); | ||
TEXT(pretty_print( Context()->{flags} )); | 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 ). | which will produce the output below. Notice that the trimTrailingZeros flag has been set to 1 (the default is 0 ). | ||
| Line 373: | Line 373: | ||
</td> | </td> | ||
<td> | <td> | ||
| 1 | ||
</td> | </td> | ||
</tr> | </tr> | ||
| Line 426: | Line 426: | ||
* Set your Context, e.g. | * Set your Context, e.g. | ||
Context( | |||
Context("Your Context Here"); # or don't do anything to see flags from the current context | |||
* Enter the text | * Enter the text | ||
TEXT(pretty_print(Context()->{flags})); | |||
* View the problem | * View the problem | ||
| Line 443: | Line 443: | ||
listVariables(); | listVariables(); | ||
This will print (too much) information. | 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 | See http://webwork.maa.org/doc/cvs/pg_CURRENT/macros/PGinfo.pl.html | ||
[[Category:Contexts]] | [[Category:Contexts]] | ||
[[Category:MathObjects]] | [[Category:MathObjects]] | ||
[[Category:AIMWeBWorK Working Groups]] | |||
Latest revision as of 11:16, 14 August 2012
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