File: autoop

package info (click to toggle)
epic4-script-light 1%3A2.8.0-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 764 kB
  • ctags: 1
  • sloc: makefile: 35; sh: 7
file content (76 lines) | stat: -rw-r--r-- 1,819 bytes parent folder | download | duplicates (2)
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
alias Light.isAutoOp (match, channel) {
	if (0 == match) return 0
	@function_return = (-1 != findw($channel $LIGHT.AutoOp.opList[$match]))
}

alias Light.isAutoVoice (match, channel) {
	if (0 == match) return 0
	@function_return = (-1 != findw($channel $LIGHT.AutoOp.voiceList[$match]))
}

alias Light.addAutoOp (match, channel) {
	if (0 == match) return
	@LIGHT.AutoOp.opList[$match] = uniq($LIGHT.AutoOp.opList[$match] $channel)
}

alias Light.addAutoVoice (match, channel) {
	if (0 == match) return
	@LIGHT.AutoOp.voiceList[$match] = uniq($LIGHT.AutoOp.voiceList[$match] $channel)
}

alias Light.removeAutoOp (mask, channels) {
	if ([] == channels) {
		return 0
	}
	@:match = Light.findAutoPattern($mask)
	unless (match) {
		return 0
	}
	if ([*] == channels) {
		^assign -LIGHT.AutoOp.opList.$match
	} {
		@LIGHT.AutoOp.opList[$match] = remws($channels / $LIGHT.AutoOp.opList[$match])
	}
	return 1
}

alias Light.removeAutoVoice (mask, channels) {
	if ([] == channels) {
		return 0
	}
	@:match = Light.findAutoPattern($mask)
	unless (match) {
		return 0
	}
	if ([*] == channels) {
		^assign -LIGHT.AutoOp.voiceList.$match
	} {
		@LIGHT.AutoOp.voiceList[$match] = remws($channels / $LIGHT.AutoOp.voiceList[$match])
	}
	return 1
}

alias Light.findAutoPattern (mask) {
	if (!match(*@* $mask)) {
		return 0
	}
	@function_return = findw($mask $LIGHT.AutoOp.patternList) + 1
}

alias Light.removeAutoPattern (match) {
	if (0 == match) return
	@:lim = numwords($LIGHT.AutoOp.patternList)
	for ii from $match to $lim {
		@LIGHT.AutoOp.opList[$ii] = LIGHT.AutoOp.opList[${ii+1}]
		@LIGHT.AutoOp.voiceList[$ii] = LIGHT.AutoOp.voiceList[${ii+1}]
	}
	@:match--
	@splice(LIGHT.AutoOp.patternList $match 1)
}

alias Light.addAutoPattern (mask) {
	if (!match(*@* $mask)) return 0
	push LIGHT.AutoOp.patternList $mask
	return 1
}