File: cycle.tcl

package info (click to toggle)
openmsx 0.5.1-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,976 kB
  • ctags: 10,295
  • sloc: cpp: 63,525; xml: 37,105; sh: 1,403; python: 681; tcl: 207; makefile: 64
file content (18 lines) | stat: -rw-r--r-- 405 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Cycle through the possible values of an enumsettings
#
# Usage:
#   cycle <enumsetting> [<step>]
#
# Example:
#   cycle scaler

proc cycle {setting {step 1}} {
	if [catch {
		set values [openmsx_info $setting]
		set cur [lsearch -exact $values [set ::$setting]]
	} ] {
		error "Not an enum setting: $setting"
	}
	set new [expr ($cur + $step) % [llength $values]]
	set ::$setting [lindex $values $new]
}