Well, after a long hiatus I'm back, restarting the 'Coding Basic' Project.
The impetus for this was--and is -- a renewed interest in linear algebra, as well as probability. I went to Better World Books (www.betterworldbooks.com), ordered two old 'Structured Basic' texts, and vowed to stick with a program this time.
Two Volumes
The books, Schaum's Outline of Programming with Structured Basic (Byron S. Gottfried) and Applied Structured Basic (Roy Ageloff and Richard Mojena), are of course ancient in computer manual terms. I had the chance to work through a bit of Ageloff and Mojena previously, and it seems to be a more than servicable introduction to not only BASIC, but to the software development process. Gottfried's 'Outline' weighs in at 411 pages -- or just about 4/5 of the size of the full fledged text book-- and is rather newer -- 1993 versus 1985. That early 1990s time frame was just after the big migration to various forms of 'C' had run its course and the outline is one of the most recent books on BASIC out there.
Setting Up
Prior to my new attack, I wanted to set up a rudimentary 'development' environment. Fortunately I already have the actual interpreter, Ron Nicholson's Chipmunk BASIC, on my MacBook. The console of Chipmunk Basic isn't exactly easy on the eyes, so a decided to go with Barebones Software's Textwrangler as my editor. Not only can the appearance of the text be adjusted for font and size with in Textwrangler, but there was potential for some rudimentary syntax highlighting. And indeed a Computer and Information Sciences instructor named John Bussjaeger had developed a BASIC syntax highlighter for Textwrangler, which was linked to by electronics blogger Andrew (http://www.andrewhazelden.com/blog/). So I downloaded the file -- file here-- and put it in the required place on my system (~/Library/Application Support/Textwrangler/Language Modules). Or rather, did so after creating that last 'Language Modules' folder. Sure enough Mr. Bussjaeger's extention (designed specificall for 'uBASIC' worked with Chipmunk BASIC, indeed I was even able to modify the colors of the highlighting by via Textwrangler's preferences menu, the 'Languages' pane.
For the time being, that will be about all there is to me fiddling with my setup , except for one thing I forgot to mention, the Applescript that Chipmunk Basic's creator wrote which enables nearly seemless running of programs written in Textwrangler. I say nearly seemless as it looks like the script doesn't clear the programs memory each time, so that new programs might be run 'on top of' a program currently active in (or loaded to) CB. The work around is to enter 'new' in the console window immediately after a program's run.
An Old Standby
Having my system good to go, I decided to do a little messing around. I wrote out the traditional "Hello World!' one-line program and ran it. Then, for some reason, I thought of doing a Fibonacci series. It's a bit of a challenge, nothing major but does require thinking. Specifically, it involves trying to add the last 2 numbers of a series together to create the next number of the series. Here ls what I came up with.
home
print "What length of Fibonacci series would you like to print --please enter a numeral";
input L
let A=1
let B=2
let C=A+B
print 1, A
print 2, B
print 3, C
for X=4 to L
let D=C+B
print X,D
let B=C
let C=D
next X
end
I think the code above is pretty much the most elegant way to output the series, with four variables being used to store the values necessary to compute the series. 'A' is a stand alone, simply starting off the series. B and C are, after being assigned intital values, the i-1 and i-2 elements 'next to' the current entry, i, in the series which is being computed. My next post will seek to explain this logic, or perhaps technique is a better word, and propose some ways it can be applied more generally.