From 79ad58a64786e88e51edf300b881e41d61bf4595 Mon Sep 17 00:00:00 2001 From: mescalinum Date: Mon, 14 Nov 2011 16:19:57 +0000 Subject: use eq/ne in place of ==/!= for string (in)equelity checks svn path=/trunk/externals/loaders/tclpd/; revision=15745 --- examples/bitmap.tcl | 42 +++++++++++++++++++++--------------------- examples/colorpicker.tcl | 20 ++++++++++---------- examples/dynreceive.tcl | 6 +++--- examples/list_change.tcl | 4 ++-- examples/properties.tcl | 14 +++++++------- examples/slider2.tcl | 26 +++++++++++++------------- 6 files changed, 56 insertions(+), 56 deletions(-) diff --git a/examples/bitmap.tcl b/examples/bitmap.tcl index 64d2b92..e1d0495 100644 --- a/examples/bitmap.tcl +++ b/examples/bitmap.tcl @@ -40,13 +40,13 @@ proc+ bitmap::constructor {self args} { lappend @config -uwidth 8 lappend @config -uheight 8 lappend @config -cellsize 16 - lappend @config -label "" - lappend @config -labelpos "top" - lappend @config -sendsymbol "" - lappend @config -receivesymbol "" - lappend @config -fgcolor "#000000" - lappend @config -bgcolor "#ffffff" - lappend @config -lblcolor "#000000" + lappend @config -label {} + lappend @config -labelpos {top} + lappend @config -sendsymbol {} + lappend @config -receivesymbol {} + lappend @config -fgcolor {#000000} + lappend @config -bgcolor {#ffffff} + lappend @config -lblcolor {#000000} set @data { 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 @@ -64,17 +64,17 @@ proc+ bitmap::constructor {self args} { } proc+ bitmap::destructor {self} { - if {$@rcvLoadData != {}} { + if {$@rcvLoadData ne {}} { #should not happen! pd_unbind $self $@rcvLoadData } - if {[dict get $@config -receivesymbol] != {}} { + if {[dict get $@config -receivesymbol] ne {}} { pd_unbind $self $@recv } } proc+ bitmap::0_config {self args} { - if {$args == {}} { + if {$args eq {}} { return $@config } else { set newconf [list] @@ -105,7 +105,7 @@ proc+ bitmap::0_config {self args} { set old [dict get $@config -$opt] if {[dict exists $newconf -$opt]} { set new [dict get $newconf -$opt] - if {$old != $new} { + if {$old ne $new} { dict set @config -$opt $new set ui 1 } @@ -115,12 +115,12 @@ proc+ bitmap::0_config {self args} { set old [dict get $@config -$opt] if {[dict exists $newconf -$opt]} { set new [dict get $newconf -$opt] - if {$old != $new} { - if {$opt == "receivesymbol"} { - if {$old != {}} { + if {$old ne $new} { + if {$opt eq {receivesymbol}} { + if {$old ne {}} { pd_unbind $self $@recv } - if {$new != {}} { + if {$new ne {}} { set @recv [canvas_realizedollar $@canvas $new] pd_bind $self $@recv } else { @@ -196,7 +196,7 @@ proc+ bitmap::0_setrow {self args} { set bgcolor [dict get $@config -bgcolor] set colors [list $bgcolor $fgcolor] for {set idx [expr {$row*$w}]} {$idx < [expr {($row+1)*$w}]} {incr idx} { - set d [expr {0!=[pd::arg $z int]}] + set d [expr {0 != [pd::arg $z int]}] lset @data $idx $d sys_gui [list $@c itemconfigure cell_${col}_${row}_$self \ -fill [lindex $colors $d]]\n @@ -215,7 +215,7 @@ proc+ bitmap::0_setcol {self args} { set bgcolor [dict get $@config -bgcolor] set colors [list $bgcolor $fgcolor] for {set idx [expr {$col}]} {$idx < [expr {$w*$h}]} {incr idx $w} { - set d [expr {0!=[pd::arg $z int]}] + set d [expr {0 != [pd::arg $z int]}] lset @data $idx $d sys_gui [list $@c itemconfigure cell_${col}_${row}_$self \ -fill [lindex $colors $d]]\n @@ -227,7 +227,7 @@ proc+ bitmap::0_setcol {self args} { proc+ bitmap::0_setcell {self args} { set r [pd::arg 0 int] set c [pd::arg 1 int] - set d [expr {0!=[pd::arg 2 int]}] + set d [expr {0 != [pd::arg 2 int]}] set w [dict get $@config -uwidth] set fgcolor [dict get $@config -fgcolor] set bgcolor [dict get $@config -bgcolor] @@ -248,7 +248,7 @@ proc+ bitmap::0_setdata {self args} { } set @data [list] foreach i $d {lappend @data [expr {int($i)}]} - if {$@rcvLoadData != {}} { + if {$@rcvLoadData ne {}} { pd_unbind $self $@rcvLoadData set @rcvLoadData {} } @@ -290,7 +290,7 @@ proc+ bitmap::widgetbehavior_select {self args} { set sel [lindex $args 0] set fgcolor [dict get $@config -fgcolor] set bgcolor [dict get $@config -bgcolor] - set selcolor "blue" + set selcolor {blue} set colors [list $selcolor $fgcolor] sys_gui [list $@c itemconfigure $self \ -outline [lindex $colors $sel]]\n @@ -333,7 +333,7 @@ proc+ bitmap::widgetbehavior_click {self args} { set j [expr {$xpix/$sz}] set i [expr {$ypix/$sz}] set idx [expr {$w*${i}+${j}}] - set d [expr {[lindex $@data $idx]==0}] + set d [expr {[lindex $@data $idx] == 0}] lset @data $idx $d sys_gui [list $@c itemconfigure cell_${j}_${i}_$self \ -fill [lindex $colors $d]]\n diff --git a/examples/colorpicker.tcl b/examples/colorpicker.tcl index 0c433cb..5ee60e7 100644 --- a/examples/colorpicker.tcl +++ b/examples/colorpicker.tcl @@ -28,14 +28,14 @@ namespace eval ::colorpicker { error "bad mode: $mode. must be one of: $modes." } set ($w:mode) $mode - set ($w:color) "#000000" + set ($w:color) {#000000} set ($w:command) {} set ($w:textvar) {} frame $w init_$mode $w rename $w ::colorpicker::_$w interp alias {} $w {} ::colorpicker::dispatch $w - if {$args != {}} {uplevel 1 ::colorpicker::config $w $args} + if {$args ne {}} {uplevel 1 ::colorpicker::config $w $args} return $w } @@ -66,7 +66,7 @@ namespace eval ::colorpicker { default { lappend options $key $value } } } - if {!$flag || $options != ""} { + if {!$flag || $options ne {}} { uplevel 1 [linsert $options 0 ::scrolledframe::_$w config] } } @@ -100,12 +100,12 @@ namespace eval ::colorpicker { variable {} set c [string tolower $c] set ($w:color) $c - if {$($w:command) != {}} { + if {$($w:command) ne {}} { set cmd $($w:command) lappend cmd $c uplevel #0 $cmd } - if {$($w:textvar) != {}} { + if {$($w:textvar) ne {}} { uplevel #0 [list set $($w:textvar) $c] } switch -exact -- $($w:mode) { @@ -114,7 +114,7 @@ namespace eval ::colorpicker { set q 0 for {set row 0} {$row < 3} {incr row} { for {set col 0} {$col < 10} {incr col} { - set b [expr {$c == "#[lindex $presets $q]"}] + set b [expr {$c eq "#[lindex $presets $q]"}] ${w}.r${row}c${col} configure \ -relief [lindex {raised sunken} $b] incr q @@ -131,7 +131,7 @@ namespace eval ::colorpicker { if {$r < 0} {set r 0} elseif {$r > 255} {set r 255} if {$g < 0} {set g 0} elseif {$g > 255} {set g 255} if {$b < 0} {set b 0} elseif {$b > 255} {set b 255} - return #[format "%2.2x%2.2x%2.2x" $r $g $b] + return #[format {%2.2x%2.2x%2.2x} $r $g $b] } proc rgbToHsv {r g b} { @@ -199,7 +199,7 @@ namespace eval ::colorpicker { for {set row 0} {$row < 3} {incr row} { for {set col 0} {$col < 10} {incr col} { set c "#[lindex $presets $q]" - set b [expr {$($w:color) == $c}] + set b [expr {$($w:color) eq $c}] grid [frame ${w}.r${row}c${col} -width 18 -height 16 \ -borderwidth 1 -relief [lindex {raised sunken} $b] \ -background $c -highlightthickness 0] \ @@ -264,10 +264,10 @@ namespace eval ::colorpicker { proc hsv_set {w what val} { variable colorhsv - if {$what != {h} && $what != {s} && $what != {v}} {return} + if {$what ne {h} && $what ne {s} && $what ne {v}} {return} set colorhsv($w:$what) $val if {$colorhsv($w:$what) < 0.0} {set colorhsv($w:$what) 0} - if {$what == {h}} { + if {$what eq {h}} { if {$colorhsv($w:$what) >= 360.0} {set colorhsv($w:$what) 0} hsv_regen $w $colorhsv($w:$what) } else { diff --git a/examples/dynreceive.tcl b/examples/dynreceive.tcl index ceef7a8..f065e77 100644 --- a/examples/dynreceive.tcl +++ b/examples/dynreceive.tcl @@ -13,7 +13,7 @@ proc+ dynreceive::constructor {self args} { proc+ dynreceive::destructor {self} { # don't forget to call pd_unbind, or sending things to a symbol # bound to dead object will crash pd! - if {$@sym != {}} { + if {$@sym ne {}} { pd_unbind $self $@sym } } @@ -21,10 +21,10 @@ proc+ dynreceive::destructor {self} { proc+ dynreceive::0_set {self args} { # send [set empty( to clear the receive symbol set s [pd::arg 0 symbol] - if {$@sym != {}} { + if {$@sym eq {}} { pd_unbind $self $@sym } - if {$s == {empty}} { + if {$s eq {empty}} { set @sym {} } else { set @sym $s diff --git a/examples/list_change.tcl b/examples/list_change.tcl index 82c751d..307e629 100644 --- a/examples/list_change.tcl +++ b/examples/list_change.tcl @@ -13,14 +13,14 @@ proc+ list_change::constructor {self args} { proc+ list_change::0_list {self args} { # HOT inlet - if {$args != $@curlist} { + if {$args ne $@curlist} { set @curlist $args pd::outlet $self 0 list $@curlist } } proc+ list_change::0_bang {self} { - if {$@curlist == {}} return + if {$@curlist eq {}} return pd::outlet $self 0 list $@curlist } diff --git a/examples/properties.tcl b/examples/properties.tcl index cdbfc1d..2769799 100644 --- a/examples/properties.tcl +++ b/examples/properties.tcl @@ -10,7 +10,7 @@ proc propertieswindow {gfxstub_id {options {}} {title {}}} { set ::optkeys($win.p) [list] set options [string map {@ $} $options] foreach {k v} $options { - if {$v eq "empty"} {set v {}} + if {$v eq {empty}} {set v {}} #set v [string map {\\$ $} $v] set ::config($win.p:$k) $v lappend ::optkeys($win.p) $k @@ -33,7 +33,7 @@ proc propertiespanel {w} { set subpanels {dimensions output behavior connective label colors} foreach subpanel $subpanels { set x [propertiespanel_$subpanel $w] - if {$x != {}} {grid $x -sticky ew -in $w} + if {$x ne {}} {grid $x -sticky ew -in $w} } set x [propertiespanel_buttons $w] grid $x -in $w @@ -351,7 +351,7 @@ proc propertiespanel_colors_set_wrap {w x wp optkey config_ idx op} { } proc propertiespanel_colors_switchpicker {w x row cpt idx op} { - raise ${x}.cp[expr {1+($::cpt($w) == {hsv})}] + raise ${x}.cp[expr {1+($::cpt($w) eq {hsv})}] } proc propertiespanel_colors_pick {w x colors wb wp wt} { @@ -359,7 +359,7 @@ proc propertiespanel_colors_pick {w x colors wb wp wt} { ${x}.b$color configure -relief raised -state normal } set r [$wb cget -relief] - if {$r == {sunken}} { + if {$r eq {sunken}} { $wb configure -relief raised ${x}.cp1 configure -command {} ${x}.cp2 configure -command {} @@ -373,9 +373,9 @@ proc propertiespanel_colors_pick {w x colors wb wp wt} { } proc propertiespanel_colors_set {w x wp wt from color} { - if {$wt != {}} {$wt delete 0 end ; $wt insert 0 $color} + if {$wt ne {}} {$wt delete 0 end ; $wt insert 0 $color} $wp configure -background $color - if {$::cpt($w) == {switches} && $from == 1} { + if {$::cpt($w) eq {switches} && $from == 1} { ${x}.cp2 set $color } } @@ -414,7 +414,7 @@ proc propertiespanel_apply {w} { set newconf [list] foreach key $::optkeys($w) { set v $::config($w:$key) - if {$v == ""} {set v "empty"} + if {$v eq {}} {set v {empty}} lappend newconf $key $v } #set newconf [string map {$ \\$} $newconf] diff --git a/examples/slider2.tcl b/examples/slider2.tcl index 1cf1335..acda5a4 100644 --- a/examples/slider2.tcl +++ b/examples/slider2.tcl @@ -29,7 +29,7 @@ pd::guiproc slider2_update {self c x y config state} { if {$realvalue < 0.0} {set realvalue 0} if {$realvalue > 1.0} {set realvalue 1} if {$rev} {set realvalue [expr {1.0-$realvalue}]} - if {$orient == "vertical"} {set realvalue [expr {1.0-$realvalue}]} + if {$orient eq {vertical}} {set realvalue [expr {1.0-$realvalue}]} switch $orient { horizontal { set hr [expr {$width-$headsz}] @@ -43,7 +43,7 @@ pd::guiproc slider2_update {self c x y config state} { } } $c delete label$self - if {$label != {}} { + if {$label ne {}} { switch $labelpos { top {set lx [expr {$x+$width/2}]; set ly [expr {$y}]; set a "s"} @@ -66,9 +66,9 @@ proc+ slider2::constructor {self args} { # set defaults: set @config { -width 15 -height 130 -headsz 3 -rangebottom 0 -rangetop 127 - -init 0 -initvalue 0 -jumponclick 0 -label "" -labelpos "top" - -orient "vertical" -sendsymbol "" -receivesymbol "" - -fgcolor "#000000" -bgcolor "#ffffff" -lblcolor "#000000" + -init 0 -initvalue 0 -jumponclick 0 -label {} -labelpos {top} + -orient {vertical} -sendsymbol {} -receivesymbol {} + -fgcolor {#000000} -bgcolor {#ffffff} -lblcolor {#000000} } set @state {_min 0 _max 127 _rev 0} # expanded ($n) send/recv symbols: @@ -78,7 +78,7 @@ proc+ slider2::constructor {self args} { } proc+ slider2::destructor {self} { - if {[dict get $@config -receivesymbol] != {}} { + if {[dict get $@config -receivesymbol] ne {}} { pd_unbind $self $@recv } } @@ -114,9 +114,9 @@ proc+ slider2::0_config {self args} { if {![dict exists $@config $k]} { return -code error "unknown option '$k'" } - if {[dict get $@config $k] == $v} {continue} + if {[dict get $@config $k] eq $v} {continue} if {[lsearch -exact $int_opts $k] != -1} {set v [expr {int($v)}]} - if {[lsearch -exact $bool_opts $k] != -1} {set v [expr {int($v)!=0}]} + if {[lsearch -exact $bool_opts $k] != -1} {set v [expr {int($v) != 0}]} if {[lsearch -exact $ui_opts $k] != -1} {set ui 1} if {[lsearch -exact $upd_opts $k] != -1} {set upd 1} dict set newconf $k $v @@ -124,17 +124,17 @@ proc+ slider2::0_config {self args} { # process -{send,receive}symbol if {[dict exists $newconf -receivesymbol]} { set new_recv [dict get $newconf -receivesymbol] - if {[dict get $@config -receivesymbol] != {}} { + if {[dict get $@config -receivesymbol] ne {}} { pd_unbind $self $@recv } - if {$new_recv != {}} { + if {$new_recv ne {}} { set @recv [canvas_realizedollar $@canvas $new_recv] pd_bind $self $@recv } else {set @recv {}} } if {[dict exists $newconf -sendsymbol]} { set new_send [dict get $newconf -sendsymbol] - if {$new_send != {}} { + if {$new_send ne {}} { set @send [canvas_realizedollar $@canvas $new_send] } else {set @send {}} } @@ -189,9 +189,9 @@ proc+ slider2::0_set {self args} { proc+ slider2::0_bang {self} { foreach v {initvalue} {set $v [dict get $@config -$v]} pd::outlet $self 0 float $initvalue - if {$@send != {}} { + if {$@send ne {}} { set s_thing [$@send cget -s_thing] - if {$s_thing != {NULL}} {pd_float $s_thing $initvalue} + if {$s_thing ne {NULL}} {pd_float $s_thing $initvalue} } } -- cgit v1.2.1