Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Who here is VERY good at troubleshooting QB programs?
#41
Quote:
Liquid Snake Wrote:alright, well for me it won't allow me to input any number greater than 10 at the point where you enter the 10 numbers. I don't know why it works for you. Maybe it's the version of QB....I don't know.
I can't help but think it's got something to do with your index variable, I, conflicting with the I in your input statement. Change your index variable to Z, or better, index......
Thanks stylin, that's got to be it! Yeah, change the index variable, or easier yet, change the "I" in the input list to something else and the reference to it also.

I just noticed that the version that I downloaded for testing has A,B,C,D,E,F,G,H,S,T. That's why it worked. You must have changed it to ....H,I,J later and inadvertently clobbered the "I" index.

Great! We're moving right along.
*****
Reply
#42
OK, I changed it but have the same result. Do you think it could be because of this line towards the top?


Code:
DEFINT A-Z
Not yet Snake! It's not over yet!
Reply
#43
Quote:OK, I changed it but have the same result. Do you think it could be because of this line towards the top?
Code:
DEFINT A-Z
No, all that does is set the default for all variable to INTEGER instead of SINGLE. This should not have any effect on the code as I see it.

Post the code that you just corrected. Better still, post the latest version of the entire program again.
*****
Reply
#44
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 100
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
#45
Quote:OK, I changed it but have the same result .....
Using your latest posted version, I ran a test entering numbers from 11 to 20.
At the end of the numbers subroutine I added some code to print out the 10 numbers input.
It prints the numbers 11 to 20 fine, so it is inputting them correctly.

Tell me what kind of error you're getting.

BTW, while looking at the PROB: subroutine, I noticed the following potential problems:
1) If the user enters a number greater than 52,
then the instruction X(X2)=X(X2)+1 will hang up because X is an array DIMed as (1 to 52). You need to check the number. You'll probably need to re-write the input logic.

2) In your instructions to the user you say to place zeros in the extra spaces. This also will hang on the same instruction because zero is not within 1 to 52. You need to put an "if" here to skip the zero values.
*****
Reply
#46
In my original program the zero thing would have worked. You need to be able to put something into the spaces that aren't used, that's why I came up with the zero idea since the lottery numbers range from 1-52. But, yeah I'll put an IF in there once this programs works.

I don't know why I get the error, but I do. I just tried it again.
Not yet Snake! It's not over yet!
Reply
#47
Quote:.....
I don't know why I get the error, but I do. I just tried it again.
I'm not sure anymore what "the error" is that you're getting. Tell me exactly what numbers you input and how you are determining "the error" and what it is.
*****
Reply
#48
Sorry, I must have screwed up somehow, I'm now getting the input in correctly too. The problem, if you test it out, is that after you put in the numbers and you select "find probabilities" it only gives you 1 number. It should give you 10 different numbers.
Not yet Snake! It's not over yet!
Reply
#49
Ok, I took a look at the following from the PROB subroutine:
Code:
FOR X1 = 1 TO 10
   FOR X = 1 TO 10
      X2 = ENTRY(1, X)
      X(X2) = X(X2) + 1
   NEXT X
NEXT X1
It loops on the value X1, but it never uses it. I don't understand what it's doing but maybe the line X2=ENTRY(1,X)
should be X2=ENTRY(X1,X).
What do you think?
*****
Reply
#50
Well, I tried it but all I get is a "subscript out of range error" I also noticed that the number that it shows for the probability is always the same.....10. One of the for loops must be messing the variables up.
Not yet Snake! It's not over yet!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)