aboutsummaryrefslogtreecommitdiff
path: root/exists.tcl
blob: 3ae3c58b4b5ab97a6995e6e5533baa1a8a57405e (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
package require Tclpd 0.2.3
package require TclpdLib 0.19

proc+ exists::constructor {self args} {
    # 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 {![info exists @filename]} return
    pd::outlet $self 0 float [file exists $@filename]
}

proc+ exists::1_symbol {self args} {
    # COLD inlet
    set @filename [pd::arg 0 symbol]
}

pd::class exists