## Forum archive 2000-2006

### Michael Gage - set_default_options

by Arnold Pizer -
Number of replies: 0
 set_default_options topic started 8/13/2001; 8:08:31 AMlast post 8/13/2001; 8:08:31 AM
Michael Gage - set_default_options
8/13/2001; 8:08:31 AM (reads: 1943, responses: 0)

### set_default_options

Description
This utility subroutine can be used within any subroutine, evaluator or filter which uses options. It provides a uniform way to set default options. It should be preceeded by assign_option_aliases. This is principally intended for use in macros.

Syntax

set_default_options($rh_options, %default_options) Params $rh_options -- reference to the hash containing the options received by the parent subroutine
%default_options-- contains a list of possible options and their default values allowed by the parent subroutine.

Action

All default options which are not already defined in the received option hash (%$rh_options) are defined with the prescribed default options. If there are any options in %$rh_options which do not have a corresponding entry in the hash of default options an error will be signaled, UNLESS the option 'allow_unknown_aliases' in the default option hash is set to 1 in which case unknown options in the received option hash do not trigger an error.

Returns

Nothing

Notes

Setting 'allow_unknown_aliases' to 1 allows the use of a single long option hash for several subroutines. Each subroutine will take only the options it needs and will ignore the others without triggering an error. This can be very convenient, however in this case there is no error checking for misspelled option names. Whenever possible subroutines that will be used directly by authors of problems should set the 'allow_unknown_aliases' option to false ( or equivalently, omit it completely) in order to provide better error checking when writing problems.