Hi everyone!
I need some help with a VBscript for sorting things.
Here is what I would like help with:
We are having an election this summer. We have about 100 electoral districts, aka "ridings" and each riding has from 4 to 12ish candidates. I want to allow for 15 possible candidates. Each candidate belongs to a political party. However, we only really care about the 4 largest parties.
So last time, we got an XML file that provided a) each electoral district b) the candidate names c) candidate party d) number of votes
What I would like to do is take this data, put it into 15 temp variables, then do a FOR-NEXT loop to put this data into the 4 final sets of fields, only if they belong to one of the 4 desired parties and ignore the other numbers.
The XML data, the candidates arrive in order of who has the most votes. The problem is if anyone has zeroes, we see the random fringe parties, because the XML in that case arrives sorted in alphabetical order by candidate surname. I would LIKE to learn how to use a database with this, but Access is not cooperating, and it might be super complicated, so I figured I would try this first.
Here is my Commodore BASIC version :) Thanks!!!
dim party(15)
dim partyTemp (15)
dim partyFinal (4)
for count = 1 to 15
put party(count) into partyTemp(count)
put firstname(count) into firstnameTemp(count)
put lastname(count) into lastnameTemp(count)
put votes(count) into votesTemp(count)
next
for count = 1 to 15
let countAgain = 1
if partyTemp(count) = "LIB" or "PC" or "NDP" or "GRN" then
put partyTemp(count) into partyFinal(countAgain)
put firstnameTemp(count) into firstnameFinal(countAgain)
put lastnameTemp(count) into lastnameFinal(countAgain)
put votesTemp(count) into votesFinal(countAgain)
countAgain=countAgain+1
endif
next