Re: The Learning Process

Richard Russell

On Tue, Feb 13, 2018 at 01:25 am, <maurice22@...> wrote:
but is quite tedious for the more involved lines.
There are various alternatives, although whether you consider any of them to be less "tedious" is another matter.  Here's one which uses BBC BASIC's array capabilities to advantage:

      DIM colour$(7)
      colour$() = " 0 BLACK"," 1 RED"," 2 GREEN"," 3 YELLOW"," 4 BLUE"," 5 MAGENTA"," 6 CYAN"," 7 WHITE"
      colour$() += CHR$(13) + CHR$(10)
      PRINT SUM(colour$())

Obviously you could initialise the array from DATA statements or a file rather than with explicit strings as above.  You could also use a single string variable rather than an array if you prefer.  There's no right or wrong way, it's just a case of what appeals to your own sense of neatness.


Join to automatically receive all group messages.