Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Who here is VERY good at troubleshooting QB programs?
#21
Quote:Well, for one, line 65 and another is line 92. I don't know how to go about fixing it. However I think that's what the error means.
I've been testing Antoni's version. I don't know why you get a subscript out of range on line 65. It works ok for me.

I think you should print a message saying that the numbers entered should have a maiximum value of 52, even though you are not checking this.

The error on line 92 is because he used "X1" to store a value, but X1 is already used in the FOR statement right above. The corrected code using X2 should look like this:
Code:
FOR X1=1 TO 10
   FOR X = 1 TO 10
      x2=ENTRY(1,x)
      x(x2)=x(x2)+1
   NEXT X
NEXT X1

Another possible problem is that at the end of showing the probabilites, it prints the first set as all zeros.

Your original version is huge and has lots of little problems all over the place. I suggest you work on Antoni's version. It's much simpler and compact, and with a little work it should be ok for you.

Please tell us which version you want to work on, so we can continue to try to help you.
*****
Reply
#22
I don't care as long as it works.
Not yet Snake! It's not over yet!
Reply
#23
Quote:I don't care as long as it works.

You're not buying it, you're making it and asking for help.

Decide on the version, yours or Antoni's. I'm not gonna spend any more time debugging the version that you may not decide to use.
*****
Reply
#24
Alright, sorry... Lets go with Antoni's program. I just get frustrated with these programs sometimes.......
Not yet Snake! It's not over yet!
Reply
#25
Ok, great. Apply the change that I posted above, and do some testing. You know what numbers to put in and what the output should be. When you get stuck, let us know.

Where's Antoni when we need him?
*****
Reply
#26
I find that the only numbers that will work without getting a subscript out of range error are numbers 1-10. Anything higher and I get the erorr on line 65.
Not yet Snake! It's not over yet!
Reply
#27
Maybe this is the reason:

PRINT "YOU CAN ENTER UP TO 10 SETS OF NUMBERS."
PRINT "YOU CAN ENTER A MAXIMUM OF 10 NUMBERS PER SET.

*****
Reply
#28
I haven't found any limitations in the coding for the number you enter though.
Not yet Snake! It's not over yet!
Reply
#29
oh wait I see why. The "i" part of the for loop interferes with the "i" value you enter into the program.
Not yet Snake! It's not over yet!
Reply
#30
I fixed that part, but I'm only getting one number ten times for the probability.

Code:
REM Lottery Probability
CLS
REM %=INTEGER
REM array declaration
DEFINT A-Z

DIM ENTRY(1 TO 10, 1 TO 10)
DIM X(1 TO 52)
DIM nth(1 TO 10)
DIM nx(1 TO 52)
FOR I = 1 TO 52: X(I) = 0: NEXT


PRINT "WELCOME TO MY LOTTERY PROBABILITY PROGRAM."
PRINT "THIS PROGRAM WILL BASICALLY TELL YOU WHICH NUMBERS COME UP THE MOST AND LEAST."
PRINT "I HAVE NO IDEA IF YOU'LL WIN OR NOT...IT'S SUPPOSEDLY RANDOM."
PRINT
PRINT "YOU CAN ENTER UP TO 10 SETS OF NUMBERS."
PRINT "YOU CAN ENTER A MAXIMUM OF 10 NUMBERS PER SET. IF THERE ARE LESS"
PRINT "THAN 10 NUMBERS PER SET, JUST USE 0'S FOR THOSE EXTRA SPACES"
PRINT
PRINT
PRINT
PRINT "PRESS ANY KEY TO CONTINUE"
SLEEP 40
PRINT
PRINT "LETS GET STARTED."
PLACE = 0
DO
   IF PLACE = 0 THEN GOSUB HOME
   IF PLACE = 1 THEN GOSUB NUMBERS
   IF PLACE = 2 THEN GOSUB PROB
   IF PLACE = 3 THEN GOSUB SAVE
   IF PLACE = 4 THEN GOSUB LOAD
   IF PLACE = 5 THEN END
LOOP
'
'---------------------------------------------------------------------------------------------------
HOME:
   PRINT
