blob: eb8f6504646e79763b5a1ae6df713e82371d97e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package require Tclpd 0.2.3
package require TclpdLib 0.19
proc+ exists::constructor {self args} {
set @current_canvas [canvas_getcurrent]
# set to blank so the var always exists
set @filename {}
# add second inlet (first created by default)
pd::add_inlet $self list
# add outlet
pd::add_outlet $self list
}
proc+ exists::0_symbol {self args} {
# HOT inlet
set @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]
} else {
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} {
# COLD inlet
set @filename [pd::arg 0 symbol]
}
pd::class exists
|