Author Topic: Mega sena database  (Read 16366 times)

0 Members and 1 Guest are viewing this topic.

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mega sena database
« Reply #15 on: March 29, 2019, 06:27:00 pm »
bplus, please, please, tell me what comes before .... dot
OPEN "temp.txt" FOR INPUT AS # 1
.... stuff

SEEK # 1, (RecordNumber - 1) * 19 + 1
FOR i = 1 TO 6
      INPUT Ball (i)
NEXT
CLOSE
Thank you very much for your help, and for SMcNeill.
CarlosCordeiro.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Mega sena database
« Reply #16 on: March 29, 2019, 07:03:13 pm »
bplus, please, please, tell me what comes before .... dot
OPEN "temp.txt" FOR INPUT AS # 1
.... stuff

SEEK # 1, (RecordNumber - 1) * 19 + 1
FOR i = 1 TO 6
      INPUT Ball (i)
NEXT
CLOSE
Thank you very much for your help, and for SMcNeill.
CarlosCordeiro.


The ...stuff was there so you could insert whatever you needed into your code to work with the values on hand.

For a working illustration of how to handle the text file using SEEK and INPUT, here's an example for you:

Code: QB64: [Select]
  1.  
  2.  
  3. OPEN "temp.txt" FOR INPUT AS #1
  4.  
  5. 'A demo of just listing all the numbers/combinations for us
  6. FOR recordnumber = 1 TO 50063830
  7.     SEEK #1, (recordnumber - 1) * 19 + 1
  8.     LINE INPUT #1, t$
  9.     PRINT "RECORD"; recordnumber; ":"; t$
  10.     IF INKEY$ <> "" THEN EXIT FOR 'Escape to quit
  11.  
  12.  
  13. 'And a demo of how to get one particular value from the list:
  14.     PRINT
  15.     PRINT
  16.     DO
  17.         INPUT "Give me a record number from 1 to 50063830 (0 quits):"; recordnumber
  18.         IF recordnumber = 0 GOTO OutsideLoop
  19.     LOOP UNTIL recordnumber > 0 AND recordnumber < 50063831
  20.     SEEK #1, (recordnumber - 1) * 19 + 1
  21.     LINE INPUT #1, t$
  22.     PRINT "RECORD"; recordnumber; ":"; t$
  23.  
  24. 'And a demo of randomly generating values using our list:
  25. OutsideLoop:
  26. FOR i = 1 TO 10
  27.     recordnumber = INT(RND * 50063830) + 1
  28.     SEEK #1, (recordnumber - 1) * 19 + 1
  29.     LINE INPUT #1, t$
  30.     PRINT "Random Drawing #"; i; ": "; t$

Note: You'll need the temp.txt file which was generated previously to run this demo.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #17 on: March 29, 2019, 07:22:41 pm »
bplus, please, please, tell me what comes before .... dot
OPEN "temp.txt" FOR INPUT AS # 1
.... stuff

SEEK # 1, (RecordNumber - 1) * 19 + 1
FOR i = 1 TO 6
      INPUT Ball (i)
NEXT
CLOSE
Thank you very much for your help, and for SMcNeill.
CarlosCordeiro.

Hi CarlosCordeiro.

Yes I was hoping Steve would fill in about the "... stuff".   Thanks Steve

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mega sena database
« Reply #18 on: March 29, 2019, 07:25:22 pm »
Great!!! Many thanks SMcNeill, you're a genius.
A great evening.
CarlosCordeiro
Excelente.jpg
* Excelente.jpg (Filesize: 303.41 KB, Dimensions: 1037x1003, Views: 394)
Excelente.jpg
* Excelente.jpg (Filesize: 303.41 KB, Dimensions: 1037x1003, Views: 302)

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mega sena database
« Reply #19 on: April 02, 2019, 08:33:10 pm »
Good night, Steve.
Not wanting to be Inconvenient, could you exemplify how do I end part of the sequence and start over again where She stopped? Let's say I want to populate the temp.txt file with Intervals without it losing its order.
I mean, insert 1 million today, then 2 million more, until you reach 50 million.
It is very important to me.
Appreciate.

