Ben's profileBen Coley's BlogBlogListsGuestbook Tools Help

Blog


    August 30

    Spiders on Drugs

    Just finishing writing my content for the Microsoft Imagine Cup Invitationals, and I got bored, decided to go on Youtube to look for some videos, decided I hate spiders so I'll look for a video of them (weird I know!) and found probably the most entertaining video I've seen to date: 

      

    August 26

    Busyyy

    As you can see, I haven't blogged in a while, but I have more good excuses for this.  Firstly, I've been very busy with work.  Secondly, I've been very busy with home.
     
    Our house still had a few missing things last week, so I made sure I went out to buy the washing up bowl, door mat, and various other house-hold items that we needed.  Then I decided the house was a bit of a mess, so I set about cleaning it.  All went swimmingly until the vacuum cleaner exploded (for no apparent reason) and upon closer inspection I discovered that it could not be mended, so I shot out to Argos to buy another one so I could finish the other half of the job I had started.
     
    Then there was the work.  After posting about Virtual Earth, I wanted to make it even more user friendly and useful, so I built a UI for it based on the Vista Control Panel.  I also started adding features to it that would allow users to manipulate the data without having to open the database in Access, making it easier to administrate for the users.  This of course added more development time, and I have bigger commitments, such as the Imagine Cup booklet and the Inspiration Tour, the latter of which is due by next Wednesday.  Anyway, I managed to get most of the application working, I'm just adding the finishing touches and then I'll post some screenshots of what it looks like!  I've been porting a game between XNA and Embedded this weekend so we can 'tell a story' with our presentations, hopefully this will make sense when I run it by Ed!
     
    Just as a side note, it looks like September - October is going to be an awesome time for all us gamers, with games like Half-Life 2: Episode 2, Portal, GTA4, and of course, the third release of that well known first-person-shooter, known as 'Halo 3' all becoming available at the same time!  Looks like Christmas '07 is going to be packed with epic battles, struggles against unknown alien forces, and violence on the streets of 'New York(?)' !!!
    August 17

    I've Conquered Virtual Earth!!

    Sorry about not posting in a few days, there's not been much to report: just been quietly working away on Microsoft Inspiration Tour Demos.  Still working on the XNA stuff, so stay tuned for that!
     
    When I got to work the other day, I decided to have another stab at finishing the Virtual Earth maps, and somehow this time, I managed to do it!  Firstly what I have is an Access Database, which has two tables: one for holding lists of all the universities, complete with postcodes and a unique identifier, the other table holds a list of all the MSPs, each with their own unique identifiers, and a foreign key field that points to the unique identifiers of the universities (so we know which MSPs are at which universities!).  Okay, now all the database stuff is out the way, I can begin to explain.
     
    Firstly, in Visual Studio (programming in C#), I have a website set up.  With this website, comes Default.aspx, and Default.aspx.cs.  Just in case you don't know, the .cs file is the C# code-behind file that is processed everytime a user accesses Default.aspx.  So logically, in this file is where I do my database reading.  I set up some Access objects, such as a connection, reader, and sql command, so that I could successfully query my database and return results.  The SQL statement I used to access all of this data was something like:
    SELECT Uni.UniName, Uni.PostCode, Msp.MspName FROM Uni, Msp WHERE MSP.UniID = Uni.ID ORDER BY Uni.UniName;
    Effectively, this selects all the universities and MSPs, and pairs them up so we know which belongs where.  There was obviouisly a bit more to it than this (such as a solution if there were multiple MSPs at one university, or if there were no MSPs for a particular university), but I won't delve too far into that at this time.
     
    Once all this selecting is over with, all the results are passed to a few arrays, which can then be accessed by the standard .aspx page for data output.  Now to move on to the .aspx page.
     
    The page has some Javascript on it, which imports the Virtual Earth .js file, and then creates a new VEMap object, and throws it on to the page in the form of a Div element.  Then using Javascript functions, we can search for all the postcodes of the universities, and begin plotting them onto the map.  Anyone spot a problem with this?  The Javascript runs client-side, but all our arrays are stored server-side.  So the next task consists of creating Javascript using server-side C#.  Sounds simple, but it really wasn't.  The code roughly looked similar to the below:
    var MSPNames = New Array(<%=MSPCount%>);
     
    <%
    for(int t=1;t<(MSPCount+1);t++)
    {
    Response.Write("MSPNames[" + t + "]=\"" + CSMSPNames(t) + "\";\n");
    }
    %>
    This code produces something along the lines of:
    var MSPNames = New Array(3);
     
    MSPNames[1] = "Ben Coley";
    MSPNames[2] = "John Smith";
    MSPNames[3] = "Anna Johnson";
    Once this was done however, the arrays from the C# code were visible to the Javascript, and so it could begin processing the data and loading it onto the Virtual Earth Map in the form of pushpins.  Again, I hit another hurdle.  This time, it was to do with Javascript.  I am aware that Javascript is supposed to be a single-process language - basically, it's not meant to resume doing the first function until it's finished the second function that was called from the first.  However, because the way we're talking to the Virtual Earth API involves setting up an event handler, Javascript treats this as a separate program (of sorts) and continues processing while it's processing the new event.  This means that before the Virtual Earth Map has time to plot the first university, I'm already sending it the second, third, fourth...  This was obviously a problem because it started plotting all the universities in the other universities places.
     
    So I firstly thought, "Can't I create some kind of 'wait' event?".  The simple answer to this question is "No" The reason for this is the browser thinks Javascript has crashed if it takes too long to process a command, so it stops the Javascript and crashes the whole browser, and also unfortunately uses up 100% of the CPU.  So there had to be another solution.  Then I found it - rather than calling the FindLocation function from a For loop (which would loop before the command had a chance to respond), I'd call the FindLocation function once with the first value, and then have it call itself with the next value once it had completed (this is known as recursing in the programmer space).  Sure enough, this caused the Javascript to wait to find one university before proceeding to the next, and thus, a successful solution had been found!
     
    Finally, I decided this web-program looked a bit Web 1.0 (as opposed to Web 2.0, which refers to the way a web-application ought to look, i.e. crisp, functional... vista-looking, if you will), so I started writing a bit of CSS (Cascading Style Sheets) to apply some nice graphical effects to the program.  Such effects included a vista-looking progress bar that progresses as each university is added to the map; a vista-looking text alert that calculates how much time it will take to add all the data to the map; a dark grey alpha layer over the map with the white words "Loading" on it so that you can only just see what it's doing in the background; and finally, once the page has finished loading, a text-update showing how many universities and MSPs have been added to the map, a Windows Live logo, and an overview of the UK so that all university pushpins are visible.
     
    The great thing about this web-application is that it's completely reusable; you could take the database I have, fill it in with different data (for a different country, or a different buildings instead of universities, or different people instead of MSPs...) and then run the application and let it find multiple areas to plot on the map...  Another cool thing is that once the program has found all the areas, you can save them to a collections file, so you basically have a "cached version" of what you see before you; this is especially useful if you don't want to wait each time to load up all the data, or if you know you'll only be updating the map every so often, etc.
     
    I will attach some photos once I get back to my Dell (it's at work at the moment).
     
    If anyone would like all the source code I have for this application, feel free to contact me by leaving a comment, and I will zip and send it to you!
     
    August 13

    XNA - All The Way

    Thanks to Andrew Sithers, I discovered an internal website with loads of cool XNA demos to trawl through for the XNA demo content.  Once I've chosen which demos to use, I will post the steps I took and some screen shots so everyone can see!! But now off to actually play my Xbox 360, rather than developing for it, starting with a tournament of PES6 (Pro Evolution Soccer 6) with Ian and Apurva!

    www (weekend, weekend, weekend!!)

    Yes I know, it's Monday and I haven't posted since Thursday last week, but I have a good excuse.  I decided to work from home on Friday so that I could continue developing XNA demo content for the campus tour (more on this later).  Once I was happy with what I'd done, I jumped in the car and headed back to Leicester to see Jess, my family, and friends.  I spent Saturday with Jess, where I got a haircut, went shopping, walked down New Walk, went to the museum, and generally chilled out, which was awesome!  I also got to see my friends on Sunday and play golf, which was cool because I won (for once!), having only messed up on one hole.
     
    I spent so much time this weekend on the move that I barely had time to get to a computer, never mind connect to the web and write a blog!  Jess cooked dinner for me on Sunday which was aces, and we just chilled together and watched the box until we got tired and went to bed.
     
    This morning, I left at 7:00AM to head back to Reading to continue my work on XNA.  I expected to arrive back at 9:00AM or there abouts, as the journey usually takes around two hours.  However on my travels, I discovered to my dismay that the entrance to the M40 was shut.  This added an extra hour on to my journey time, as I had to drive down A roads the whole way.  All was not lost, however, as some of the roads I drove down were really pretty, and as it's a sunny day, I found this to be rather enjoyable.
     
    Now I am sitting down at my computer in the lovely city of Reading, about to continue XNA development.  I plan to post another blog entry later detailing my successes with game-programming, so stay tuned!! 
    August 09

    Thursday with Dad

    My dad visted me today, which was awesome given that I've not seen him in over a month!  I showed him around Microsoft, and showed him all the cool benefits we get as employees; we even managed to find time for a quick game of foosball, which he whooped me at.  Then he left his car at MS, jumped in my car and I drove us home so he could give me some gear so I could fix a bug in the software he's using.  This went rather smoothly, and we even had the television on just for some background noise.

    This turned out to be a really good day - productive in the way that I started fixing dad's software bug, (and also managed to get some work done on XNA development with my newly aquired Creator's Club membership, thanks to Claire!) and fun in the way that I got to show dad the company, and sit in the sun and have a coffee.

    Tomorrow I plan to finish what I've started on XNA so I can begin to set it up as a demo ready for Ed next week.  I'd also quite like to go back to Leicester this weekend to grab some more stuff and see the rest of my family and friends, and perhaps even get a haircut... we'll see!!

    August 08

    Cars, Computers and Cryptic Titles

    So today started with me getting in my car and driving it to Ford.  Apparently there was something wrong with the engine, and I was strongly advised (both by the internet community and my car's manual) to take it to a Ford dealership.  So I dropped the car in at about 9:00AM and headed home on foot, which took me about 40mins.  It was a nice sunny day and I had my HTC Touch with me for music, so I didn't really fancy the bus.
     
    When I got home, I grabbed myself an orange juice and stuck on the news.  Then I heard this really low grunting noise and turning my head to the left to look up the stairs, I saw a hung-over Ian stumbling down, attempting to talk to me.   When he'd finally re-mastered the art of speech, he managed to put together the words "going work in five, you coming?".  Up until now, I'd decided I could work from home today, but seeing Ian soldier on this way inspired me to go to work, so I grabbed my stuff and off we headed, into the sun-rise.
     
    When we got to work, it was about 10:30AM and still no word from Ford (with regards to the 1hour diagnostics test).  So I spent most of the day filtering through my Outlook "To Do" list, which consisted of about ten items.  By the time I was ready to call it a day, only two remained (both of these rely on others so I was unable to complete them).  A quick watch-check revealed the time to be 4:30PM, still no word from Ford.  Having already rang once and being put on infinite hold, I rang them again, only to be informed that an exhaust replacement was necessary, and that it would cost me around £630.00.  My reaction to this was simple: "No way am I paying that."  Luckily my step dad Mark informed me that I could drive on with this problem and get it fixed in my home-city of Leicester for around £250.00, a much more reasonable amount.  I learnt two things today: 1- Don't get your car serviced by Ford unless absolutely necessary.  2- Hung-over Ian is fun!!  Laughing at him when he winced in the sunlight was one of the funnier points of the day, so I wasn't all that upset about the car in the end, as it worked out cheaper than I expected!

    Home-Work

    Ah the beauty of working at Microsoft.  The attitude to work is truly inspired: "as long as you do the work, we don't care where or how you do it".  Naturally this means that you can work from home if you don't need to come in to the office.  So late Monday night, I scheduled an all-day-event for Tuesday with the title "content development - working from home" to let everyone know I was at home Tuesday.
     
    This was amazing for two reasons.  Reason 1: I was able to actually get up at 9:00AM and start work, instead of getting up at 7:30AM to get to the office for 9:00AM.  Reason 2: I got to get up at 9:00AM.  Seriously people, it's so amazing the difference a decent night's sleep can make to your day.  I got so much done Tuesday!  The .NET books Ed provided me with to develop content for the Embedded machine and Sideshow board he's given me proved truely invaluable.
     
    The first time I attempted to create an Embedded image, the documentation on the internet was nothing short of shabby, which caused me many issues in actually deploying the image to the device I was trying to program.  But with Ed's books, providing step-by-step instructions to deploying Embedded images and .NET programs to your Embedded device, it was a doddle.  Literally.  I therefore highly recommend them as bed-time reading (.NET Compact Framework - Andy Wigley & Stephen Wheelwright and Embedded Programming With The .NET Micro Framework - Donald Thompson & Rob S. Miles)
    August 06

    Developing with Virtual Earth

    In the past few days at work, I've been writing an applicaton to map all the Universities in the UK to a Virtual Earth map, so we can see which Universites we've reached.
     
    This task probably could have been easier, but I decided to go about it in my own way, as I like to 'learn as I go'.  So my first thoughts were, "let's put all the univerities in a nice Access database so I can pull them out programmatically!".  The first problem with this was that none of the data was particularly 'friendly'.  So I sat down and pasted all the data I was given into an Excel spreadsheet... promptly then spending the rest of the day cleaning it up.  Once this task was complete, I moved all my data over to Access, and read up on how to programatically use SQL to pull this data into my program.  Finally, I wrote some C# code which called on a few Javascripted Virtual Earth functions to add the university locations to a map of the UK, and then added the Microsoft Student Partners to the same map.
     
    The main problem with doing this was the Javascript functions seemed to be creating new threads all over the place (which I found odd, because by default Javascript isn't a multithreading langauge).  I won't go in to the programming concepts involved, sufficed to say this caused me a problem: all the universities appeared in the correct places, but all their names were mixed up, which naturally was very confusing.  Finally, after figuring out how to force Javascript to wait for a thread to complete before proceeding, I managed to get something resembling a finished program.
     
    I'm going to go back to work tomorrow, and hopefully finish off this application, then I may be able to post some of the source code, in case anyone was wondering how I managed to get this to work!!