Program HOURTAB; {HT20050102 minor modification 20061116} {$R+} uses CRT; type vector = array [1..64] of single; var b : byte; f, g : file of byte; i, n, y, hour, newhour : integer; v : vector; tab : array [1..7] of vector; s, dataname, resultname : string; prime : boolean; data, result : text; procedure processhour; var j, k : integer; x, sum, min, max : single; begin if n < 3 then exit; write (result, round (tab [1, 1]), #09, 100 * hour + 30); for k := 3 to 64 do begin sum := 0; min := 1e9; max := -min; for j := 1 to n do begin x := tab [j, k]; sum := sum + x; if x < min then min := x; if x > max then max := x; end; x := (sum - min - max) / (n - 2); if k = 3 then write (result, #09, x:5:3) else if k in [4, 5, 6, 60, 62] then write (result, #09, x:3:1) else write (result, #09, x:1:0); end; writeln (result); end; begin clrscr; if paramcount > 0 then begin {dragged filename} s := paramstr (1); y := length (s); i := y; repeat i := i - 1 until s [i] = '\'; chdir (copy (s, 1, i - 1)); dataname := copy (s, i + 1, y - i); end else begin {keyboard filename} writeln; writeln (' Normal way to run this program is to drag the icon of'); writeln (' a BSMA output file onto the icon of the program file'); writeln (' If you wish to use this method then exit now the program'); writeln (' pressing immediately ENTER instead of the filename.'); write (' Please press ENTER or write the name of the data file: '); readln (dataname); if dataname = '' then halt; end; resultname := dataname; resultname [2] := 'H'; assign (f, dataname); {$I-} reset (f); {$I+} if IOresult <> 0 then begin writeln (' Sorry, ', dataname, ' is not available.'); writeln (' Press ENTER for escape!'); readln; halt; end; {copy the table header} assign (g, resultname); rewrite (g); repeat read (f, b); write (g, b); until b = 10; close (g); close (f); {header is copied} assign (data, dataname); reset (data); readln (data, s); {skip header} assign (result, resultname); append (result); prime := true; n := 0; repeat for i := 1 to 64 do read (data, v [i]); n := n + 1; tab [n] := v; newhour := round (v [2]) div 100; if prime then hour := newhour; if eof (data) and (newhour = hour) then processhour else if newhour <> hour then begin n := n - 1; processhour; n := 0; tab [1] := v; hour := newhour; end; prime := false; until eof (data); close (result); close (data); writeln (' Done. Press ENTER for escape!'); readln; end.