Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
psf
@psf@oldbytes.space  ·  activity timestamp last week

Looking at Line 5-10 of this #Basic Star Trek listing confused the heck out of me. This listing was written by Li-Chen Wang for use in his own #TinyBasic.

https://archive.org/details/1976-07-peoples-computer-company/page/22/mode/2up?view=theater

Here is the confusing part, expanded out to multiple lines and modern syntax for the benefit of today's readers.

Y=2999
INPUT "DO YOU WANT A DIFFICULT GAME? (Y OR N)",A
IF A=Y THEN Y=999

Without support for string input, how the heck can the program accept "Y or N" from the user?

Answer: In this dialect, INPUT accepts not just numbers, but expressions. Single characters (A-Z) are valid expressions and evaluate to the value in that variable. So in this program, typing "Y" sets A=2999 and typing "N" sets A=N (some uninitialized value). Then the next line checks A=Y (true if user entered "Y") and, if so, sets Y to 999 ("difficult game" value). Else, Y is left at 2999 ("easy game" value).

Li-Chen is absolutely some kind of genius.

#retrocomputing

  • Copy link
  • Flag this post
  • Block
psf
@psf@oldbytes.space replied  ·  activity timestamp last week

Looking at Line 5-10 of this #Basic Star Trek listing confused the heck out of me. This listing was written by Li-Chen Wang for use in his own #TinyBasic.

https://archive.org/details/1976-07-peoples-computer-company/page/22/mode/2up?view=theater

Here is the confusing part, expanded out to multiple lines and modern syntax for the benefit of today's readers.

Y=2999
INPUT "DO YOU WANT A DIFFICULT GAME? (Y OR N)",A
IF A=Y THEN Y=999

Without support for string input, how the heck can the program accept "Y or N" from the user?

Answer: In this dialect, INPUT accepts not just numbers, but expressions. Single characters (A-Z) are valid expressions and evaluate to the value in that variable. So in this program, typing "Y" sets A=2999 and typing "N" sets A=N (some uninitialized value). Then the next line checks A=Y (true if user entered "Y") and, if so, sets Y to 999 ("difficult game" value). Else, Y is left at 2999 ("easy game" value).

Li-Chen is absolutely some kind of genius.

#retrocomputing

  • Copy link
  • Flag this comment
  • Block
psf
@psf@oldbytes.space replied  ·  activity timestamp last week

The funniest part here is that the magazine editors also got confused by this in 1976. "Hey, for this program to work, this #BASIC must have a 1-character mini string type!" No, no strings, the author just knows his language and is squeezing every ounce of expressiveness out of it.

A talk-bubble captioned "1 character mini-strings" points at the right edge of the line,
5. Y=2999;IN."DO YOU WANT A DIFFICULT GAME?  ","(Y OR N)"A
A talk-bubble captioned "1 character mini-strings" points at the right edge of the line, 5. Y=2999;IN."DO YOU WANT A DIFFICULT GAME? ","(Y OR N)"A
A talk-bubble captioned "1 character mini-strings" points at the right edge of the line, 5. Y=2999;IN."DO YOU WANT A DIFFICULT GAME? ","(Y OR N)"A
  • Copy link
  • Flag this comment
  • Block
psf
@psf@oldbytes.space replied  ·  activity timestamp last week

Forgot to thread this: https://oldbytes.space/@psf/115285802359299755

  • Copy link
  • Flag this comment
  • Block
psf
@psf@oldbytes.space replied  ·  activity timestamp 7 days ago

#MailStation #TinyBasic program of the day: Hangman!

I wanted something that would exercise my hacked-in "strings" support. Seems to work well enough for a word game!

Source listing (21 lines): https://gitlab.cs.washington.edu/fidelp/mailstation_apps/-/blob/master/basic/hangman.bas

#basic #retrocomputing

WRONGS: 0, WORD: _____
WRONGS: 0, WORD: _A___
WRONGS: 0, WORD: _A__E
WRONGS: 1, WORD: _A__E
WRONGS: 2, WORD: _A__E
WRONGS: 2, WORD: _AU_E
WRONGS: 0, WORD: _____ WRONGS: 0, WORD: _A___ WRONGS: 0, WORD: _A__E WRONGS: 1, WORD: _A__E WRONGS: 2, WORD: _A__E WRONGS: 2, WORD: _AU_E
WRONGS: 0, WORD: _____ WRONGS: 0, WORD: _A___ WRONGS: 0, WORD: _A__E WRONGS: 1, WORD: _A__E WRONGS: 2, WORD: _A__E WRONGS: 2, WORD: _AU_E
  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.3.1 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login