PRINT "Calculating..."
OPEN "temp.txt" FOR OUTPUT AS #1
FOR num1 = 1 TO 55
    LOCATE 5, 3: PRINT num1,
    FOR num2 = num1 + 1 TO 56
        LOCATE 5, 5: PRINT num2,
        FOR num3 = num2 + 1 TO 57
            LOCATE 5, 7: PRINT num3,
            FOR num4 = num3 + 1 TO 58
                LOCATE 5, 9: PRINT num4,
                FOR num5 = num4 + 1 TO 59
                    LOCATE 5, 11: PRINT num5,
                    FOR num6 = num5 + 1 TO 60
                        LOCATE 5, 13: PRINT num6
                        s$ = LTRIM$(STR$(num1)) + ","
                        IF num1 < 10 THEN s$ = "0" + s$
                        IF num2 < 10 THEN s$ = s$ + "0"
                        s$ = s$ + LTRIM$(STR$(num2)) + ","
                        IF num3 < 10 THEN s$ = s$ + "0"
                        s$ = s$ + LTRIM$(STR$(num3)) + ","
                        IF num4 < 10 THEN s$ = s$ + "0"
                        s$ = s$ + LTRIM$(STR$(num4)) + ","
                        IF num5 < 10 THEN s$ = s$ + "0"
                        s$ = s$ + LTRIM$(STR$(num5)) + ","
                        IF num6 < 10 THEN s$ = s$ + "0"
                        s$ = s$ + LTRIM$(STR$(num6))
                        PRINT #1, s$
                    NEXT
                NEXT
            NEXT
        NEXT
    NEXT
NEXT


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #20 on: April 03, 2019, 09:53:15 am »
Good night, Steve.
Not wanting to be Inconvenient, could you exemplify how do I end part of the sequence and start over again where She stopped? Let's say I want to populate the temp.txt file with Intervals without it losing its order.
I mean, insert 1 million today, then 2 million more, until you reach 50 million.
It is very important to me.
Appreciate.

PRINT "Calculating..."
OPEN "temp.txt" FOR OUTPUT AS #1
FOR num1 = 1 TO 55
    LOCATE 5, 3: PRINT num1,
    FOR num2 = num1 + 1 TO 56
        LOCATE 5, 5: PRINT num2,
        FOR num3 = num2 + 1 TO 57
            LOCATE 5, 7: PRINT num3,
            FOR num4 = num3 + 1 TO 58
                LOCATE 5, 9: PRINT num4,
                FOR num5 = num4 + 1 TO 59
                    LOCATE 5, 11: PRINT num5,
                    FOR num6 = num5 + 1 TO 60
                        LOCATE 5, 13: PRINT num6
                        s$ = LTRIM$(STR$(num1)) + ","
                        IF num1 < 10 THEN s$ = "0" + s$
                        IF num2 < 10 THEN s$ = s$ + "0"
                        s$ = s$ + LTRIM$(STR$(num2)) + ","
                        IF num3 < 10 THEN s$ = s$ + "0"
                        s$ = s$ + LTRIM$(STR$(num3)) + ","
                        IF num4 < 10 THEN s$ = s$ + "0"
                        s$ = s$ + LTRIM$(STR$(num4)) + ","
                        IF num5 < 10 THEN s$ = s$ + "0"
                        s$ = s$ + LTRIM$(STR$(num5)) + ","
                        IF num6 < 10 THEN s$ = s$ + "0"
                        s$ = s$ + LTRIM$(STR$(num6))
                        PRINT #1, s$
                    NEXT
                NEXT
            NEXT
        NEXT
    NEXT
NEXT

Hi carloscordeiro,

I see your question addressed to Steve, but Steve not answering (yet). So I will try to assist.

You can create more files or applications based on using the file created from code above as a source of data.
For example create a file with first million, then create a file with 2nd million and so on... or just load an array with a million items randomly selected or in blocks and do what you want with it.

Steve gave you the code, keys to accessing that file's data, for whatever purpose you might use that data for (see reply #16).
« Last Edit: April 03, 2019, 10:29:24 am by bplus »

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mega sena database
« Reply #21 on: April 03, 2019, 08:12:44 pm »
Good evening, bplus

Thanks for answering for Steve.
I want to create a single temp.txt file, which I support inserting every million in intervals. For example, I enter 1 million today, another 2 million tomorrow until I get 50 million in the same temp.txt file.

CarlosCordeiro

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: Mega sena database
« Reply #22 on: April 03, 2019, 09:26:22 pm »
the way I understand it, you want to write 1 million lotto numbers to a text file and then suspend the operation, then the next days resume where you left off and add another million numbers a day until finished, is that right?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #23 on: April 03, 2019, 09:42:07 pm »
That's the way I read it too Jack.

