Changeset 3056 for trunk/lang/tcl/scripts
- Timestamp:
- Jun 25, 2012, 3:43:37 PM (12 years ago)
- Location:
- trunk/lang/tcl/scripts
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lang/tcl/scripts/Makefile.in
r2698 r3056 61 61 62 62 TYPEFILES = \ 63 $(srcdir)/types/atomactive.tcl \ 64 $(srcdir)/types/atomelem.tcl \ 65 $(srcdir)/types/atomprops.tcl \ 63 66 $(srcdir)/types/boolean.tcl \ 64 67 $(srcdir)/types/choices.tcl \ -
trunk/lang/tcl/scripts/objects/periodicelement/periodicelement.rp
r2638 r3056 18 18 help http://rappture.org/wiki/rp_xml_ele_periodicelement 19 19 20 attr active -title "Active Elements" \ 21 -type string -path default -only input \ 22 -tooltip "Specifies the set of elements that can be selected.\n\nCan be a list of element symbols or groups: actinoid, alkali-metal, alkaline-earth-metal, halogen, lanthanoid, metalloid, noble-gas, other-non-metal, post-transition-metal, transition-metal, or unknown." 23 attr inactive -title "Inactive Elements" \ 24 -type string -path default -only input \ 25 -tooltip "Specifies the set of elements that can't be selected.\n\nCan be a list of element symbols or groups: actinoid, alkali-metal, alkaline-earth-metal, halogen, lanthanoid, metalloid, noble-gas, other-non-metal, post-transition-metal, transition-metal, or unknown." 20 attr default -title "Default Value" -type atomelem -path default -only input -tooltip "Sets the value that this input has when the program first starts. This value is used by default unless the user explicitly changes it." 26 21 27 attr returnvalue -title "Return value" -type string -path default -only input -tooltip "Specifies the return value: name, symbol, number, or weight."22 attr returnvalue -title "Return value" -type atomprops -path returnvalue -only input -tooltip "Specifies how the selected element is reported to your program: name, symbol, number, or weight." 28 23 29 attr default -title "Default Value" -type string -path default -only input -tooltip "Sets the value that this input has when the program first starts. This value is used by default unless the user explicitly changes it." 24 attr active -title "Allowed Elements" \ 25 -type atomactive -path active -only input -tooltip "Specifies the set of elements that can be selected.\n\nCan allow or disallow one or more groups of elements on the periodic table: actinoid, alkali-metal, alkaline-earth-metal, halogen, lanthanoid, metalloid, noble-gas, other-non-metal, post-transition-metal, transition-metal, or unknown." 30 26 31 27 check default { 32 if {[llength $attr(options)] > 0} { 33 if {[string length [string trim $attr(default)]] == 0} { 34 return [list error "Must have a default value for this periodicelement."] 28 set defval [string trim $attr(default)] 29 if {[string length $defval] == 0} { 30 return [list error "Must have a default value for this periodicelement."] 31 } 32 33 # make sure that the given value is a valid element type 34 if {[Rappture::PeriodicTable::FindElement $defval] eq ""} { 35 return [list error "Bad value \"$defval\": must be a known element in the periodic table."] 36 } 37 38 # make sure that the given value isn't in conflict with allowed values 39 if {$attr(active) ne "" && [regexp {^(active|inactive): (.+)} $attr(active) match polarity vlist]} { 40 set found [eval Rappture::PeriodicTable::ElementIsType $attr(default) [split $vlist ,]] 41 if { (!$found && $polarity eq "active") 42 || ($found && $polarity eq "inactive") } { 43 return [list error "Default value \"$attr(default)\" is not one of the allowed values"] 35 44 } 45 } 46 } 36 47 37 # make sure that the default is really a choice 38 set defval [string trim $attr(default)] 39 set found 0 40 foreach rec $attr(options) { 41 set label [string trim [lindex $rec 0]] 42 set value [string trim [lindex $rec 1]] 43 if {$defval eq $label || $defval eq $value} { 44 set found 1 45 break 46 } 47 } 48 if {!$found} { 49 return [list error "Default value must be a label or value for one of the current periodicelements."] 50 } 48 check returnvalue { 49 if {[string length [string trim $attr(returnvalue)]] == 0} { 50 return [list error "Must choose at least one return value to report the selected element to your program."] 51 51 } 52 52 }
Note: See TracChangeset
for help on using the changeset viewer.