Changeset 5b1390 in git


Ignore:
Timestamp:
Dec 20, 2013, 7:00:03 PM (9 years ago)
Author:
Jakob Kröker <kroeker@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
d1280f11e9d71dd9d45c276dfc5619bd557fba32
Parents:
4e4e24bd5220c690dc16529b1fb431b5ef67482c
git-author:
Jakob Kröker <kroeker@math.uni-hannover.de>2013-12-20 19:00:03+01:00
git-committer:
Jakob Kroeker <kroeker@uni-math.gwdg.de>2014-01-28 11:47:55+01:00
Message:
add optionIsSet proposal
added check if an option is valid to optionIsSet
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/ring.lib

    r4e4e24b r5b1390  
    2222 rootofUnity(n);          the minimal polynomial for the n-th primitive root of unity
    2323             (parameters in square brackets [] are optional)
     24 optionIsSet(opt)         check if as a string given option is set or not.
    2425";
    2526
     
    2728LIB "general.lib";
    2829LIB "primdec.lib";
     30
     31///////////////////////////////////////////////////////////////////////////////
     32proc optionIsSet(string optionName)
     33"
     34USAGE:       @code{optionIsSet( optionName );}
     35PARAMETERS:  @code{optionName}: a name(string) of an option of interest
     36RETURN:      true, if the by  @code{optionName} given option is active, false otherwise.
     37EXAMPLE:     example optionIsSet;
     38"
     39{
     40   def op = option(get);
     41   //sanity check, if option is valid. will raise an error if not
     42   option(optionName);    option("no" + optionName);
     43   option(set,op);
     44   // first entry is currently a comment "//options:", which is not an option.
     45   int pos = find(option(), optionName, 11 );
     46   return(pos>0);
     47}
     48example
     49{
     50    // check if the option "warn" is set.
     51    optionIsSet("warn");
     52    option("warn");
     53    // now the option is set
     54    optionIsSet("warn");
     55
     56    option("nowarn");
     57    // now the option is unset
     58    optionIsSet("warn");
     59}
     60
     61
     62static proc testOptionIsSet()
     63{
     64     option("warn");
     65     ASSUME(0, optionIsSet("warn") );
     66     option("nowarn");
     67     ASSUME(0, 0 == optionIsSet("warn") );
     68}
     69
    2970///////////////////////////////////////////////////////////////////////////////
    3071
Note: See TracChangeset for help on using the changeset viewer.