1 PRINT "MAIN"
   PRINT "HERE ARE YOUR CHOICES"
   PRINT "1. START PUTTING IN NUMBERS"
   PRINT "2. SHOW PROBABILITIES"
   PRINT "3. SAVE NUMBERS"
   PRINT "4. LOAD NUMBERS"
   PRINT "5. QUIT"
   DO
      INPUT PLACE
      PLACE = INT(PLACE)
   LOOP UNTIL (PLACE > 0) AND (PLACE < 6)
RETURN
'
'-------------------------------------------------------------------------------------------------------
NUMBERS:
   PRINT
   PRINT "I HAVEN'T REALLY MADE THIS DUMMY PROOF, SO IF YOU MESS UP, YOU'RE IN TROUBLE."
   PRINT "SO REMEMBER...PLACE ZEROES INTO THE EXTRA SPACES. THERE ARE 10 SPACES IN ALL."
   PRINT "AFTER EACH ENTRY PRESS ENTER. AND FOLLOW THE DIRECTIONS!"
    
    
   FOR I = 1 TO 10
      INPUT "ENTER THE NUMBERS FOR THIS FIRST ENTRY, EACH FOLLOWED BY A COMMA, EXCEPT FOR THE LAST ONE"; A, B, C, D, E, F, G, H, S, T
      ENTRY(I, 1) = A
      ENTRY(I, 2) = B
      ENTRY(I, 3) = C
      ENTRY(I, 4) = D
      ENTRY(I, 5) = E
      ENTRY(I, 6) = F
      ENTRY(I, 7) = G
      ENTRY(I, 8) = H
      ENTRY(I, 9) = S
      ENTRY(I, 10) = T
      DO
         INPUT "DO YOU WANT TO STOP?(Y/N)"; DONE$
         IF (DONE$ = "Y") THEN GOTO 1
      LOOP UNTIL DONE$ = "N"
   NEXT I
   PLACE = 0
RETURN
'
'
'-----------------------------------------------------------------------------------------------------------

PROB:
PRINT "GETTING THE PROBABILITY OF THE NUMBERS(MOST COMMON)."
REM ALL ENTRIES
FOR X1 = 1 TO 10
   FOR X = 1 TO 10
      X2 = ENTRY(1, X)
      X(X2) = X(X2) + 1
   NEXT X
NEXT X1
'
'
'
FOR I = 1 TO 10:
  nth(I) = 0
NEXT
PICKED = 0
FOR I = 1 TO 52
   nx(I) = 0:
NEXT

FOR z = 1 TO 10
  
FOR I = 1 TO 24
   IF (PICKED < X(I)) AND (nx(I) = 0) THEN
   PICKED = I: nx(I) = 1
   END IF
NEXT
  
FOR I = 25 TO 52
   IF (PICKED < X(I)) THEN
     flag = 0
     FOR j = 1 TO 10
       IF nth(j) = X(I) THEN flag = 1: EXIT FOR
     NEXT
     IF flag = 0 THEN PICKED = I
    END IF
NEXT
          
nth(z) = PICKED

PRINT z
PRINT PICKED
SLEEP 10
NEXT z
PRINT "YOUR FIRST SET: "; "-";
FOR I = 1 TO 10
  PRINT nth(I); "-";
NEXT
PLACE = 0
RETURN
'
'
'-----------------------------------------------------------------------------------------------------------------
SAVE:
INPUT "ENTER A SMALL FILENAME"; FILENAME$
OPEN FILENAME$ FOR OUTPUT AS #1
FOR I = 1 TO 52
PRINT #1, X(I)
NEXT
CLOSE
PLACE = 0
RETURN
'
'
'------------------------------------------------------------------------------------------------------------------
LOAD:
INPUT "WHAT IS YOUR FILE CALLED?"; FILENAME$
FILENAME$ = FILENAME$ + ".TXT"
OPEN FILENAME$ FOR INPUT AS #1
DO
IF EOF(1) = -1 THEN EXIT DO
FOR I = 1 TO 52
INPUT #1, X(I)
NEXT
LOOP
CLOSE
PLACE = 0
RETURN
Not yet Snake! It's not over yet!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)