From b4791d3cd1cc6bfe759cef5635f54c38a3b58396 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 11 Nov 2011 23:33:31 +0000 Subject: ported to 'variable ' technique and use proc instead of proc+ svn path=/trunk/externals/tclfile/; revision=15726 --- exists.tcl | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'exists.tcl') diff --git a/exists.tcl b/exists.tcl index eb8f650..fed8da3 100644 --- a/exists.tcl +++ b/exists.tcl @@ -1,10 +1,13 @@ package require Tclpd 0.2.3 package require TclpdLib 0.19 -proc+ exists::constructor {self args} { - set @current_canvas [canvas_getcurrent] +proc exists::constructor {self args} { + if {![namespace exists $self]} { + namespace eval $self {} + } + variable ${self}::current_canvas [canvas_getcurrent] # set to blank so the var always exists - set @filename {} + variable ${self}::filename {} # add second inlet (first created by default) pd::add_inlet $self list @@ -13,24 +16,26 @@ proc+ exists::constructor {self args} { pd::add_outlet $self list } -proc+ exists::0_symbol {self args} { +proc exists::0_symbol {self args} { # HOT inlet - set @filename [pd::arg 0 symbol] + variable ${self}::filename [pd::arg 0 symbol] exists::0_bang $self } -proc+ exists::0_bang {self} { - if {[file pathtype $@filename] eq "absolute"} { - pd::outlet $self 0 float [file exists $@filename] +proc exists::0_bang {self} { + variable ${self}::current_canvas + variable ${self}::filename + if {[file pathtype $filename] eq "absolute"} { + pd::outlet $self 0 float [file exists $filename] } else { - set dir [[canvas_getdir $@current_canvas] cget -s_name] - pd::outlet $self 0 float [file exists [file join $dir $@filename]] + set dir [[canvas_getdir $current_canvas] cget -s_name] + pd::outlet $self 0 float [file exists [file join $dir $filename]] } } -proc+ exists::1_symbol {self args} { +proc exists::1_symbol {self args} { # COLD inlet - set @filename [pd::arg 0 symbol] + variable ${self}::filename [pd::arg 0 symbol] } pd::class exists -- cgit v1.2.1