Do you think this will do that?
Code: QB64: [Select]
  1.  
  2. INPUT "Enter which million we are appending today ", millions 'day 1 say 1, day 2 say 2...
  3.  
  4. PRINT "Calculating..."
  5. OPEN "temp.txt" FOR APPEND AS #1
  6. FOR num1 = 1 TO 55
  7.     LOCATE 5, 3: PRINT num1,
  8.     FOR num2 = num1 + 1 TO 56
  9.         LOCATE 5, 5: PRINT num2,
  10.         FOR num3 = num2 + 1 TO 57
  11.             LOCATE 5, 7: PRINT num3,
  12.             FOR num4 = num3 + 1 TO 58
  13.                 LOCATE 5, 9: PRINT num4,
  14.                 FOR num5 = num4 + 1 TO 59
  15.                     LOCATE 5, 11: PRINT num5,
  16.                     FOR num6 = num5 + 1 TO 60
  17.                         LOCATE 5, 13: PRINT num6
  18.                         s$ = LTRIM$(STR$(num1)) + ","
  19.                         IF num1 < 10 THEN s$ = "0" + s$
  20.                         IF num2 < 10 THEN s$ = s$ + "0"
  21.                         s$ = s$ + LTRIM$(STR$(num2)) + ","
  22.                         IF num3 < 10 THEN s$ = s$ + "0"
  23.                         s$ = s$ + LTRIM$(STR$(num3)) + ","
  24.                         IF num4 < 10 THEN s$ = s$ + "0"
  25.                         s$ = s$ + LTRIM$(STR$(num4)) + ","
  26.                         IF num5 < 10 THEN s$ = s$ + "0"
  27.                         s$ = s$ + LTRIM$(STR$(num5)) + ","
  28.                         IF num6 < 10 THEN s$ = s$ + "0"
  29.                         s$ = s$ + LTRIM$(STR$(num6))
  30.                         count = count + 1
  31.                         IF count >= (millions - 1) * 10 ^ 6 + 1 AND count < millions * 10 ^ 6 + 1 THEN
  32.                             PRINT #1, s$
  33.                         END IF
  34.                         IF count >= millions * 10 ^ 6 + 1 THEN CLOSE #1: END
  35.                     NEXT
  36.                 NEXT
  37.             NEXT
  38.         NEXT
  39.     NEXT
  40.  
  41.  

Edit: I was off by 1 when I tested by 10's, fixed.
« Last Edit: April 03, 2019, 09:54:42 pm by bplus »

FellippeHeitor

  • Guest
Re: Mega sena database
« Reply #24 on: April 03, 2019, 09:50:55 pm »
I have nothing to do with this, but why again?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #25 on: April 03, 2019, 10:02:25 pm »
I have nothing to do with this, but why again?

;-))

I have the 2nd day ending with

01,07,16,42,44,46

the 2 millionth entry

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mega sena database
« Reply #26 on: April 03, 2019, 10:22:01 pm »
Thank you very much, that's exactly what I want Jack. Write 1 million lottery numbers in a text file and then suspend the operation, so the next few days pick up where you left off and add another million numbers a day until you finish.

Thanks again to bplus. The code resumes where it stopped, but does not continue to count 1 million, it returns to the beginning.
CarlosCordeiro
Por partes.jpg
* Por partes.jpg (Filesize: 165.46 KB, Dimensions: 705x999, Views: 287)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #27 on: April 03, 2019, 10:37:04 pm »
Thank you very much, that's exactly what I want Jack. Write 1 million lottery numbers in a text file and then suspend the operation, so the next few days pick up where you left off and add another million numbers a day until you finish.

Thanks again to bplus. The code resumes where it stopped, but does not continue to count 1 million, it returns to the beginning.
CarlosCordeiro

On day 2 enter 2 not 1, here is my transition:
day 2.PNG


Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mega sena database
« Reply #28 on: April 03, 2019, 11:10:29 pm »
Bplus, on day 2 it will resume the sequence of 1,2,3,4,5,6. If the code could start from 01,04,13,23,30,59. So there would be no need to go back to the beginning. My intention would be this.
I'm sorry if I'm getting inconvenient

CarlosCordeiro

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #29 on: April 03, 2019, 11:19:31 pm »
Bplus, on day 2 it will resume the sequence of 1,2,3,4,5,6. If the code could start from 01,04,13,23,30,59. So there would be no need to go back to the beginning. My intention would be this.
I'm sorry if I'm getting inconvenient

CarlosCordeiro

Start Over!

Erase temp.txt

day 1 enter 1 at this prompt
INPUT "Enter which million we are appending today ", millions 'day 1 say 1, day 2 say 2...

day 2 enter 2 at this prompt
INPUT "Enter which million we are appending today ", millions 'day 1 say 1, day 2 say 2...

then all will work. :)

If you mess up, the code will just keep adding the new section onto the old reguardless if it is where you wanted it or not.
The code is NOT rewriting the file but only adding on to the end of it.

BTW the code has been fixed, because it was 1 off of a million, use the current code in my last code listing posted in this thread, Reply #23.
« Last Edit: April 03, 2019, 11:23:18 pm by bplus »