stringBug

Description of the page content

Demo of a Beta BASIC's bug, for Sinclair ZX Spectrum.

Tags:

While writing the program Alien-B in Beta BASIC 4.0+D, I discovered a bug in the language: The STRING$ function sometimes doesn't work fine if nested. In order to show it, I wrote this little program.

Screenshot

The program shows what the results of some calculations should be, and what they actually are. It shows their code too.

Rezulto

Source code

  10 REM stringBug
  20 REM A demo of a Beta BASIC 4.0+D's bug, found out by the author
  30 REM By Marcos Cruz (programandala.net)

  40 REM 2010-11-23 First version
  50 REM 2011-02-03 Some little changes in the code

  60 RANDOMIZE USR 58419
     REM Beta BASIC on
  70 WINDOW 0
     PAPER 0
     BORDER 0
     INK 1
     CSIZE 8,7
     CLS
  80 PRINT "Bug in Beta BASIC 4.0+D:"'"sometimes nested STRING$ doesn't"'"work fine."'
  90 PRINT INVERSE 1'"Should be","Result"
 100 PRINT 300,LEN STRING$(10,"012345678901234567890123456789")
 110 PRINT 300,LEN STRING$(10,STRING$(10,"abc"));" (nested)"
 120 PRINT 448,LEN STRING$(14,"123456789_123456789_123456789_12")
 130 PRINT 448,LEN STRING$(14,(CHAR$(0)+STRING$(28,"a")+CHAR$(0)));" (nested)"
 140 PRINT 392,LEN STRING$(28,"123456789_1234")
 150 PRINT 392,LEN STRING$(28,STRING$(14,"a"));" (nested)"
 160 PRINT 392,LEN STRING$(14,STRING$(28,"a"));" (nested)"
 170 PRINT 10,LEN STRING$(5,STRING$(2,"A"));" (nested)"
 180 PRINT 10,LEN STRING$(2,STRING$(5,"A"));" (nested)"
 190 CSIZE 4,7
     PRINT
     LIST 100 TO 170
 200 CSIZE 8
     PAUSE 0
     STOP

 210 DEF PROC s
 220   ERASE d*"stringBug~"
 230   ERASE d*"stringBug" TO "stringBug~"
 240   SAVE d*"stringBug" LINE 10
 250 END PROC

Downloads

The +D disk images contain, beside the program stringBug, the following:

The Autoload program loads both Beta BASIC and the program stringBug.

Related pages

OverBug
Tool used to check a Beta DOS's bug in Beta BASIC, with the Sinclair ZX Spectrum.
bb4d-fixer
A fixer for some Beta BASIC 4.0+D bugs.