Ok I apologize for the rather simple idea, but any how: I am following the book Hands on DarkBASIC professional, and I am currently on Activity 12.8, which gets you to type in the program given to create a simple dice calculation.
What it does it creates a single cell array, in a type holding dice1,dice2,dice3 records, then gives each record a random number from 1-6. If all three dices = 6 then the program displays all the dice rolls (Breaking every 31st). This is following code I wrote:
`*** Define the type for dice ***
TYPE ThrowType
dice1 AS BYTE
dice2 AS BYTE
dice3 AS BYTE
ENDTYPE
`*** Randomize the timer ***
RANDOMIZE TIMER()
`*** Set up the array to hold the throws ***
DIM throws(1) AS ThrowType
`*** Define the variable to count how many throws ***
thrownumber = 0
`*** Roll the dice ***
REPEAT
throws(thrownumber).dice1 = RND(5) + 1
throws(thrownumber).dice2 = RND(5) + 1
throws(thrownumber).dice3 = RND(5) + 1
PRINT throws(thrownumber).dice1,throws(thrownumber).dice2,throws(thrownumber).dice3;
SET CURSOR 50,50
thrownumber = thrownumber + 1
SET TEXT OPAQUE
PRINT " "
`*** Insert the new cell of the array ***
ARRAY INSERT AT BOTTOM throws(0)
UNTIL throws(thrownumber).dice1 + throws(thrownumber).dice2 + throws(thrownumber).dice3 = 18
`*** Print the dice rolls ***
FOR c = 0 TO thrownumber-1
PRINT c, " ",throws(c).dice1," ",throws(c).dice2," ",throws(c).dice3
`*** Stop every 31 throws so they dont go of screen ***
IF c mod 31 = 0
WAIT KEY
ENDIF
NEXT c
WAIT KEY
END
And I cant for the love of god get it to work! The problem is, it is just not stopping and displaying the results after the dice all get sixes. Now I have added an extra part to show the dice numbers each "Repeat". It is odd because even when I change it to show the rolls after one six on the first die, or two sixes on the first two dice, which I see on the screen come up, it does not show the results. Instead just continues to generate random dice rolls.
I am absolutely stumped, and despite it being a minor program that I could perhaps skip, I am worried if there might be a problem with my DarkBASIC Pro (Which is V7.4)
Help would greatly be appreciated! I hope it is just a stupid error but comparing with the solution this does not appear to be the case.
Zarok