## Forum archive 2000-2006

### Michael Gage - assign_option_aliases -- utility subroutine

by Arnold Pizer -
Number of replies: 0
 assign_option_aliases -- utility subroutine topic started 8/28/2001; 1:01:50 AMlast post 8/28/2001; 1:01:50 AM
Michael Gage - assign_option_aliases -- utility subroutine
8/28/2001; 1:01:50 AM (reads: 1837, responses: 0)

### assign_option_aliases -- utility subroutine

Description
This utility subroutine can be used within any subroutine, evaluator or filter which uses options. It provides a uniform way to alias option values. For example the domain of a function tested by fun_cmp can be specified either by limits => [0,5] (the principle option) or by domain => [0,5] . (domain is an alias for limits).

Syntax

set_option_aliases($rh_options, %alias2option ) Params $rh_options -- reference to the hash containing the options received by the parent subroutine
%alias2option-- contains a list of possible aliases and the option they are assigned to:
 %alias2option = ( alias1 => option1, alias2 => option1, alias3 => option2 )

Action

If the option itself is defined in the options received by the parent subroutine then any aliases which are also received are ignored. An assignment to the actual option has priority, after which the FIRST alias assigned to the option which is listed in the option hash received by the parent subroutine. (In other words, once an option receives a value, subsequent assignments through aliases are ignored.)

Returns

Nothing. But it modifies the contents pointed to by $rh_options. Examples from fun_cmp :  assign_option_aliases( \%opt, 'domain' => 'limits', # set the standard option 'limits' to the one specified as domain 'vars' => 'var', # set the standard option 'var' to the one specified as vars 'reltol' => 'relTol', 'param' => 'params', ); set_default_options( \%opt, 'var' =>$functVarDefault, 'params' => [], 'limits' => [[$functLLimitDefault,$functULimitDefault]], 'mode' => 'std', 'tolType' => (defined($opt{tol}) ) ? 'absolute' : 'relative', 'tol' => .01, # default mode should be relative, if the tol option is defined, the mode is absolute 'relTol' =>$functRelPercentTolDefault, 'numPoints' => $functNumOfPoints, 'maxConstantOfIntegration' =>$functMaxConstantOfIntegration, 'zeroLevel' => $functZeroLevelDefault, 'zeroLevelTol' =>$functZeroLevelTolDefault, 'debug' => 0, );

Notes

This subroutine must preceed set_default_options. (Otherwise all options will have SOME value, and this subroutine will have no affect.)

This subroutine is at the end of the macro file PGanswermacros.pl