aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-11-14 05:43:13 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-11-14 05:43:13 +0000
commit6d3a518ce3393a2c00b4795d13d7c420ce8b441d (patch)
treea7786721ba704a144f9f1cc30849977a10da0890
parent40359cc18bdb10a89c22f22bd51791f760e094d0 (diff)
move shared function to a Tcl package, now that tclpd supports a local package
svn path=/trunk/externals/tclfile/; revision=15742
-rw-r--r--delete-help.pd22
-rw-r--r--delete.tcl20
-rw-r--r--exists.tcl14
-rw-r--r--mkdir.tcl20
-rw-r--r--pkgIndex.tcl1
-rw-r--r--tclfile.tcl14
6 files changed, 59 insertions, 32 deletions
diff --git a/delete-help.pd b/delete-help.pd
index 667cfd5..5a25fb8 100644
--- a/delete-help.pd
+++ b/delete-help.pd
@@ -1,23 +1,23 @@
-#N canvas 186 203 501 349 10;
+#N canvas 657 79 501 349 10;
#X obj 297 261 mkdir;
-#X msg 298 232 symbol /tmp/blah;
#X obj 202 160 exists;
-#X msg 202 114 symbol /tmp/blah;
-#X obj 202 181 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
+#X obj 202 181 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;
#X obj 202 201 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X msg 209 133 symbol /tmp/created_after_bang;
#X text 28 294 this is a clone of this command:;
-#X msg 48 63 symbol /tmp/blah;
#X obj 48 115 delete;
#X text 25 20 delete a file or empty folder;
#X text 253 209 make a new one:;
#X obj 120 306 pddp/pddplink http://tcl.tk/man/tcl8.5/TclCmd/file.htm#M12
;
-#X connect 1 0 0 0;
-#X connect 2 0 4 0;
-#X connect 3 0 2 0;
-#X connect 4 0 5 0;
-#X connect 6 0 2 0;
-#X connect 8 0 9 0;
+#X msg 48 63 this is a test;
+#X msg 298 233 this is a test;
+#X msg 202 114 this is a test;
+#X connect 1 0 2 0;
+#X connect 2 0 3 0;
+#X connect 4 0 1 0;
+#X connect 10 0 6 0;
+#X connect 11 0 0 0;
+#X connect 12 0 1 0;
diff --git a/delete.tcl b/delete.tcl
index aeeaa25..5ab7289 100644
--- a/delete.tcl
+++ b/delete.tcl
@@ -1,24 +1,30 @@
package require Tclpd 0.3.0
package require TclpdLib 0.20
+package require tclfile
proc delete::constructor {self args} {
if {![namespace exists $self]} {
namespace eval $self {}
}
- # set to blank so the var always delete
- variable ${self}::filename {}
variable ${self}::current_canvas [canvas_getcurrent]
+ # set to blank so the var always exists
+ variable ${self}::filename {}
# add second inlet (first created by default)
pd::add_inlet $self list
}
+# HOT inlet --------------------------------------------------------------------
proc delete::0_symbol {self args} {
- # HOT inlet
variable ${self}::filename [pd::arg 0 symbol]
delete::0_bang $self
}
+proc delete::0_anything {self args} {
+ variable ${self}::filename [tclfile::make_symbol $args]
+ delete::0_bang $self
+}
+
proc delete::0_bang {self} {
variable ${self}::current_canvas
variable ${self}::filename
@@ -30,9 +36,13 @@ proc delete::0_bang {self} {
}
}
-proc+ delete::1_symbol {self args} {
- # COLD inlet
+# COLD inlet -------------------------------------------------------------------
+proc delete::1_symbol {self args} {
variable ${self}::filename [pd::arg 0 symbol]
}
+proc delete::1_anything {self args} {
+ variable ${self}::filename [tclfile::make_symbol $args]
+}
+
pd::class delete
diff --git a/exists.tcl b/exists.tcl
index 3e337c5..017da58 100644
--- a/exists.tcl
+++ b/exists.tcl
@@ -1,14 +1,6 @@
package require Tclpd 0.3.0
package require TclpdLib 0.20
-
-proc exists::make_symbol {argslist} {
- set output [pd::strip_selectors $argslist]
- set selector [lindex $output 0]
- if {$selector eq "list" || $selector eq "float"} {
- set output [lrange $output 1 end]
- }
- return $output
-}
+package require tclfile
proc exists::constructor {self args} {
if {![namespace exists $self]} {
@@ -32,7 +24,7 @@ proc exists::0_symbol {self args} {
}
proc exists::0_anything {self args} {
- variable ${self}::filename [make_symbol $args]
+ variable ${self}::filename [tclfile::make_symbol $args]
exists::0_bang $self
}
@@ -53,7 +45,7 @@ proc exists::1_symbol {self args} {
}
proc exists::1_anything {self args} {
- variable ${self}::filename [make_symbol $args]
+ variable ${self}::filename [tclfile::make_symbol $args]
}
pd::class exists
diff --git a/mkdir.tcl b/mkdir.tcl
index 9d2f7b7..2ff47eb 100644
--- a/mkdir.tcl
+++ b/mkdir.tcl
@@ -1,24 +1,30 @@
package require Tclpd 0.3.0
package require TclpdLib 0.20
+package require tclfile
proc mkdir::constructor {self args} {
if {![namespace exists $self]} {
namespace eval $self {}
}
- # set to blank so the var always mkdir
- variable ${self}::filename {}
variable ${self}::current_canvas [canvas_getcurrent]
+ # set to blank so the var always exists
+ variable ${self}::filename {}
# add second inlet (first created by default)
pd::add_inlet $self list
}
+# HOT inlet --------------------------------------------------------------------
proc mkdir::0_symbol {self args} {
- # HOT inlet
variable ${self}::filename [pd::arg 0 symbol]
mkdir::0_bang $self
}
+proc mkdir::0_anything {self args} {
+ variable ${self}::filename [tclfile::make_symbol $args]
+ mkdir::0_bang $self
+}
+
proc mkdir::0_bang {self} {
variable ${self}::current_canvas
variable ${self}::filename
@@ -30,9 +36,13 @@ proc mkdir::0_bang {self} {
}
}
-proc+ mkdir::1_symbol {self args} {
- # COLD inlet
+# COLD inlet -------------------------------------------------------------------
+proc mkdir::1_symbol {self args} {
variable ${self}::filename [pd::arg 0 symbol]
}
+proc mkdir::1_anything {self args} {
+ variable ${self}::filename [tclfile::make_symbol $args]
+}
+
pd::class mkdir
diff --git a/pkgIndex.tcl b/pkgIndex.tcl
new file mode 100644
index 0000000..7e72c03
--- /dev/null
+++ b/pkgIndex.tcl
@@ -0,0 +1 @@
+package ifneeded tclfile 0.1 [list source [file join $dir tclfile.tcl]]
diff --git a/tclfile.tcl b/tclfile.tcl
new file mode 100644
index 0000000..7700a5d
--- /dev/null
+++ b/tclfile.tcl
@@ -0,0 +1,14 @@
+package require Tclpd 0.2.3
+
+package provide tclfile 0.1
+namespace eval ::tclfile {
+}
+
+proc tclfile::make_symbol {argslist} {
+ set output [pd::strip_selectors $argslist]
+ set selector [lindex $output 0]
+ if {$selector eq "list" || $selector eq "float"} {
+ set output [lrange $output 1 end]
+ }
+ return $output
+}