-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyrinx.tcl
143 lines (110 loc) · 3.56 KB
/
syrinx.tcl
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#! /usr/bin/env tclsh
# syrinx.tcl
# remedial guardian sniffs for named capsules
apply {{files} {
set perch grackle.tcl
if {[file exists $perch]} {
source $perch
Grackle::guardian $files
} else {
puts stderr "$perch not found"
exit 1
}
unset perch
return
}} {estrilda.tcl ploceus.tcl sturnus.tcl}
namespace eval ::Syrinx {
namespace export atrium
# tail name of current qualified namespace
proc surname {} {
set curtail [namespace tail [namespace current]]
return $curtail
}
# iso-8601 timestamp
proc dateline {} {
set meantime [clock format [clock seconds] \
-timezone UTC -format "%Y-%m-%dT%TZ"]
return $meantime
}
# display matrices of chosen tuning and keys,
# secondary process which takes two arguments,
# the 1st being the selected instrument tuning,
# and the 2nd is a list containing key signs
proc compendia {{harp ""} {kids {}}} {
if [llength $kids] then {
puts ""
foreach sign $kids {
::Ploceus::fingerboard $harp $sign
puts ""
}
unset sign
}
unset harp kids
return
}
# main entry point for application,
# taking a list argument of which the 1st
# item is the selected instrument tuning
# and the remaining items are key signs
proc atrium {{argots {}}} {
set amount [llength $argots]
# vessel to hold key signature names
set clefs [lsort -ascii [array names ::Estrilda::oscines]]
# maximum amount of input arguments
set climax [expr {[llength $clefs] + 1}]
if {$amount && ($amount <= $climax)} then {
# maximum number of input characters
set spandex 15
# limit quantity of characters for each argument
lset argots [::Sturnus::sentinel $argots $spandex]
# establish instrument tuning
set tuned [lindex $::Ploceus::machines [
lsearch -exact $::Ploceus::machines [lindex $argots 0]]]
# numerically search through keys
if {($amount eq 1) && [string match {*[0-9]*} [lindex $argots 0]]} {
set kinda [lindex $argots 0]
::Estrilda::research $clefs $kinda
unset kinda
} elseif {($amount eq 1) &&
[string match {*[A-z]*} [lindex $argots 0]] &&
![string length [
lsearch -exact -inline $::Ploceus::machines [lindex $argots 0]]] &&
![string equal help [lindex $argots 0]]
} then {
# alphabetic search through values
::Estrilda::correlate [lindex $argots 0] $::Ploceus::metallic
} elseif {($amount eq 1) || ![llength $tuned]} {
# display help message with examples
::Sturnus::examples $::Ploceus::machines
} elseif {($amount > 1) && [llength $tuned]} {
# correct tuning chosen so parse variant arguments
set harp [lindex $argots 0]
set kids [lrange $argots 1 end]
if {[string length [lsearch -exact -inline $kids "flock"]]} {
# display all matrices formatted in chosen tuning
if {[array size ::Estrilda::oscines]} {
compendia $harp $clefs
} else {
puts stderr "::Estrilda::oscines is empty"
exit 1
}
unset argots amount clefs climax
unset harp kids spandex tuned
exit 0
} else {
# display matrices of chosen tuning and keys
compendia $harp $kids
unset harp kids
}
}
unset amount argots spandex tuned
} else {
# display menu of signatures
::Estrilda::signboard
}
unset clefs climax
return
} ;# atrium
# entryway
atrium $argv
} ;# close Syrinx