Saturday 31 December 2016

Programming Again

A few posts ago I mentioned that I'd resurrected my old website writing skills (Going Solo, 29th November).  The resultant site is, I admit, far from being the greatest on the Worldwide Web but it does its job and I had a lot of fun putting it together.

Like many in my generation, my first foray into computer programming was writing programs in BASIC. To start with, they were simple ones like this conversion table from degrees C to F:

10 for c=0 to 100 step 10
20 print c, (c*1.8)+32
30 next c

I was most fortunate to be working in a development unit where "playing with computers" was accepted as an important part of the job. We had some of the early micro-computers to be imported from the USA, such as these products from Southwest Technical, and a couple of us became so enthusiastic that we often ordered sandwiches from the Head Office canteen and worked on into the evening for no extra pay.  O the joys of not having too many family responsibilities!

My programming skills developed quite rapidly so that, before long, I was able to control items of lab equipment and automatically log the results. I branched out a bit into other programming languages but mainly stuck with derivatives of that original BASIC language, since programs could be developed quite quickly. In our industry, processing speed was never an issue and if I ran out of memory I could always slot in an extra 8k board. Yes, a whole 8k... wow!

Anyway, revenons à nos moutons, that web programming has reminded me that I do enjoy writing programs. So, pining for the old days of my youth, I've decided to learn a modern incarnation of the old BASIC language — Visual Basic.

First step was to buy a good 'teach yourself' book and I settled on this one.  Computer wiz-kids will be quick to point out that Visual Basic 2012 isn't wholly compatible with Windows 10 and that I should have gone for the 2015 version, but that was a lot more expensive and, for the programs I have in mind, I think I can cope with any incompatibility problems. By the way, those "24 hours" are not meant to imply that, if I open the book on Monday morning then by Tuesday morning I'll know it all!  They are 24 one hour lessons, so several weeks of work lie ahead of me.

The next step was to download Visual Basic 2012, free of charge, from Microsoft. To my surprise, what I ended up with was a suite of programs (Visual Studio) that included C++ (with which I have dabbled in the past) and C# that I've not heard of before.

Yesterday evening I opened the book and tackled Lesson One. Here's some of the code that I had written before the clock chimed midnight and I crawled off to bed:

Private Sub btnSelectPicture_Click(sender As Object, e As EventArgs) Handles btnSelectPicture.Click
        ' Show the open file dialog box.
        If ofdSelectPicture.ShowDialog = DialogResult.OK Then
            ' Load the picture into the picture box
            picShowPicture.Image = Image.FromFile(ofdSelectPicture.Filename)
            ' Show the name of the file in the form's caption.
            Me.Text = "Picture Viewer(" & ofdselectpicture.FileName & ")"

        End If
    End Sub

Crumbs, there really isn't much of that old BASIC left, though a few expressions have a familiar ring to them, such as  If... Then... End If. Much of the rest remains gobbledegook to me, but I expect to grow a little wiser with each passing chapter. For this old bird, the thrill of actually making a computer do something is like being young(ish) all over again!



3 comments:

  1. I haven't the mind for this at all. But you clearly have, so good luck with the other 23 lessons!

    Lucy

    ReplyDelete
    Replies
    1. Judging by those fearsomely complex spreadsheets that you produce, Lucy, you may well have latent programming skills.

      IF Lucy had a reason for doing so
      THEN she could surely write programs
      ELSE she would simply continue to entertain us with her blog
      ENDIF

      I'm sure you get the idea! x

      Delete
  2. How I have often pondered what might have been. The Basic programming course I took at university I just considered a gift of an easy 100% score to ease any slippage elsewhere. A brother in law had a loan of a PET machine from the Home Office who had asked his small company to work out what they could do with it! Looked a bit like that picture above and we drove it home strapped into the front seat of his car and it looked a bit like R2D2 driving us home. At the time BIL was often being asked to "improve" the basic games found in machines in places like pubs, once customers had mastered them. They found it easy to make the games more complicated and harder. Sadly both of us drifted away from working on such dumb machines, it seemed that it would be centuries before they would be capable of doing anything useful or interesting. We were dumb...

    ReplyDelete