aboutsummaryrefslogtreecommitdiff
path: root/externals/gridflow/bin/pd-tools.tcl
blob: 2951b260b0965c7b4572df0eebd932c916d64e8d (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
37
# (this proc is taken from desiredata)
# split at message boundaries.
# \n is wiped, then that character is reused temporarily to mean a quoted semicolon.
proc pd_mess_split {e} {
	set r {}
	regsub -all "\n" $e " " y
	regsub -all {\\;} $y "\n" z
	foreach mess [split $z ";"] {
		regsub -all "\n" $mess "\\;" mess
		set mess [string trimleft $mess]
		if {$mess != ""} {lappend r $mess}
	}
	return $r
}

proc pd_read_file {filename} {
  set f [open $filename]
  set r [pd_mess_split [read $f]]
  close $f
  return $r
}

proc pd_pickle {l} {
	set i 0
	set t ""
	set n [llength $l]
	foreach e $l {
		incr n -1
		#regsub -all "," $e "\\," e
		append t $e
		incr i [string length $e]
		if {$i>65} {set i 0; append t "\n"} elseif {$n>0} {incr i; append t " "}
	}
	append t ";"
	return $t
}