Hi folks,
i am developing an application that takes in a load of footy score
predictions and then calculates points for each prediction once the games
have been played, it then works out the winners etc. Another factor is that
a player can belong to a team and teams themselves are in various local
leagues.
My problem is that once i've worked everything out i have to print various
tables including a table for each team showing every player in that team's
points awarded that week and i am finding that it takes my win 2k, pentium4
2.4ghz, 1Mb ram machine over two minutes to sort out these tables for only a
thousand predictions, so i'd like to know if thats what i should expect or
if my sorting code is awful and i'm missing several tricks !
i store an individual prediction in a list like
PredList = [#area : "", #gameNo : 0 , #pred1 : 0 , #pred2 : 0 , #pred3 : 0,
#pred4 : 0 , #pred5 : 0 , #pred6 : 0 , #pred7 : 0 , #pred8 : 0 , #pred9 : 0
, #pred10 : 0 , #pred11 : 0 , #pred12 : 0, #player : "", #team : "", #points
: 0,#place:1]
these are then grouped in another list as the game is split into local areas
and these local lists of prediction lists are the stored in one global
master list ie
gmasterpredlist[1][1].team is the team of the first prediction of the first
area.
by the time i want to print the team tables the data is sorted in the master
predictionlist by place in each area. I also have a similar global list of
area lists for the teams data for each league.
So thats my situation and here is my code which takes so long . . .
on printTeams3
-- sort the predictions list by team name
workingleaguelist = gfileleaguelist.duplicate() -- global list of the team
data in each league
templist = []
repeat with i=1 to workingleaguelist.count
templist[i] = []
repeat with j = 1 to workingleaguelist[i].count -- step through each
team in every league
thefilter = workingleaguelist[i][j][2]
slist = gmasterpredlist[i]
tempresult = filterList( slist, thefilter)
templist[i].append(tempresult) -- build a temp list where predictions
are grouped in lists by team name
end repeat
end repeat
-- start creating the html
member("temptext").text = "<html><head><style type='text/css'>BR
{page-break-after: always}</style></head><body> "
repeat with i = 1 to templist.count
repeat with j = 1 to templist[i].count -- now step through each team
list in templist
member("temptext").text =member("temptext").text & "<table
width=95%'><tr><Td colspan=4><font size=+2>" & templist[i][j][1][1] & "
Individual Team Tables</font></td></tr>"
member("temptext").text = member("temptext").text & "<tr><Td
colspan=4>Game Number " & ggamelist.gameNo & " Weekend " &
member("datefield").text & "</td></tr>"
member("temptext").text = member("temptext").text & "</table>"
member("temptext").text = member("temptext").text & "<table
width=95%'><tr><Td colspan=4><font size=+1>Team : " & templist[i][j][1][2] &
"</font></td></tr>"
member("temptext").text = member("temptext").text &
"<tr><TD>Place</td><TD>Player</td><TD>Points</td><TD></td></tr>"
repeat with m = 1 to templist[i][j].count
member("temptext").text = member("temptext").text & "<tr><TD>" & m &
"</td><TD>" & templist[i][j][m][3] & "</td><TD>" & templist[i][j][m][4] &
"</td><TD></TD></tr>"
end repeat
tempteamlist= []
member("temptext").text = member("temptext").text & "</table><br>"
put j
end repeat
put "area" & i
end repeat
member("temptext").text = member("temptext").text & "</body></html>"
printfile = the moviepath & "\data\printteamfile.htm"
temptext = member("temptext").text
fileerror = baWriteFile(printfile, temptext) -- write to file for printing
end
on filterList sList, filterStr
rList = []
mx = count (sList)
repeat with k = 1 to mx
fName = [sList[k].area, sList[k].team, sList[k].player,
sList[k].points ]
if sList[k].team =filterStr then append rList, fName
end repeat
return rList
end
by looking at the output i can see that it is the parsing of the team lists
in templist that takes all the time. I have also tried to do this in other
ways,for instance not creating a list of lists grouped by team name but
simply taking a unique team name from gfileleaguelist and then going through
the master prediction list and adding every occurence of that team name to
my output and the repeating for the next team name but this takes a similar
amount of time.
Another difficulty i have experienced on this project is wanting to insert
a value in a list at a given point and not overwriting the existing data but
moving it and all subsequent data along one place. I have to do this with a
repeat loop every time so that in effect to insert a value in a list at a
given place i have to step through the whole list. Is there a better way to
do this ?
all comments much appreciated
Lee Blinco
Multimedia Developer
AVR Productions
+44 (0)1462 819603
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL
PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping
with programming Lingo. Thanks!]