Length of random sequence in Locomotive Basic (1986)

I am learning BASIC and working now in GEM Locomotive BASIC (1986) on '86 Amstrad PC1512DD (8MHz, 512 ram, 5.25" 360 kb floppies) I am randomly generating numbers in a range with a program that prints numbers in loop as


First, it prints a number, then adds a randomly generated value. This continues until it reaches a maximum value, then the program stops.

What I would like to do is to count up the number of outputs once the program stops at the end, not to add numbers.

For example, if line has numbers

20   100    1500    125

That should count as 4, as each is separate value rather than sum them as 1745. This is just an example, and I may have thousands of outputs.

Maybe to treat that numbers convert to strings then to count up string somehow? Any help will be much appreciated please.


  • Not easy to verify this but after tracking down an Amstrad 486 CPC emulator, I was able to verify this works.

    # variable  description
    # NUM       The value of the current number being incremented
    # NUMCOUNT  The total number of time the value has been incremented
    # MAXNUM    The maximum value of the sequence
    # MAXGAP    The largest possible value to randomly add to the NUM
    100 NUM = 1
    150 NUMCOUNT = 0
    200 INPUT"
    Max Number";MAXNUM
    300 INPUT"
    Max Gap";MAXGAP
    600 IF NUM > MAXNUM THEN 800
    700 GOTO 400