> AVCalc 8 Calculate AV results from General Election results : 0 array$(0,20),seats%(10),won%(10),lost%(10)  :Close_All:: : in% = "GEVotes.csv" out%="AVVotes.csv" csv_rd(in%,0,20):clear 2 A%=0 10: array$(0,A%)::csv_wr(out%,0,9) + Seat,Con,Lab,LD,SNP,PC,Grn,BNP,UKIP,, :con%=1:lab%=2:ld%=3:snp%=4:pc%=5:grn%=6:bnp%=7:ukip%=8 :  csv_rd(in%,0,20) array$(0,1)<>"" av csv_wr(out%,0,9) wr(out%,",,,,,,,,,"+13) & win%:seats%(win%)=seats%(win%)+1  #in% clear JB%=0: A%=0 10:seats%(A%):array$(0,A%)=seats%(A%):B%=B%+seats%(A%) 1:array$(0,0)="Total: "+B%:csv_wr(out%,0,9) 4: A%=0 10: array$(0,A%)::csv_wr(out%,0,9) * A%=1 10:array$(0,A%)=(won%(A%)): 6array$(0,0)="Changes: seats won":csv_wr(out%,0,9) + A%=1 10:array$(0,A%)=(lost%(A%)): 7array$(0,0)="Changes: seats lost":csv_wr(out%,0,9) #out%:out%=0 #in%:in%=0 Ș : av array$(0,0)=array$(0,1) , A%=1 8:array$(0,A%)=array$(0,A%+8): ! A%=9 19:array$(0,A%)="": csv_wr(out%,0,9):max%=max  'los%=9:win%=winner:rem%=remaining  win%=0 array$(0,0)="" los%=min Ȏ los%  1 : Conservative 5 Con->0Con,10Lab,25LD,5SNP,5PC,5Grn,10BNP,10UKIP Larray$(0,lab%) :array$(0,lab%) =(array$(0,lab%) +array$(0,con%)/10) Karray$(0,ld%) :array$(0,ld%) =(array$(0,ld%) +array$(0,con%)/4) Larray$(0,bnp%) :array$(0,bnp%) =(array$(0,bnp%) +array$(0,con%)/10) Larray$(0,snp%) :array$(0,snp%) =(array$(0,snp%) +array$(0,con%)/20) Larray$(0,pc%) :array$(0,pc%) =(array$(0,pc%) +array$(0,con%)/20) Larray$(0,grn%) :array$(0,grn%) =(array$(0,grn%) +array$(0,con%)/20) Larray$(0,ukip%):array$(0,ukip%)=(array$(0,ukip%)+array$(0,con%)/10)  2 : Labour 5 Lab->10Con,0Lab,40LD,5SNP,5PC,20Grn,10BNP,0UKIP Iarray$(0,con%):array$(0,con%)=(array$(0,con%)+array$(0,lab%)/10) Karray$(0,ld%) :array$(0,ld%) =(array$(0,ld%) +array$(0,lab%)*4/10) Iarray$(0,snp%):array$(0,snp%)=(array$(0,snp%)+array$(0,lab%)/20) Iarray$(0,pc%) :array$(0,pc%) =(array$(0,pc%) +array$(0,lab%)/20) Harray$(0,grn%):array$(0,grn%)=(array$(0,grn%)+array$(0,lab%)/4) Iarray$(0,bnp%):array$(0,bnp%)=(array$(0,bnp%)+array$(0,lab%)/10)  3 : LibDem 3 LD->20Con,25Lab,0LD,5SNP,5PC,20Grn,0BNP,0UKIP Garray$(0,con%):array$(0,con%)=(array$(0,con%)+array$(0,ld%)/5) Garray$(0,lab%):array$(0,lab%)=(array$(0,lab%)+array$(0,ld%)/4) Harray$(0,snp%):array$(0,snp%)=(array$(0,snp%)+array$(0,ld%)/20) Harray$(0,pc%) :array$(0,pc%) =(array$(0,pc%) +array$(0,ld%)/20) Garray$(0,grn%):array$(0,grn%)=(array$(0,grn%)+array$(0,ld%)/5)  4 : SNP 3 SNP->0Con,25Lab,25LD,0SNP,0PC,0Grn,0BNP,0UKIP Harray$(0,lab%):array$(0,lab%)=(array$(0,lab%)+array$(0,snp%)/4) Harray$(0,ld%) :array$(0,ld%) =(array$(0,ld%) +array$(0,snp%)/4)  5 : PC 2 PC->0Con,25Lab,25LD,0SNP,0PC,0Grn,0BNP,0UKIP Garray$(0,lab%):array$(0,lab%)=(array$(0,lab%)+array$(0,pc%)/4) Garray$(0,ld%) :array$(0,ld%) =(array$(0,ld%) +array$(0,pc%)/4)  6 : Green 2 PC->0Con,20Lab,25LD,5SNP,5PC,0Grn,0BNP,0UKIP Harray$(0,lab%):array$(0,lab%)=(array$(0,lab%)+array$(0,grn%)/5) Harray$(0,ld%) :array$(0,ld%) =(array$(0,ld%) +array$(0,grn%)/4) Iarray$(0,snp%):array$(0,snp%)=(array$(0,snp%)+array$(0,grn%)/20) Iarray$(0,pc%) :array$(0,pc%) =(array$(0,pc%) +array$(0,grn%)/20)  7 : BNP 1 BNP->0Con,0Lab,0LD,0SNP,0PC,0Grn,0BNP,0UKIP  8 : UKIP 4 UKIP->100Con,0Lab,0LD,0SNP,0PC,0Grn,0BNP,0UKIP Garray$(0,con%):array$(0,con%)=(array$(0,con%)+array$(0,ukip%))  los% array$(0,los%)="" &B=0: A%=0 9:B=B+array$(0,A%): # A%=0 9: array$(0,A%)<>0 'array$(0,A%)=(100*array$(0,A%)/B)   : rem%>2:array$(0,los%)="ELIMINATED":csv_wr(out%,0,9) array$(0,los%)=""   rem%=1:win%=los%  win% los%=0 $clear:array$(0,win%)="*WINNER*" Zwin%<>max%:array$(0,max%)="-LOSER-":won%(win%)=won%(win%)+1:lost%(max%)=lost%(max%)+1  : Dݤwinner:A%=0::A%=A%+1:array$(0,A%)>50 A%>8: A%>8:=0 =A% Wݤmax:B=0:C%=0: A%=1 10:array$(0,A%)<>0:array$(0,A%)>B:C%=A%:B=array$(0,A%) :=C% Yݤmin:B=100:C%=0: A%=1 10:array$(0,A%)<>0:array$(0,A%)0:B%=B%+1 :=B% : clear ! A%=0 10:array$(0,A%)="":  : Close_All "in%=in%:in%:A%=in%:in%=0:#A% 'out%=out%:out%:A%=out%:out%=0:#A%  : ( Read CSV file from in% to array$() ( ---------------------------------- csv_rd(i%,imax%,rmax%) s$=rd(i%)  record%=0 rmax%-1 -i%=s$+",",","):r$=s$,i%-1):s$=s$,i%+1) .r$,1)="""": r$,1)="""":r$=r$,2,r$-2) i%=0  /i%=r$,"""",i%+1): i%:r$=r$,i%)+r$,i%+1) i%=0 array$(imax%,record%)=r$ record% imax%=imax%+1   * Write CSV file from array$() to out% * ------------------------------------ csv_wr(o%,item%,rmax%)  record%=0 rmax%-1 r$=array$(item%,record%) i%=0  5i%=r$,"""",i%+1): i%:r$=r$,i%)+r$,i%):i%=i%+1 i%=0 # r$,",")<>0 r$=""""+r$+"""" wr(o%,r$+",") record% #out%=#out%-1:#out%,13   ݤrd(i%)=#i% wr(o%,A$):#o%,A$;: