DECLARE FUNCTION round20! (x!, y!) DECLARE FUNCTION j2$ (n!) DECLARE FUNCTION pdata$ (tm!, ps!, pt!) DECLARE FUNCTION j$ (j!) DECLARE FUNCTION ptime$ (tm!) DECLARE SUB sorttemp () DEFsng a-z REM Rules:next hcap=ave(last hcap+this hcap) no run means no change in hcap SHARED temp(), timedata() winpoints = 50 wide = 6: REM printout this many last races ff$ = CHR$(12) DIM races$(16), cnt(16) RESTORE racedata noofraces = 0 DO UNTIL nname$ = "end" noofraces = noofraces + 1 READ nname$ races$(noofraces) = nname$ LOOP noofraces = noofraces - 1 OPEN "Hcap99.txt" FOR OUTPUT AS #1 OPEN "HCapStrt.txt" FOR OUTPUT AS #2: REM for handicap this will be the next months starting order RESTORE runnerdata REM check data count = 0: nname$ = "" DO UNTIL nname$ = "end" READ nname$, div IF nname$ <> "end" THEN count = count + 1 FOR r = 1 TO noofraces READ tm, ps IF tm <> 0 OR ps <> 0 THEN cnt(r) = cnt(r) + 1 NEXT READ test$ IF test$ <> "end" THEN PRINT "Error in runner data": error 99 END IF LOOP DIM runners$(count), divs(count), hctime(noofraces, count) DIM timedata(noofraces, count), posdata(noofraces, count) DIM ppoints(noofraces, count), tname$(count) DIM temp(2, count) RESTORE runnerdata FOR runner = 1 TO count READ runners$(runner), divs(runner) FOR race = 1 TO noofraces READ timedata(race, runner), posdata(race, runner) NEXT READ dummy$: IF dummy$ <> "end" THEN error 99 NEXT READ a$, b IF a$ <> "end" OR b <> 0 THEN error 99 FOR r = 1 TO count timedata(0, r) = timedata(1, r): REM make zeroth race time = to 1st race so average works for 1st race.. NEXT FOR race = 1 TO noofraces REM sort on pos FOR r = 1 TO count temp(1, r) = r IF posdata(race, r) = 0 THEN temp(2, r) = 999999 ELSE temp(2, r) = posdata(race, r) NEXT sorttemp REM fill in missing times with fastest time consistent with position FOR r = 1 TO count IF timedata(race, temp(1, r)) = 0 AND posdata(race, temp(1, r)) <> 0 THEN x = timedata(race, temp(1, r - 1)) y = round(timedata(race - 1, temp(1, r - 1)), timedata(race - 2, temp(1, r - 1))) z = round(timedata(race - 1, temp(1, r)), timedata(race - 2, temp(1, r))) REM convert to secs xsecs = 60 * (x \ 100) + (x MOD 100) ysecs = 60 * (y \ 100) + (y MOD 100) zsecs = 60 * (z \ 100) + (z MOD 100) a = xsecs - ysecs + zsecs REM convert back to mins/secs timedata(race, temp(1, r)) = (100 * (a \ 60)) + (a MOD 60) IF timedata(race, temp(1, r)) > 3000 THEN error 99 END IF NEXT FOR r = 1 TO count IF temp(2, r) = 999999 THEN p = 0 ELSE n = 0: first = 0 FOR x = 1 TO count IF temp(2, x) = temp(2, r) THEN n = n + 1: IF first = 0 THEN first = x NEXT p = winpoints - first + 1 - .5 * (n - 1) END IF ppoints(race, temp(1, r)) = p IF p > 0 THEN posdata(race, temp(1, r)) = r NEXT NEXT REM add up best 4 points to get total FOR r = 1 TO count s1 = 0: s2 = 0: s3 = 0: s4 = 0 FOR t = 1 TO noofraces s = ppoints(t, r) SELECT CASE s CASE > s4 s1 = s2: s2 = s3: s3 = s4: s4 = s CASE > s3 s1 = s2: s2 = s3: s3 = s CASE > s2 s1 = s2: s2 = s CASE > s1 s1 = s END SELECT NEXT ppoints(0, r) = s1 + s2 + s3 + s4 NEXT FOR r = 1 TO count temp(1, r) = r: temp(2, r) = ppoints(0, r) NEXT sorttemp REM find last few races only FOR r = noofraces TO 1 STEP -1 IF cnt(r) > 0 THEN lastrace = r: EXIT FOR NEXT IF lastrace < wide THEN lastrace = wide CLS PRINT #1, TAB(10 * wide); "Sunderland Strollers Winter Handicap 1999/2000" PRINT #1, PRINT #1, "Pos Team Name Tot."; SPC(16 - LEN(races$(lastrace - wide + 1)) / 2); FOR t = lastrace - wide + 1 TO lastrace PRINT #1, races$(t); SPC(20 + LEN(races$(t)) / 2 - LEN(races$(t)) - LEN(races$(t + 1)) / 2); NEXT PRINT #1, TAB(39); "time pos pts "; FOR r = 1 TO wide - 1 PRINT #1, "time pos pts "; NEXT PRINT #1, FOR r = count TO 1 STEP -1 p = temp(1, r) REM suppress o/p for non-runners so it doesn't fill sheet with unused names IF ppoints(0, p) =0 THEN EXIT FOR PRINT #1, j$(count - r + 1); " "; j$(divs(p)); " "; runners$(p); TAB(27); j2$(ppoints(0, p)); SPC(3); FOR t = lastrace - wide + 1 TO lastrace IF posdata(t, p) = 0 AND timedata(t, p) = 0 THEN PRINT #1, SPC(20); ELSE PRINT #1, SPC(2); pdata$(timedata(t, p), posdata(t, p), ppoints(t, p)); END IF NEXT PRINT #1, IF (count - r + 1) MOD 5 = 0 THEN PRINT #1, STRING$(33, "."); FOR t = lastrace - wide + 1 TO lastrace PRINT #1, STRING$(20, "."); NEXT PRINT #1, END IF NEXT PRINT #1, : PRINT #1, "Points Team and members" RESTORE teamdata teams = 0 DO READ teamno, teamname$ IF teamno = 0 THEN EXIT DO teams = teams + 1 tname$(teams) = teamname$ IF teamno <> teams THEN error 99: REM team data error LOOP REM get team points FOR r = 1 TO count temp(1, r) = r: temp(2, r) = 0 NEXT FOR r = 1 TO count FOR race = 2 TO noofraces temp(2, divs(r)) = temp(2, divs(r)) + ppoints(race, r) NEXT NEXT sorttemp FOR r% = count TO count - teams + 1 STEP -1 REM suppress o/p of teams with no points IF temp(2,r%)=0 then EXIT FOR PRINT #1, RIGHT$(" " + STR$(temp(2, r%)), 5); PRINT #1, RIGHT$(" " + STR$(temp(1, r%)), 5); ") "; tname$(temp(1, r%)); PRINT #1, TAB(58); FOR t% = 1 TO count IF divs(t%) = temp(1, r%) THEN PRINT #1, runners$(t%); " "; NEXT PRINT #1, : PRINT #1, NEXT 'PRINT #1, 'PRINT #1, "If any of the above information is incorrect or missing, inform Bob and/or Dicka as soon as possible." 'PRINT #1, "Remember it is YOUR responsibility to get results/times in within 3 hours of the race." 'PRINT #1, 'PRINT #1, "Points are awarded as follows.." 'PRINT #1, "50 points to first finished, 49 to 2nd, 48 to 3rd etc. No points for a non-runner." 'REM PRINT #1, 'PRINT #1, "Races will be held on the 2nd Wednesday of the month from October until March." 'PRINT #1, "Only 5 of these races will be run to allow for one to be cancelled due to bad weather." 'PRINT #1, "Individual scores will be the best 4 scores from the 5 races." 'PRINT #1, "Team scores will be totals of all team members over all 5 races." 'PRINT #1, "Teams shall have 3 runners." REM print next months start times and delays FOR r = 1 TO count cnt% = lastrace: first% = 0 DO IF timedata(cnt%, r) <> 0 THEN first% = timedata(cnt%, r) cnt% = cnt% - 1 LOOP UNTIL first% <> 0 second% = 0 DO IF timedata(cnt%, r) <> 0 THEN second% = timedata(cnt%, r) cnt% = cnt% - 1 LOOP UNTIL (second% <> 0) OR (cnt% < 0) temp(1, r) = r: temp(2, r) = round20((first%), (second%)) NEXT r sorttemp REM find slowest mmax = 0 FOR r = 1 TO count IF mmax < temp(2, r) THEN mmax = temp(2, r) NEXT PRINT #2, "Name Handicap time Start delay Finish time Finish position" FOR r = count TO 1 STEP -1 PRINT #2, runners$(temp(1, r)); TAB(18); MID$(STR$(10000 + temp(2, r)), 3, 2); ":"; RIGHT$(STR$(10000 + temp(2, r)), 2); TAB(27); xx = ((mmax \ 100) * 60 + mmax MOD 100) - ((temp(2, r) \ 100) * 60 + temp(2, r) MOD 100) xx$ = " " + STR$(xx \ 60) + ":" + RIGHT$(STR$((xx MOD 60) + 100), 2) PRINT #2, xx$ IF temp(2, r) <> temp(2, r - 1) THEN PRINT #2, STRING$(74, "_"): PRINT #2, NEXT CLOSE INPUT "The results are stored in text file 'HCAP99.txt'. Print it now?", a$ IF LEFT$(a$, 1) = "Y" OR LEFT$(a$, 1) = "y" THEN rem SHELL "type champ99.txt >lpt1:" width LPRINT 255 open "hcap99.txt" for input as #1 do line input#1,a$ lprint a$ loop until eof(1) LPRINT ff$: REM printer form feed END IF END racedata: REM race data DATA "Initial","October","November","December","January","February" DATA "March",end runnerdata: REM Runner data in order Name,Start Handicap time, race1 time, race1 pos, race2 time,race2 pos.. REM times in form HHMMSS with no separator 'DATA Ian Archibold,0, 1600,, ,, ,, ,, ,, ,, ,,end DATA Eddie Airson,8, 2300,, 2453,24, 2429,12, 2425,3, 2320,2, 2236,2, ,,end DATA Shiela Alcock,4, 2300,, 2422,20, 2540,28, ,, ,, ,, ,,end DATA Robert Allington,0, 2300,, ,, ,, ,, ,, ,, ,,end DATA Ron Avery,12, 2120,, 2249,21, 2302,22, 2427,19, ,, 2414,20, ,,end DATA Bob Blair,2, 1920,, 2021,13, ,, ,, ,, ,, ,,end DATA Richard Bowman,15, 1820,, ,, ,, 1829,5, 1903,12, 1748,8, ,,end 'DATA Dave Burke,0, 1940,, ,, ,, ,, ,, ,, ,,end DATA Graham Clazey,7, 1840,, ,, ,, ,, ,, ,, ,,end 'DATA Dave Clear,0, 2200,, ,, ,, ,, ,, ,, ,,end DATA Ev Colgin,5, 2000,, ,, 2145,26, ,, ,, ,, ,,end DATA Paul Collins,12, 1600,, 1730,22, 1625,5, ,, ,, ,, ,,end DATA Ray Collins,0, 2300,, ,, ,, ,, ,, ,, ,,end DATA John Cosgrove,3, 2300,, 2404,14, 2433,18, 2704,24, 2440,3, 2400,1, ,,end DATA Malcolm Cox,13, 2000,, ,, 2210,29, 2221,18, ,, ,, ,,end 'DATA Mickey Crozier,0, 2100,, ,, ,, ,, ,, ,, ,,end DATA Bruce Davison,8, 2400,, 2705,27, 2437,7, 2623,10, ,, 2706,15, ,,end DATA Alyson Dixon,11, 1900,, 1911,5, 2044,24, ,, ,, ,, ,,end DATA Dave Dixon,6, 2000,, 2030,7, ,, ,, ,, 2028,16, ,,end DATA Derek Dixon,6, 1920,, 2027,29, 2003,25, 1954,2, ,, 2043,21, ,,end DATA Paul Dixon,1, 1920,, 2026,15, 2007,9, 2057,14, 2105,10, 2045,11, ,,end 'DATA Alan Duffy,0, 2100,, ,, ,, ,, ,, ,, ,,end 'DATA Kim Easton,0, 2200,, ,, ,, ,, ,, ,, ,,end DATA Stuart Eggleston,0, 2100,, ,, ,, ,, ,, 2217,24, ,,end 'DATA Dawn Elliot,0, 1900,, ,, ,, ,, ,, ,, ,,end 'DATA Keith Elliot,0, 1640,, ,, ,, ,, ,, ,, ,,end 'DATA Julie Emmerson,0, 2200,, ,, ,, ,, ,, ,, ,,end 'DATA Mark Feeley,0, 1740,, ,, ,, ,, ,, ,, ,,end DATA Norman Felce,0, 2100,, ,, ,, ,, ,, ,, ,,end DATA Tony Gair,0, 2400,, ,, ,, ,, ,, ,, ,,end DATA Roger Garrington,14,2040,, ,, 2253,30, 2331,22, ,, 2322,14, ,,end DATA Colin Glass,0, 2040,, ,, ,, ,, ,, 2145,7, ,,end DATA Emma Grant,15, 2040,, ,, ,, 2150,17, 2048,4, 2056,9, ,,end 'DATA Joe Gordon,0, 2220,, ,, ,, ,, ,, ,, ,,end DATA Bill Hitchcock,0, 2120,, ,, ,, ,, ,, ,, ,,end DATA Steve Hobday,13, 1900,, ,, 2313,33, 2034,1, 1929,1, ,, ,,end DATA Tony Howe,11, 2400,, 2705,28, ,, ,, ,, ,, ,,end DATA Lesley Jackson,13, 2220,, ,, 2127,2, ,, ,, ,, ,,end 'DATA Ernie Johnson,0, 2600,, ,, ,, ,, ,, ,, ,,end DATA Paul Lavender,0, 1900,, ,, ,, ,, ,, ,, ,,end 'DATA Jacqui Lobley,0, 2300,, ,, ,, ,, ,, ,, ,,end 'DATA Paul Marshall,0, 2200,, ,, ,, ,, ,, ,, ,,end DATA Ian Maxwell,5, 2100,, 2158,30, ,, 2306,20, 2432,15, 2237,3, ,,end DATA Sandra Maxwell,9, 2220,, 2238,6, ,, ,, ,, ,, ,,end DATA Ken Maynard,9, 1700,, 1831,23, 1827,15, 1850,12, ,, 1913,23, ,,end 'DATA Danny McFarlane,0, 2100,, ,, ,, ,, ,, ,, ,,end DATA Wilson McKnight,2, 2020,, 2133,17, 2138,13, 2149,6, 2207,11, 2208,17, ,,end DATA Peter McManus,15, 1840,, ,, ,, 1909,11, ,, ,, ,,end 'DATA Catherine Morris,0,2200,, ,, ,, ,, ,, ,, ,,end 'DATA Sonja Muller,0, 2520,, ,, ,, ,, ,, ,, ,,end DATA Gerry O'Brien,0, 1940,, ,, ,, ,, ,, ,, ,,end 'DATA Mike O'Hara,0, 2220,, ,, ,, ,, ,, ,, ,,end DATA Kevin O'Neil,10, 2020,, ,, ,, ,, ,, ,, ,,end DATA Vince Oliver,9, 1800,, 1835,9, 1820,8, 1840,9, 1815,6, ,, ,,end DATA Jacquie Pitt,4, 2500,, 2704,25, 2640,14, ,, ,, ,, ,,end 'DATA Dave Pounder,0, 2040,, ,, ,, ,, ,, ,, ,,end DATA Adrian Potter,11, 2020,, 2117,11, 2141,21, ,, ,, ,, ,,end 'DATA Sean Price,0, 2020,, ,, ,, ,, ,, ,, ,,end DATA Geoff Prior,5, 1800,, 1849,10, 1836,10, 1920,15, 1829,5, 1849,12, ,,end DATA Sandra Quinn,0, 2600,, ,, ,, ,, ,, ,, ,,end DATA Linda Raine,4, 2140,, 2149,4, 2231,16, ,, ,, ,, ,,end 'DATA Steve Ramage,0, 2520,, ,, ,, ,, ,, ,, ,,end DATA Steve Ramsden,0, 2000,, ,, ,, ,, 2102,13, 2110,18, ,,end DATA Hayley Reed,7, 2220,, 2150,2, 2252,17, ,, ,, ,, ,,end DATA Tracey Reed,7, 2140,, ,, 2126,6, ,, ,, ,, ,,end DATA Allan Robertson,10, 2140,, 2240,12, ,, ,, ,, 2254,19, ,,end DATA Allen Routledge,1, 2020,, ,, 2245,31, 2332,23, 2310,7, 2234,5, ,,end DATA Richie Sampson,0, 2600,, ,, ,, ,, ,, ,, ,,end DATA Ian Semens,0, 2020,, ,, ,, ,, ,, 2142,25, ,,end DATA Gavin Spencer,10, 1920,, 1953,8, 1919,3, 2014,13, 2002,9, 2050,22, ,,end 'DATA Gavin Sword,0, 2200,, ,, ,, ,, ,, ,, ,,end DATA Alan Tait,0, 2300,, ,, ,, ,, ,, ,, ,,end 'DATA Charlie Tate,0, 1900,, ,, ,, ,, ,, ,, ,,end DATA Paul Taylor,0, 1700,, ,, ,, ,, ,, ,, ,,end DATA Bill Thompson,8, 2400,, 2400,3, 2237,1, 2330,7, 2500,16, 2324,4, ,,end DATA Keith Turnbull,0, 2300,, ,, ,, 2611,25, ,, ,, ,,end DATA Phil Tweddell,0, 2220,, ,, ,, ,, ,, ,, ,,end DATA Ken Tweedy,14, 1840,, ,, 2106,32, ,, ,, ,, ,,end 'DATA Carol Vinter,0, 2700,, ,, ,, ,, ,, ,, ,,end DATA Peter Watts,1, 1940,, ,, 2126,27, ,, ,, ,, ,,end DATA Dave Warnaby,2, 1900,, 2133,26, 2003,4, ,, ,, ,, ,,end DATA Phil Watson,3, 1920,, 2041,18, 2056,19, 2148,16, 2227,14, 2124,6, ,,end DATA David Williams,14, 2220,, ,, 2322,23, 2449,21, ,, 2344,10, ,,end DATA Steve Wills,0, 2020,, ,, ,, ,, ,, ,, ,,end DATA Jacky Wilson,6, 2100,, 2208,16, 2157,11, 2115,8, ,, 2344,26, ,,end DATA John Wilson,3, 2400,, 2330,1, ,, 2347,4, 2401,8, 2359,13, ,,end DATA Neil Wilson,12, 1920,, 2042,19, 2057,20, ,, ,, ,, ,,end DATA John Woodward,0, 2200,, ,, ,, ,, ,, ,, ,,end DATA Derek Wright,0, 2000,, ,, ,, ,, ,, ,, ,,end 'DATA Dave Wyatt,0, 1540,, ,, ,, ,, ,, ,, ,,end 'DATA Ken Younger,0, 2040,, ,, ,, ,, ,, ,, ,,end 'DATA xxxxxx,d, 2300,, ,, ,, ,, ,, ,, ,,end DATA end,0 teamdata: DATA 1,Dicka's Dropouts,2,BWD,3,The rot DATA 4,Crap,5,Woody is a fat bastard,6,Grangetown Workingmens Club DATA 7,Hayley's Comets,8,Billy Whizz,9,Sandra Maxies disco Panties,10,Scotch mist DATA 11,Aly's palies,12,Neil's nutters,13,Lesley's losers,14,Dave's ditherers DATA 15,Grant's Grunters,16,Derek's Dopes DATA 17,Whining Whingers,18,Janet's Joggers,19,Vauxies Horsies DATA 20,Muller's Mugs,21,Jacqui's Jockstraps,22,Archie's asses DATA 0,end FUNCTION j$ (x) REM return a right justified string of 3 characters j$ = RIGHT$(" " + STR$(x), 3) END FUNCTION FUNCTION j2$ (n) REM return a decimal point justified string of 5 characters IF INT(n) = n THEN j2$ = RIGHT$(" " + STR$(n), 3) + " " ELSE j2$ = RIGHT$(" " + STR$(n), 5) END IF END FUNCTION FUNCTION pdata$ (tm, ps, pt) REM return a formatted string IF tm = 0 AND ps = 0 THEN pdata$ = " " ELSE a$ = ptime$(tm) a$ = a$ + " " REM pdata$ = a$ + " " + RIGHT$(STR$(ps), 2) + " " + RIGHT$(STR$(pt), 2) pdata$ = a$ + " " + RIGHT$(STR$(ps), 2) + " " + j2$(pt) END IF END FUNCTION FUNCTION ptime$ (tm) REM convert a time in the format HHMMSSS to H:MM:SS and suppress leading 0's IF tm = 0 THEN ptime$ = " " ELSE a$ = RIGHT$(STR$(1000000 + tm), 5) IF tm > 5959 THEN ptime$ = LEFT$(a$, 1) + ":" + MID$(a$, 2, 2) + ":" + RIGHT$(a$, 2) ELSE ptime$ = " " + MID$(a$, 2, 2) + ":" + RIGHT$(a$, 2) END IF END IF END FUNCTION FUNCTION round20 (x, y) REM convert AVE( x + y) to nearest 20sec start time xsecs = 60 * (x \ 100) + (x MOD 100) ysecs = 60 * (y \ 100) + (y MOD 100) avexy = 20 * (((xsecs + ysecs + 20) \ 2) \ 20) round20 = 100 * (avexy \ 60) + avexy MOD 60 END FUNCTION SUB sorttemp SHARED temp(), count FOR r% = 1 TO count - 1 mmin = temp(2, r%): p% = r% FOR t% = r% + 1 TO count IF temp(2, t%) < mmin THEN mmin = temp(2, t%): p% = t% NEXT SWAP temp(1, p%), temp(1, r%): SWAP temp(2, p%), temp(2, r%) NEXT END SUB