REM pier to pier results program num%=1000:rem max number of runners prn%=0:rem 0=HP-4MP, <>0=LQ400 lines%=90 columns%=2 type runner number as string * 4 nname as string * 20 club as string * 20 category as string * 3 time as string * 5 position as string * 4 cr as string * 2 end type REM a catalogue item TYPE catitem code AS LONG desc AS STRING * 36 cost AS LONG retail AS LONG barcode AS QUAD makerscode AS STRING * 16 cartonqty AS INTEGER location AS INTEGER minvalue AS LONG supplier AS STRING * 10 instock AS LONG modified AS LONG END TYPE dim huge runners(num%) as runner dim nulrunner as runner,x as runner DIM item AS catitem shared runners(),nulrunner,x,num%,lines%,columns%,prn%,item nulrunner.number="" nulrunner.nname="" nulrunner.club="" nulrunner.category="" nulrunner.time="" nulrunner.position="" nulrunner.cr=chr$(13)+chr$(10) loadrunners c%=0 'for r% = 1 to 999 'if runners(r%).category<>" " then incr c% 'next '?c% 'stop 'for ppos%=1 to 999 'if val(runners(ppos%).position) >179 then ' runners(ppos%).position=trim$(str$(val(runners(ppos%).position)+3)+" ") ' end if 'next saverunners 'for ppos%=180 to 294 'for r% = 0 to 999 'if val(runners(r%).position) = ppos% then ' for t% = 0 to 999 ' if val(runners(t%).position)=ppos%-3 then ' runners(r%).time=runners(t%).time ' exit for ' end if ' next ' ' exit for ' end if ' next 'next 'saverunners 'rem add dummy pos/time to all 'for r% = 1 to num% 'if val(runners(r%).number) <> 0 then ' runners(r%).position=trim$(str$(rnd(1000))) ' runners(r%).time=tohms(str$(rnd(9999))) ' end if ' next REM main menu menu: cls ?"1) Add new runner" ? ?"2) Edit existing runner" ? ?"3) List all runners to screen" ? ?"4) List all results so far to screen" ? ?"5) Input times" ? ?"6) Search for name" ? ?"7) Delete runner" ? ?"8) Print all runners" ? ?"9) Print results so far" ? ?"10)Exit" ? input "select 1-10";n$ n=val(n$) select case n case 1 addrunner case 2 changerunner case 3 listrunners case 4 listresults case 5 results case 6 search case 7 deleterunner case 8 printrunners case 9 ? input "Big or Normal?",b$ if left$(ucase$(b$),1)="B" then b%=1 else b%=0 printresults(b%) case 10 close end end select goto menu sub addrunner do ? input "Number? ",n$ n$=left$(trim$(n$),3) n%=val(n$) if n% = 0 then exit loop if val(runners(n%).number) <> 0 then ?"Runner already exists!" else runners(n%).number=n$ input "Name? ",runners(n%).nname input "Club? ",runners(n%).club do input "Category (m99/f99)? ",c$ c$=ucase$(left$(c$+" ",3)) if left$(c$,1)<>"M" and left$(c$,1)<>"F" then ?"Invalid category, please re-enter" else exit loop end if loop runners(n%).category=c$ rem write runner to disk file open "rundat.txt" for random as #1 len=len(nulrunner) put #1,n%,runners(n%) close end if loop end sub sub changerunner input "Race Number",n% if VAL(runners(n%).number)=0 then ?"Runner does not exist" getkey exit sub else editrunner(n%) end if end sub sub clearrunners for r% = 0 to num% runners(r%)=nulrunner next end sub sub deleterunner input "Race Number",n% if VAL(runners(n%).number)=0 then ?"Runner does not exist" getkey exit sub else runners(n%)=nulrunner rem write editted runner to disk file open "rundat.txt" for random as #1 len=len(nulrunner) put #1,n%,runners(n%) close end if end sub sub editrunner(n%) dim r as runner ?"Number ";runners(n%).number ?"Name ";runners(n%).nname ?"Club ";runners(n%).club ?"Category ";runners(n%).category ?"Position ";runners(n%).position ?"Time ";runners(n%).time ? input "Name? ",rnname$ input "Club? ",rclub$ do input "Category (m99/f99)? ",c$ if c$="" then exit loop c$=ucase$(left$(c$+" ",3)) if left$(c$,1)<>"M" and left$(c$,1)<>"F" then ?"Invalid category, please re-enter" else exit loop end if loop rcategory$=c$ input "Position? ",rposition$ input "Time? ",rtime$ if rnname$<>"" then runners(n%).nname=rnname$ if rclub$<>"" then runners(n%).club=rclub$ if rcategory$<>"" then runners(n%).category=rcategory$ if rposition$<>"" then if rposition$="0" then runners(n%).position=nulrunner.position else runners(n%).position=rposition$ end if end if if rtime$<>"" then runners(n%).time=tohms(rtime$) rem write editted runner to disk file open "rundat.txt" for random as #1 len=len(nulrunner) put #1,n%,runners(n%) close end sub sub getkey ?"Press any key to continue."; do loop until instat end sub sub listresults rem count runners finished dim temp1!(num%),temp2%(num%) count%=0 for r% = 0 to num% if val(runners(r%).position)<>0 then temp1!(count%)=val(runners(r%).position) temp2%(count%)=r% incr count% end if next array sort temp1!() for count%, tagarray temp2%() for q% = 0 to count% r%=temp2%(q%) if val(runners(r%).position)<>0 then print right$(" "+str$(q%+1),3);" ";runners(r%).number;runners(r%).nname;" ";_ runners(r%).club;" ";runners(r%).category;" ";runners(r%).time end if next close getkey end sub sub listrunners for r% = 0 to num% if val(runners(r%).number)<>0 then print runners(r%).number;runners(r%).nname;_ runners(r%).club;runners(r%).category;runners(r%).time;_ runners(r%).position end if next getkey end sub sub loadrunners open "rundat.txt" for random as #1 len=len(nulrunner) for r% = 1 to num% get #1,r%,runners(r%) k$=ucase$(runners(r%).club) if left$(k$,3)="U/A" or left$(k$,2)="UA" then runners(r%).club = "Unattached" next close#1 end sub sub printresults(big%) rem if big%<>0 then print to laserjet at 1 column, 40 lines/page, big type newlines%=lines% newcols%=columns% rem count runners finished dim temp1!(num%),temp2%(num%) count%=0 for r% = 0 to num% if val(runners(r%).position)<>0 then temp1!(count%)=val(runners(r%).position) temp2%(count%)=r% incr count% end if next if count% = 0 then ?"There is nothing to print!" getkey exit sub end if array sort temp1!() for count%, tagarray temp2%() title$=" Race results for Pier to Pier race Sunday 21st May 2000" head$="Pos No. Name Club Cat Time " width "lpt1:",200 e$ = CHR$(27): ff$ = CHR$(12): cr$ = CHR$(13) open "lpt1:" for output as #2 if prn%<>0 then 'LQ400 printer print #2,chr$(27);"3";chr$(19):'set 8 lines/inch else 'HP-4MP if big%=0 then PRINT #2, e$ + "%0A"; : REM enter PCL mode PRINT #2, e$ + "E"; : REM reset PRINT #2, e$ + "%0A"; : REM enter PCL mode PRINT #2, e$ + "&l26A"; : REM A4 paper PRINT #2, e$ + "&l0O"; : REM portrait PRINT #2, e$ + "&l5C"; : REM Vertical motion 5/48th inch /line =9.5 lines/inch approx. PRINT #2, e$ + "&l90F"; : REM 90 lines /page? PRINT #2, e$ + "(10U"; : REM symbol set code page 437 (formerly ISO L1) PRINT #2, e$ + "(s4099T"; : REM courier font PRINT #2, e$ + "(s16H"; : REM 16 cpi PRINT #2, e$ + "(s0S"; : REM solid font PRINT #2, e$ + "(s0B"; : REM normal weight PRINT #2, e$ + "&a1L"; : REM left margin 1 PRINT #2, e$ + "&l2E"; : REM 2 line top margin PRINT #2, e$ + "&a0R"; : REM move to row 0 PRINT #2, cr$; : REM move to start of line else PRINT #2, e$ + "%0A"; : REM enter PCL mode PRINT #2, e$ + "E"; : REM reset PRINT #2, e$ + "%0A"; : REM enter PCL mode PRINT #2, e$ + "&l26A"; : REM A4 paper PRINT #2, e$ + "&l0O"; : REM portrait PRINT #2, e$ + "&l11C"; : REM Vertical motion 11/48th inch /line =3.8 lines/inch approx. PRINT #2, e$ + "&l50F"; : REM 50 lines /page? PRINT #2, e$ + "(10U"; : REM symbol set code page 437 (formerly ISO L1) PRINT #2, e$ + "(s4099T"; : REM courier font PRINT #2, e$ + "(s8H"; : REM 8 cpi PRINT #2, e$ + "(s0S"; : REM solid font PRINT #2, e$ + "(s0B"; : REM normal weight PRINT #2, e$ + "&a1L"; : REM left margin 1 PRINT #2, e$ + "&l1E"; : REM 1 line top margin PRINT #2, e$ + "&a0R"; : REM move to row 0 PRINT #2, cr$; : REM move to start of line newlines%=40 newcols%=1 end if end if maxpage%=int(count%/newcols%/newlines%+.9999) do ? "Which page (0-";maxpage%;") 0 = all "; input w% loop until (w% >= 0) and (w% <= maxpage%) if w% = 0 then pstart%=1 pstop%=maxpage% else pstart%=w% pstop%=w% end if for page%=pstart% to pstop% print #2, if prn%=0 and big%=0 then PRINT #2, e$ + "(s8H"; : REM 16 cpi print#2,title$ if prn%=0 and big%=0 then PRINT #2, e$ + "(s16H"; : REM 16 cpi print#2, for c%=1 to newcols% if c%<>1 then print#2," "; print#2,head$; next print#2, firstnum%=(page%-1)*newlines%*newcols%+1 if page%=maxpage% then colinc%=int((count%-(maxpage%-1)*newlines%*newcols%) / newcols%+.999) else colinc%=newlines% end if for lline%=1 to colinc% for c%=1 to newcols% j%=firstnum%+(c%-1)*colinc%+lline%-1 k%=temp2%(j%-1) if val(runners(k%).position) <> 0 then if c%<>1 then print#2," "; if trim$(runners(k%).nname)="" then nm$="Unknown Runner " else nm$=runners(k%).nname end if 'print#2, right$(" "+str$(j%),3);" ";runners(k%).number;runners(k%).nname;" ";_ print#2, right$(" "+str$(j%),3);" ";left$(trim$(str$(k%))+" ",4);nm$;" ";_ runners(k%).club;" ";runners(k%).category;" ";runners(k%).time; end if next ?#2, next ?#2,chr$(12);:rem eject page next close end sub sub printrunners dim temp2%(num%) head$="No. Name Club Cat " title$="Entry list for Pier to Pier race Sunday 16th May 1999" width "lpt1:",200 open "lpt1:" for output as #2 e$ = CHR$(27): ff$ = CHR$(12): cr$ = CHR$(13) if prn%<>0 then 'LQ400 printer print #2,chr$(27);"3";chr$(19):'set 8 lines/inch end if rem count runners entered count%=0 for r% = 0 to num% if val(runners(r%).number)<>0 then incr count% temp2%(count%)=r% end if next if count% = 0 then ?"There is nothing to print!" getkey exit sub end if if prn%<>0 then 'LQ400 printer print #2,chr$(27);"3";chr$(19):'set 8 lines/inch else 'HP-4MP PRINT #2, e$ + "%0A"; : REM enter PCL mode PRINT #2, e$ + "E"; : REM reset PRINT #2, e$ + "%0A"; : REM enter PCL mode PRINT #2, e$ + "&l26A"; : REM A4 paper PRINT #2, e$ + "&l0O"; : REM portrait PRINT #2, e$ + "&l5C"; : REM Vertical motion 5/48th inch /line =9.5 lines/inch approx. PRINT #2, e$ + "&l90F"; : REM 90 lines /page? PRINT #2, e$ + "(10U"; : REM symbol set code page 437 (formerly ISO L1) PRINT #2, e$ + "(s4099T"; : REM courier font PRINT #2, e$ + "(s16H"; : REM 16 cpi PRINT #2, e$ + "(s0S"; : REM solid font PRINT #2, e$ + "(s0B"; : REM normal weight PRINT #2, e$ + "&a1L"; : REM left margin 1 PRINT #2, e$ + "&l2E"; : REM 2 line top margin PRINT #2, e$ + "&a0R"; : REM move to row 0 PRINT #2, cr$; : REM move to start of line end if maxpage%=int(count%/columns%/lines%+.9999) do ? "Which page (0-";maxpage%;") 0 = all "; input w% loop until (w% >= 0) and (w% <= maxpage%) if w% = 0 then pstart%=1 pstop%=maxpage% else pstart%=w% pstop%=w% end if for page%=pstart% to pstop% print#2,title$ print#2, for c%=1 to columns% if c%<>1 then print#2," "; print#2,head$; next print#2, firstnum%=(page%-1)*lines%*columns%+1 if page%=maxpage% then colinc%=int((count%-(maxpage%-1)*lines%*columns%) / columns%+.999) else colinc%=lines% end if for lline%=1 to colinc% for c%=1 to columns% j%=firstnum%+(c%-1)*colinc%+lline%-1 k%=temp2%(j%) if c%<>1 then print#2," "; ?#2,runners(k%).number;runners(k%).nname;" ";runners(k%).club;" ";_ runners(k%).category; next ?#2, next ?#2,chr$(12):rem eject page next close end sub sub results input "Position? ",p% ? ? do p$=trim$(str$(p%)) ?"Position ";p$ input"Number? ",n$ n%=val(n$) mod 1000 if n%=0 then exit loop ?runners(n%) input "Time mmss? ",t$ runners(n%).time=tohms(t$) runners(n%).position=p$ rem write editted runner to disk file open "rundat.txt" for random as #1 len=len(nulrunner) put #1,n%,runners(n%) close incr p% loop end sub sub saverunners open "rundat.txt" for random as #1 len=len(nulrunner) OPEN "catalog.max" FOR RANDOM AS #4 LEN = len(item) for r% = 1 to num% put #1,r%,runners(r%) item.code=r% item.desc=left$(runners(r%).nname+string$(20," "),20)+left$(runners(r%).club,16) item.barcode=item.code item.cost=val(right$(runners(r%).category,len(runners(r%).category)-1)) item.retail=0 put#4,r%,item next close end sub sub search input "Search for what?",s$ for r% = 1 to num% if instr(ucase$(runners(r%)),ucase$(s$)) then ?runners(r%) next getkey end sub function tohms(t$) as string rem convert t$ into MM:SS tm$="0000"+t$ s$=right$(tm$,2) tm$=left$(tm$,len(tm$)-2) m$=right$(tm$,2) tohms= m$+":"+s$ end function