@verb #62:"set" this none this rxdo #60 @program #62:"set" this none this ":set(optionlist,oname,value) => raised E_TYPE or revised optionlist." "oname must be the full name of an option in .names or .extras." "FALSE (0, blank string, or empty list) is always a legal value." "If a verb :check_foo is defined on this, it will be used to typecheck any" "non-false or object-type value supplied as a new value for option `foo'." "" " :check_foo(value) => E_TYPE or {value to use}" "" "If instead there is a property .check_foo, that will give either the expected " "type or a list of allowed types." "Otherwise, the option is taken to be a boolean flag and all non-false, " "non-object values map to 1." "" {options, oname, value} = args if (!(oname in this.names || oname in this.extras)) raise(E_TYPE, "Unknown option: " + oname) elseif (!value && typeof(value) != $OBJ) "... always accept FALSE (0, blankstring, emptylist)..." elseif (this:has_callable_verb(check = "check_" + oname)) "... a :check_foo verb exists; use it to typecheck the value..." value = this:(check)(value) elseif (this:has_property(tprop = "type_" + oname)) "... a .type_foo property exists..." "... property value should be a type or list of types..." if (!this:istype(value, t = this.(tprop))) raise(E_TYPE, $su:capitalize(this:desc_type(t) + " value expected.")) endif elseif (this:has_property(cprop = "choices_" + oname)) "... a .choices_foo property exists..." "... property value should be a list of {value,docstring} pairs..." if (!listassoc(value, c = this.(cprop))) raise(E_TYPE, "Allowed values: " + $su:english_list($list_utils:slice(c, 1), "(??)", " or ")) endif else "... value is considered to be boolean..." if (!value) "... must be an object. oops." raise(E_TYPE, "Non-object value expected.") endif value = 1 endif "... We now have oname and a value. However, if oname is one of the extras," "... then we need to call :actual to see what it really means." if (oname in this.names) nvlist = {{oname, value}} else nvlist = this:actual(oname, value) endif "... :actual returns a list of pairs..." for nv in (nvlist) {oname, value} = nv if (i = oname in options || listiassoc(oname, options)) if (!value && typeof(value) != $OBJ) "value == 0, blank string, empty list" options[i..i] = {} elseif (value == 1) options[i] = oname else options[i] = {oname, value} endif elseif (value || typeof(value) == $OBJ) options[1..0] = {value == 1 ? oname | {oname, value}} endif endfor return options "Last modified by Dax (#789) on Wed May 4 06:44:31 2005 MDT." .