BASIC Programs from Sky & Telescope PDF Print E-mail
Sunday, 30 March 2008

I first became interested in computer programming about thirty years ago when a fellow solider first showed me his programmable calculator that he had purchased for only thirty dollars at the base PX. I was so fascinated by this clever contraption that I promptly went out the next day and bought myself one. I still have the TI-55 calculator that I bought in 1979, but the power adapter stopped working many years ago.

A few years later I purchased my first computer - a TI-99 4/A - and with that I first started to teach myself to program using the the BASIC programming language. Over the years that followed I progressed to learning several programming languages - QuickBasic, Visual Basic, C, C++, Java, JavaScript, VB.NET, and C# - not necessarily in that order. Today I do most of my professional work in either VB.NET or C#.

I have always found that best way to learn a programming language is to actually do something with the language. In other words to write an actual program that I or someone else might actually use. When I first started learning to program I was interested in learning how to write programs that could do complex computations for determining rather mundane things such as calculating the times of sunrise and sunset.

Many years ago magazines such as Compute! and Sky & Telescope would publish whole programs or snippets of programs usually written in some variation of the popular BASIC language. Some these oldie-but-goodies can be found at BASIC Programs from Sky & Telescope.

Sky & Telescope magazine is pleased to make available in machine-readable form the programs that have been published in its monthly Astronomical Computing department, which first appeared in April 1984, and later in the Computers in Astronomy department. These are offered as-is and without support.

This is great that S&T has made these little programs available on-line. There is however one little problem for most modern computer users. These programs are written in a rather archaic form of BASIC that can't be easily run on the later versions of Windows - the reason being is that Microsoft stop shipping the BASICA and QuickBasic interpreters with Windows about ten years ago.

I downloaded a couple of the S&T BASIC source codes just to see what I could do with them. One was called SUNUP.BAS - which computes the times of sunrise/set at any place on Earth. I then ported this over to Visual Basic and then to VB.NET by not so much re-writing the code, but rather restructuring the code to take into account that VB and VB.NET do not use line numbers and GOSUBs. The result, a VB.NET class for calculating  sunrise and sunset which can be downloaded here (sunup.zip), seems to have some problems... Given a date (Y M D) a location (longitude and latitude) and a time zone, it does compute the sunrise correctly, but the sunset time appears to off by about six or seven minutes. The original S&T BASIC code was spaghetti code to begin with (which is what most BASIC suffer from by nature of the language), and though I think that I straighten out most of the strands of spaghetti I can't seem to figure out where the problem is with returning the correct time for sunset.

I also found in a July 1989 issue of Sky & Telescope a BASIC program for computing the Moon rise and set times. This program is not one that is listed at the link above, but here is my interpretation - a VB.NET class for calculating  moonrise and moonset which can be downloaded here (moonup.zip).

Last Updated ( Sunday, 19 October 2008 )