Re: [OT] Commodore 64 BASIC
Old Wolf <oldwolf@inspir e.net.nz> scribbled the following:[color=blue]
> Joona I Palaste <palaste@cc.hel sinki.fi> wrote:[color=green][color=darkred]
>> >> Right on the money, Dan. I started programming on C=64 BASIC V2, which
>> >> is an extremely cut-down version of BASIC by 1980s standards. Back then
>> >> GOTO with a symbolic label rather than a hard-coded line number as the
>> >> destination was like science fiction...[/color]
>>
>> Yes, but what were you going to do about it? C-64 Basic v2 had pretty
>> much the bare minimum of control structures. IF... THEN was only for
>> single lines, not blocks of lines, and there was no ELSE. The only loop
>> available was FOR... NEXT. Every other kind of loop had to be simulated
>> with IF... THEN GOTO. And like I said, GOTOs had to have hard-coded line
>> numbers as destinations. There was GOSUB... RETURN which I think could
>> be used to have "poor man's subroutines", because they behaved
>> otherwise like subroutines but had no concept of local variable scope.[/color][/color]
[color=blue]
> Don't forget the BASIC equivalent of "switch":[/color]
[color=blue]
> 240 GOTO 250*(i=0) + 350*(i=1) + 380*(i=2) + .... + 3530*(i=51)[/color]
[color=blue]
> (this came from an adventure game where there were 50 or so possible
> user actions, each having its own handling "function") .
> Luckily my micro's version of BASIC included the feature of expressions
> evaluating to either 1 or 0 (pretty advanced for those days); the other
> micros had to do something more complicated.
> I'm sure these program listings had to be generated by someone working
> in a real environment with some tool that outputs micro-suitable
> BASIC code, in real life it would take forever to re-number a program
> and the programs were usually perfectly-numbered.[/color]
On a Commodore 64, that GOTO statement will cause an "undef'd
statement" error if the variable i has any value from 0 to 51. This is
because unlike your micro's BASIC, the Commodore 64 BASIC evaluates
true expressions to -1, and thus if i has some value from 0 to 51,
the above GOTO will attempt to jump to a negative line number. It
should read:
240 GOTO -250*(i=0) - 350*(i=1) - 380*(i=2) - ... - 3550*(i=51)
--
/-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I wish someone we knew would die so we could leave them flowers."
- A 6-year-old girl, upon seeing flowers in a cemetery
Old Wolf <oldwolf@inspir e.net.nz> scribbled the following:[color=blue]
> Joona I Palaste <palaste@cc.hel sinki.fi> wrote:[color=green][color=darkred]
>> >> Right on the money, Dan. I started programming on C=64 BASIC V2, which
>> >> is an extremely cut-down version of BASIC by 1980s standards. Back then
>> >> GOTO with a symbolic label rather than a hard-coded line number as the
>> >> destination was like science fiction...[/color]
>>
>> Yes, but what were you going to do about it? C-64 Basic v2 had pretty
>> much the bare minimum of control structures. IF... THEN was only for
>> single lines, not blocks of lines, and there was no ELSE. The only loop
>> available was FOR... NEXT. Every other kind of loop had to be simulated
>> with IF... THEN GOTO. And like I said, GOTOs had to have hard-coded line
>> numbers as destinations. There was GOSUB... RETURN which I think could
>> be used to have "poor man's subroutines", because they behaved
>> otherwise like subroutines but had no concept of local variable scope.[/color][/color]
[color=blue]
> Don't forget the BASIC equivalent of "switch":[/color]
[color=blue]
> 240 GOTO 250*(i=0) + 350*(i=1) + 380*(i=2) + .... + 3530*(i=51)[/color]
[color=blue]
> (this came from an adventure game where there were 50 or so possible
> user actions, each having its own handling "function") .
> Luckily my micro's version of BASIC included the feature of expressions
> evaluating to either 1 or 0 (pretty advanced for those days); the other
> micros had to do something more complicated.
> I'm sure these program listings had to be generated by someone working
> in a real environment with some tool that outputs micro-suitable
> BASIC code, in real life it would take forever to re-number a program
> and the programs were usually perfectly-numbered.[/color]
On a Commodore 64, that GOTO statement will cause an "undef'd
statement" error if the variable i has any value from 0 to 51. This is
because unlike your micro's BASIC, the Commodore 64 BASIC evaluates
true expressions to -1, and thus if i has some value from 0 to 51,
the above GOTO will attempt to jump to a negative line number. It
should read:
240 GOTO -250*(i=0) - 350*(i=1) - 380*(i=2) - ... - 3550*(i=51)
--
/-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I wish someone we knew would die so we could leave them flowers."
- A 6-year-old girl, upon seeing flowers in a cemetery
Comment