// MeterList -- prints out listing of Spruce activities:

get "Spruce.d" 
get "SpruceFiles.d"

external [
	OpenFile
	Closes
	Wss
	Wns
	Puts
	ReadBlock
	Gets
	CallSwat
	]

static [
	so
	time
	reftime
	]

let doit() be
[
	let si=OpenFile("Spruce.Meter")
	so=OpenFile("Spruce.MeterList", 0, 1)

[
	let v=vec 200
	ReadBlock(si, v, size M/16)
	let t=v>>M.type
	time=v>>M.time
	if reftime eq 0 then reftime=time
	if v>>M.length then ReadBlock(si, v, v>>M.length)

switchon t into [

case METERRead: case METERWrite:
	[
	Title((t eq METERRead? "File read","File write"))
	let f=v>>FLStat.File
	let n=selecton f into [
		case FILEBands: "Bands"
		case FILEMeter: "Meter"
		case FILEFontDictionary: "Font"
		case FILESpruceProgram: "Spruce"
		case FILEPress rem 256: "Press file"
		default: "??"
		]
	P(n)
	P(": page="); Pn(v>>FLStat.Page)
	P(", count="); Pn(v>>FLStat.Cnt)
	]
	endcase

case METEREnd: break

default: CallSwat("Illegal entry")
]

	P("*n")
] repeat

	Closes(so)
]

and Title(s) be
[
	P(s)
	P("  [time=")
	Pn(time-reftime)
	P("]  ")
]

and P(s) be Wss(so, s)

and Pn(s) be Wns(so, s)