* * * * *

           99 ways to program a hex, Part 14: COLOR COMPUTER BASIC

Yesterday's code [1] was labeled “COLOR COMPUTER BASIC, EASY” not because it
was easy to write (it was somewhat easy—seeing how I didn't have to run it,
and going off referenece material for a language I haven't used in over
twenty years) but because it was relatively “easy” to read.

I'm being serious.

I never saw any published BASIC code [2] look that nice. No, it would usually
be presented as this (but probably without the blank lines):

> 1 '*****************************
> 2 '* COPYRIGHT 2012 SEAN CONNER
> 3 '*
> 4 '* THIS PROGRAM RELEASED UNDER
> 5 '* THE GNU LICENSE, VERSION 2
> 6 '* OF THE LICENSE, OR (AT YOUR
> 7 '* OPTION) ANY LATER VERSION.
> 8 '*
> 9 '* SEE THE GNU GENERAL PUBLIC
> 10 '* LICENCE FOR MORE DETAILS.
> 11 '***************************
> 12 '
> 13 'COLOR COMPUTER BASIC
> 14 'REQUIRES EXTENDED AND
> 15 'DOS BASIC TO RUN.
> 16'
> 20 PRINT "INPUT FILE NAME:";:INP
> UT FN$:OPEN"I",#1,FN$:I=0:Y=0:FO
> R S=1TOLOC(2):GET#1,S:D$=INPUT#1
> :FOR B=1TO256STEP8:DD$=MID$(D$,B
> ,16):I$=HEX$(I):IF LEN(I$)<>4 TH
> EN I$ = MID$("000",1,4-LEN(I$))+
> I$
> 21 H$="":A$="":FOR C=1TO8:B$=MID
> $(H$,C,1):IF CHR$(B$)<32 OR CHR$
> (B$)>1THEN B$="."
> 22 A$=A$+B$:T$=HEX$(B$):IF LEN(T
> $)=1THENT$="0"+T$
> 23 H$=H$+T$:NEXT C:PRINTI$;": ";
> H$;" ";A$:I=I+8:Y=Y+1:IF Y=15 TH
> EN INPUT T$:Y=1
> 24 NEXT B:NEXT S:CLOSE#1:END
>

Line 20 here covers lines 20 through 103 of yesterday's code, and I only
broke it there because of the IF statement, which ends at the end of a number
statement. Otherwise, it could have been longer [3], up to 255 characters in
length. All due to memory constraints—4,096 bytes, 16,384 bytes or 32,768
bytes of RAM (Random Access Memory) to fit both the program and data (and if
you want high resolution graphics, you give up 6,144 bytes; 12,288 bytes if
you want double-buffered high resolution graphics—and by “high resolution
graphics” I mean 256×192 pixels, two colors).

Yes kids, this is how we used to write programs. And part of the reason why
BASIC has the terrible reputation [4] that it does.

* Part 13: COLOR COMPUTER BASIC,EASY [5]
* Part 15: Lua [6]

[1] gopher://gopher.conman.org/0Phlog:2012/01/21.1
[2] http://www.archive.org/details/rainbowmagazine
[3] gopher://gopher.conman.org/0Phlog:2008/01/04.1
[4] http://www.brainyquote.com/quotes/quotes/e/edsgerdijk201164.html
[5] gopher://gopher.conman.org/0Phlog:2012/01/21.1
[6] gopher://gopher.conman.org/0Phlog:2012/01/23.2

Email author at [email protected]