Author Topic: help my  (Read 42355 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: help my
« Reply #105 on: July 16, 2020, 02:56:37 pm »
OK does anybody have a function to convert a lotto number to a day and date?

Hint: Lotto Days are Tues, Thurs, Sat and I assume they don't stop for anything
1465 > = Tues, June 6, 2017
1466 > = Thurs, June 8, 2017
1467 > = Sat, June 10, 2017
...

🤷‍♂️

Wouldn’t you basically run it through a timestamp type function?

1 = start date
2 = start date + 2
3 = start date + 4
4 = start date + 7
5 = start date + 9
6 = start date + 11

((Number - 1) \ 3) * 7 + ((Number - 1) MOD 3) * 2

Take your start date and then increment by the above number of days.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
Re: help my
« Reply #106 on: July 16, 2020, 03:44:13 pm »
OK does anybody have a function to convert a lotto number to a day and date?

Hint: Lotto Days are Tues, Thurs, Sat and I assume they don't stop for anything
1465 > = Tues, June 6, 2017
1466 > = Thurs, June 8, 2017
1467 > = Sat, June 10, 2017
...

🤷‍♂️

I found this that you enter day month and year an Italian date is printed

Code: QB64: [Select]
  1. OPTION _EXPLICIT ' impone la dichiarazione delle variabili
  2. OPTION BASE 1 ' le matrici partono dall'indice 1
  3.  
  4. _TITLE "CB @2020"
  5.  
  6. ' inizializzazione varaiabili
  7. DIM sGiorno AS STRING
  8. DIM sMese AS STRING
  9. DIM sAnno AS STRING
  10. DIM sData AS STRING
  11. DIM iGiorno AS INTEGER
  12. DIM iMese AS INTEGER
  13. DIM iAnno AS INTEGER
  14.  
  15. DIM msNomeMesi(12) AS STRING ' matrice di stringhe
  16.  
  17. msNomeMesi(1) = "Gennaio"
  18. msNomeMesi(2) = "Febbraio"
  19. msNomeMesi(3) = "Marzo"
  20. msNomeMesi(4) = "Aprile"
  21. msNomeMesi(5) = "Maggio"
  22. msNomeMesi(6) = "Giugno"
  23. msNomeMesi(7) = "Luglio"
  24. msNomeMesi(8) = "Agosto"
  25. msNomeMesi(9) = "Settembre"
  26. msNomeMesi(10) = "Ottobre"
  27. msNomeMesi(11) = "Novembre"
  28. msNomeMesi(12) = "Dicembre"
  29.  
  30. DIM msSettimana(7) AS STRING ' matrice di stringhe
  31.  
  32. msSettimana(1) = "Domenica"
  33. msSettimana(2) = "Lunedi"
  34. msSettimana(3) = "Martedi"
  35. msSettimana(4) = "Mercoledi"
  36. msSettimana(5) = "Giovedi"
  37. msSettimana(6) = "Venerdi"
  38. msSettimana(7) = "Sabato"
  39.  
  40.  
  41. ' preparazione schermo
  42. COLOR , 1
  43. Inizio:
  44. COLOR 14, 12
  45. LOCATE 2, 1: PRINT "--------------------------------------------------------------------------------"
  46. LOCATE 3, 1: PRINT "                             DA DATA A DATA ESTESA                              "
  47. LOCATE 4, 1: PRINT "--------------------------------------------------------------------------------"
  48. COLOR 15, 1
  49.  
  50. LOCATE 7, 10: INPUT "inserisci il giorno (1/31) "; sGiorno
  51. LOCATE 9, 10: INPUT "inserisci il mese (1/12) "; sMese
  52. LOCATE 11, 10: INPUT "inserisci l'anno (1584/3000) "; sAnno
  53.  
  54. ' mancano controlli sugli input
  55.  
  56. ' conversione stringa->numero
  57. iGiorno = VAL(sGiorno)
  58. iMese = VAL(sMese)
  59. iAnno = VAL(sAnno)
  60. ' composizione data di uscita
  61. sData = sGiorno + "/" + msNomeMesi(iMese) + "/" + sAnno
  62. ' calcolo del giorno della settimana
  63. IF iMese < 3 THEN
  64.     iAnno = iAnno - 1
  65.     iMese = iMese + 12
  66. iV1 = INT(iAnno / 100)
  67. iV2 = iAnno - iV1 * 100
  68. iV3 = INT(2.6001 * (iMese - 2) - .2) + iGiorno + iV2 + INT(iV2 / 4) + INT(iV1 / 4) - 2 * iV1
  69. iV3 = iV3 - INT(iV3 / 7) * 7 + 1
  70.  
  71. ' uscita
  72. LOCATE 16, 10: PRINT msSettimana(iV3); " "; sData
  73.  
  74. ' attesa
  75. LOCATE 24, 10: PRINT "[ premi un tasto per nuova data ]";
  76. DO: K = INKEY$: SLEEP (1): LOOP WHILE K = ""
  77. GOTO Inizio
  78.  
  79.  

I hope this helps
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #107 on: July 16, 2020, 03:59:34 pm »
Ha! Yes @SMcNeill  thanks to practice checking your time stamps, I think I have handle on this, at least for numbers going forward. I moved start date to Thurs June 1, 2017 to make whole month tests = lotto number 1463 and based calculations starting there.

A little more checking to do but I have good dates through Jan 2, 2018 lotto number 1555.


@Kiara87
Wow, all you folks for whom English is not your first language I am so impressed with your participation here at this forum!

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
Re: help my
« Reply #108 on: July 16, 2020, 04:36:29 pm »
Ha! Yes @SMcNeill  thanks to practice checking your time stamps, I think I have handle on this, at least for numbers going forward. I moved start date to Thurs June 1, 2017 to make whole month tests = lotto number 1463 and based calculations starting there.

A little more checking to do but I have good dates through Jan 2, 2018 lotto number 1555.


@Kiara87
Wow, all you folks for whom English is not your first language I am so impressed with your participation here at this forum!

qb64 fascinates me and has become my passion
and this forum there is something special
that drives you to learn
even people who try to help you
as you are doing
you are a person who knows how to keep the forum active
and with your knowledge as a good programmer
I hope to learn to program and understand the logic of programming too

and tried to understand the changes you make in my program so I also understand how to program
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #109 on: July 16, 2020, 04:39:50 pm »
Hopefully I have the Italian correct:
Code: QB64: [Select]
  1. DEFLNG A-Z
  2. _TITLE "Lotto day+date from lotto number" 'b+ 2020-07-16
  3. ' given a number (integer) figure the day and date of lotto
  4. ' hint: 1465 = Tuesday, June 6, 2017 that is key to this hack job
  5. ' moved back to Thursday, June 1, 2017 but might have to move back further
  6. ' for lotto number 1.
  7.  
  8. DIM SHARED msNomeMesi(12) AS STRING ' matrice di stringhe
  9. msNomeMesi(1) = "Gennaio"
  10. msNomeMesi(2) = "Febbraio"
  11. msNomeMesi(3) = "Marzo"
  12. msNomeMesi(4) = "Aprile"
  13. msNomeMesi(5) = "Maggio"
  14. msNomeMesi(6) = "Giugno"
  15. msNomeMesi(7) = "Luglio"
  16. msNomeMesi(8) = "Agosto"
  17. msNomeMesi(9) = "Settembre"
  18. msNomeMesi(10) = "Ottobre"
  19. msNomeMesi(11) = "Novembre"
  20. msNomeMesi(12) = "Dicembre"
  21.  
  22. DIM SHARED msSettimana(7) AS STRING ' matrice di stringhe
  23. msSettimana(1) = "Domenica"
  24. msSettimana(2) = "Lunedi"
  25. msSettimana(3) = "Martedi"
  26. msSettimana(4) = "Mercoledi"
  27. msSettimana(5) = "Giovedi"
  28. msSettimana(6) = "Venerdi"
  29. msSettimana(7) = "Sabato"
  30.  
  31.  
  32. DIM lottoNum
  33. FOR lottoNum = 1463 TO 1483 'checked through 1712
  34.     'INPUT "Enter lotto number "; lottoNumX
  35.     '  lottoNumX = ?
  36.     PRINT lottoNum, CovertLottoNumToDate$(lottoNum)
  37.  
  38. FUNCTION CovertLottoNumToDate$ (lottoNumX)
  39.     DIM numberOfDays1463, yr, mo
  40.     numberOfDays1463 = INT(lottoNumX - 1463) / 3 * 7
  41.     yr = 2017
  42.     mo = 6
  43.     WHILE numberOfDays1463 > daysInMonth%(mo, yr) - 1
  44.         numberOfDays1463 = numberOfDays1463 - daysInMonth%(mo, yr)
  45.         mo = mo + 1
  46.         IF mo = 13 THEN mo = 1: yr = yr + 1
  47.     WEND
  48.     ' date shound be yr, m0, numberOfDays1465
  49.     CovertLottoNumToDate$ = lottoday$(lottoNumX) + _TRIM$(STR$(numberOfDays1463 + 1)) + "/" + msNomeMesi(mo) + "/" + _TRIM$(STR$(yr))
  50.  
  51. FUNCTION lottoday$ (lottoNum)
  52.     IF lottoNum MOD 3 = 1 THEN lottoday$ = "Martedi, "
  53.     IF lottoNum MOD 3 = 2 THEN lottoday$ = "Giovedi, "
  54.     IF lottoNum MOD 3 = 0 THEN lottoday$ = "Sabato, "
  55.  
  56. FUNCTION daysInMonth% (mNum, yearNum)
  57.     DIM copyM, copyY
  58.     copyM = mNum
  59.     IF mNum = 13 THEN copyM = 1: copyY = yearNum + 1 ELSE copyY = yearNum
  60.     SELECT CASE copyM
  61.         CASE 1, 3, 5, 7, 8, 10, 12: daysInMonth% = 31
  62.         CASE 4, 6, 9, 11: daysInMonth% = 30
  63.         CASE 2: daysInMonth% = daysInFeb%(copyY)
  64.     END SELECT
  65.  
  66. FUNCTION daysInFeb% (yr) 'from Pete's calendar this is a very clear calc
  67.     DIM days AS INTEGER
  68.     IF yr MOD 4 = 0 THEN
  69.         IF yr MOD 100 = 0 THEN
  70.             IF yr MOD 400 = 0 THEN days = 29
  71.         ELSE
  72.             days = 29
  73.         END IF
  74.     END IF
  75.     IF days THEN daysInFeb% = days ELSE daysInFeb% = 28
  76.  
  77.  

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
Re: help my
« Reply #110 on: July 16, 2020, 05:00:00 pm »
Hopefully I have the Italian correct:
Code: QB64: [Select]
  1. DEFLNG A-Z
  2. _TITLE "Lotto day+date from lotto number" 'b+ 2020-07-16
  3. ' given a number (integer) figure the day and date of lotto
  4. ' hint: 1465 = Tuesday, June 6, 2017 that is key to this hack job
  5. ' moved back to Thursday, June 1, 2017 but might have to move back further
  6. ' for lotto number 1.
  7.  
  8. DIM SHARED msNomeMesi(12) AS STRING ' matrice di stringhe
  9. msNomeMesi(1) = "Gennaio"
  10. msNomeMesi(2) = "Febbraio"
  11. msNomeMesi(3) = "Marzo"
  12. msNomeMesi(4) = "Aprile"
  13. msNomeMesi(5) = "Maggio"
  14. msNomeMesi(6) = "Giugno"
  15. msNomeMesi(7) = "Luglio"
  16. msNomeMesi(8) = "Agosto"
  17. msNomeMesi(9) = "Settembre"
  18. msNomeMesi(10) = "Ottobre"
  19. msNomeMesi(11) = "Novembre"
  20. msNomeMesi(12) = "Dicembre"
  21.  
  22. DIM SHARED msSettimana(7) AS STRING ' matrice di stringhe
  23. msSettimana(1) = "Domenica"
  24. msSettimana(2) = "Lunedi"
  25. msSettimana(3) = "Martedi"
  26. msSettimana(4) = "Mercoledi"
  27. msSettimana(5) = "Giovedi"
  28. msSettimana(6) = "Venerdi"
  29. msSettimana(7) = "Sabato"
  30.  
  31.  
  32. DIM lottoNum
  33. FOR lottoNum = 1463 TO 1483 'checked through 1712
  34.     'INPUT "Enter lotto number "; lottoNumX
  35.     '  lottoNumX = ?
  36.     PRINT lottoNum, CovertLottoNumToDate$(lottoNum)
  37.  
  38. FUNCTION CovertLottoNumToDate$ (lottoNumX)
  39.     DIM numberOfDays1463, yr, mo
  40.     numberOfDays1463 = INT(lottoNumX - 1463) / 3 * 7
  41.     yr = 2017
  42.     mo = 6
  43.     WHILE numberOfDays1463 > daysInMonth%(mo, yr) - 1
  44.         numberOfDays1463 = numberOfDays1463 - daysInMonth%(mo, yr)
  45.         mo = mo + 1
  46.         IF mo = 13 THEN mo = 1: yr = yr + 1
  47.     WEND
  48.     ' date shound be yr, m0, numberOfDays1465
  49.     CovertLottoNumToDate$ = lottoday$(lottoNumX) + _TRIM$(STR$(numberOfDays1463 + 1)) + "/" + msNomeMesi(mo) + "/" + _TRIM$(STR$(yr))
  50.  
  51. FUNCTION lottoday$ (lottoNum)
  52.     IF lottoNum MOD 3 = 1 THEN lottoday$ = "Martedi, "
  53.     IF lottoNum MOD 3 = 2 THEN lottoday$ = "Giovedi, "
  54.     IF lottoNum MOD 3 = 0 THEN lottoday$ = "Sabato, "
  55.  
  56. FUNCTION daysInMonth% (mNum, yearNum)
  57.     DIM copyM, copyY
  58.     copyM = mNum
  59.     IF mNum = 13 THEN copyM = 1: copyY = yearNum + 1 ELSE copyY = yearNum
  60.     SELECT CASE copyM
  61.         CASE 1, 3, 5, 7, 8, 10, 12: daysInMonth% = 31
  62.         CASE 4, 6, 9, 11: daysInMonth% = 30
  63.         CASE 2: daysInMonth% = daysInFeb%(copyY)
  64.     END SELECT
  65.  
  66. FUNCTION daysInFeb% (yr) 'from Pete's calendar this is a very clear calc
  67.     DIM days AS INTEGER
  68.     IF yr MOD 4 = 0 THEN
  69.         IF yr MOD 100 = 0 THEN
  70.             IF yr MOD 400 = 0 THEN days = 29
  71.         ELSE
  72.             days = 29
  73.         END IF
  74.     END IF
  75.     IF days THEN daysInFeb% = days ELSE daysInFeb% = 28
  76.  
  77.  

you are truly an alien a programming machine

now I have to understand how the function fits into the program thanks
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #111 on: July 16, 2020, 09:18:07 pm »
Quote
now I have to understand how the function fits into the program thanks

The 4 FUNCTIONs go at the end of the code. The array of month names is SHARED at the top of your code with other variables setup. The code in middle is just a demo test to see that the Convert Function works.

When you want to show the date of the Lotto line, LOCATE where you want date and PRINT ConvertLottoNumtoDate$(lottoNum) which is the first 4 digits of the line from Lotto.dat.

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
Re: help my
« Reply #112 on: July 17, 2020, 04:27:03 am »
The 4 FUNCTIONs go at the end of the code. The array of month names is SHARED at the top of your code with other variables setup. The code in middle is just a demo test to see that the Convert Function works.

When you want to show the date of the Lotto line, LOCATE where you want date and PRINT ConvertLottoNumtoDate$(lottoNum) which is the first 4 digits of the line from Lotto.dat.

ok bplus

Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!  b+ mod of kiara mod of b+ 2020-07-15
  2.  
  3. DEFINT A-Z ' everything is integer unless DIM or suffix
  4. CONST nRows = 11 'rows of 5 data points in each line of fileDat
  5. DIM a AS STRING, a2 AS STRING, count, i, lineNum, lineNum2 ' for file and array access
  6. DIM Q$ '                             for INKEY$
  7. DIM row, col, aPlace '               for screening Data from a string
  8. DIM rowCnt, y, rowPlus '       for loading lineDAT() from a file string
  9. DIM lineDAT(1 TO 5, 1 TO nRows) AS INTEGER 'an  array to load from each line from DAT
  10. DIM shiftRight
  11. DIM shiftRight2
  12. DIM mb, mx, my, oldmouse ' oldmouse is trick Steve McNeill showed us to get ONE mouse click!
  13. DIM lottoNum
  14. '---------------------------------------------------------------------------------------------------
  15. DIM SHARED msNomeMesi(12) AS STRING ' matrice di stringhe
  16. msNomeMesi(1) = "Gennaio"
  17. msNomeMesi(2) = "Febbraio"
  18. msNomeMesi(3) = "Marzo"
  19. msNomeMesi(4) = "Aprile"
  20. msNomeMesi(5) = "Maggio"
  21. msNomeMesi(6) = "Giugno"
  22. msNomeMesi(7) = "Luglio"
  23. msNomeMesi(8) = "Agosto"
  24. msNomeMesi(9) = "Settembre"
  25. msNomeMesi(10) = "Ottobre"
  26. msNomeMesi(11) = "Novembre"
  27. msNomeMesi(12) = "Dicembre"
  28.  
  29. DIM SHARED msSettimana(7) AS STRING ' matrice di stringhe
  30. msSettimana(1) = "Domenica"
  31. msSettimana(2) = "Lunedi"
  32. msSettimana(3) = "Martedi"
  33. msSettimana(4) = "Mercoledi"
  34. msSettimana(5) = "Giovedi"
  35. msSettimana(6) = "Venerdi"
  36. msSettimana(7) = "Sabato"
  37.  
  38.  
  39.  
  40. '-------------------------------------------------------------------------------------------------
  41. shiftRight2 = 65
  42. shiftRight = 11
  43.  
  44.  
  45. 'count lines in file
  46. OPEN "lotto.dat" FOR INPUT AS #1
  47.     INPUT #1, a
  48.     '          debug check inputs from file
  49.     'PRINT a
  50.     'INPUT " OK enter "; w$
  51.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  52.  
  53. 'now we now size of file so ready an array to load file Data
  54. DIM fileDAT(1 TO count) AS STRING
  55. OPEN "lotto.dat" FOR INPUT AS #1
  56. FOR i = 1 TO count
  57.     INPUT #1, a
  58.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  59.  
  60. ' NOW all the data if loaded into fileDAT() array, 480 strings of Lottory data
  61.  
  62. GOSUB labelScreen
  63.  
  64. 'set first line and get a data string from the FileDAT array
  65. lineNum = 1
  66. a = fileDAT(lineNum)
  67. lineNum2 = 1
  68. a2 = fileDAT(lineNum2)
  69. lottoNum = 1465
  70.     CLS
  71.     Q$ = INKEY$
  72.     IF Q$ = "+" THEN lottoNum = lottoNum + 1
  73.     IF Q$ = "-" THEN lottoNum = lottoNum - 1
  74.     IF Q$ = "+" THEN lineNum = lineNum + 1
  75.     IF Q$ = "-" THEN lineNum = lineNum - 1
  76.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum2 = lineNum2 + 1
  77.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum2 = lineNum2 - 1
  78.  
  79.     mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  80.     'LOCATE 3, 1: PRINT mx, my
  81.     IF mb AND oldmouse = 0 AND my > 24 THEN ' <<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  82.         '_DELAY .25 '        just one click please!
  83.         IF 17 <= mx AND mx <= 25 THEN lineNum = lineNum + 1
  84.         IF 28 <= mx AND mx <= 37 THEN lineNum = lineNum - 1
  85.         IF 44 <= mx AND mx <= 52 THEN lineNum2 = lineNum2 + 1
  86.         IF 55 <= mx AND mx <= 64 THEN lineNum2 = lineNum2 - 1
  87.     END IF
  88.     oldmouse = _MOUSEBUTTON(1) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  89.     IF lineNum2 > count THEN lineNum2 = 1
  90.     IF lineNum2 < 1 THEN lineNum2 = count
  91.  
  92.     IF lineNum > count THEN lineNum = 1
  93.     IF lineNum < 1 THEN lineNum = count
  94.  
  95.     'get new data line
  96.     a = fileDAT(lineNum)
  97.  
  98.     a2 = fileDAT(lineNum2)
  99.     'print out the data from the new line
  100.  
  101.     GOSUB labelScreen
  102.     GOSUB screenDataLine
  103.     GOSUB loadLineDAT_Mark30s
  104.     _DISPLAY
  105.     _LIMIT 30
  106.  
  107. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  108. rowCnt = 1: y = 1
  109. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  110.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  111.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  112.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  113. COLOR 9 'blue marker  seacrh through columes for  30's
  114. FOR col = 1 TO 5 'for each of the columes of data
  115.     FOR row = 1 TO 10 'for each of the rows of dat
  116.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  117.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  118.                 LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, row));
  119.                 LOCATE rowPlus * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, rowPlus));
  120.             END IF
  121.         NEXT
  122.     NEXT
  123. '---------------------------------------------------- right side  a2 data line
  124. rowCnt = 1: y = 1
  125. FOR i = 5 TO LEN(a2) STEP 2 ' is marking off the start of each data 2 digit integer
  126.     lineDAT(rowCnt, y) = VAL(MID$(a2, i, 2)) 'convert data item to integer
  127.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  128.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  129. COLOR 9 'blue marker  seacrh through columes for  30's
  130. FOR col = 1 TO 5 'for each of the columes of data
  131.     FOR row = 1 TO 10 'for each of the rows of dat
  132.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  133.             ' IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  134.             'LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, row));
  135.             'LOCATE rowPlus * 2 + 1, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, rowPlus));
  136.             'END IF
  137.         NEXT
  138.     NEXT
  139.  
  140.  
  141. screenDataLine:
  142. LOCATE 1, 1
  143. PRINT "estraz: "; CovertLottoNumToDate$(lottoNum);" " LEFT$(a, 4)
  144. LOCATE 1, 1
  145. 'PRINT "estraz: "; LEFT$(a, 4); '"  line:"; 'STR$(lineNum); ""
  146. aPlace = 5
  147. FOR row = 1 TO 11
  148.     FOR col = 1 TO 5
  149.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2);
  150.         aPlace = aPlace + 2
  151.     NEXT
  152. '-------------------------------------------------- Right side
  153. LOCATE 1, 15 + 43
  154. PRINT "estraz "; LEFT$(a2, 4); "   line:"; STR$(lineNum2); '<<<<<<<<<<<<<<< a2 now
  155. aPlace = 5
  156. FOR row = 1 TO 11
  157.     FOR col = 1 TO 5
  158.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT MID$(a2, aPlace, 2); '<<<<<<<<<<<<<<< a2 now
  159.         aPlace = aPlace + 2
  160.     NEXT
  161.  
  162. labelScreen:
  163. DIM labels(11) AS STRING ' setup screen labels for reporting data
  164. labels(1) = "BARI"
  165. labels(2) = "CAGLIARI"
  166. labels(3) = "FIRENZE"
  167. labels(4) = "GENOVA"
  168. labels(5) = "MILANO"
  169. labels(6) = "NAPOLI"
  170. labels(7) = "PALERMO"
  171. labels(8) = "ROMA"
  172. labels(9) = "TORINO"
  173. labels(10) = "VENEZIA"
  174. labels(11) = "NAZIONALE"
  175. FOR i = 1 TO 11
  176.     LOCATE i * 2 + 1, 1: PRINT labels(i)
  177. LOCATE 25, 1
  178. FOR i = 1 TO 11
  179.     LOCATE i * 2 + 1, 55: PRINT labels(i)
  180. LOCATE 25, 1
  181.  
  182.  
  183. PRINT " Fare clic su:  Fino / Up  Giu / Down      Fino / Up  Giu / Down";
  184. '      12345678901234567890123456789012345678901234567890123456789012345678901234567890
  185. '               1         2         3         4         5         6         7         8
  186.  
  187. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  188.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  189.  
  190. FUNCTION diff30in90 (a, b) 'default integers a-z
  191.     DIM hi, lo
  192.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  193.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  194.     IF hi - lo = 30 THEN
  195.         diff30in90 = -1
  196.     ELSE
  197.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  198.     END IF
  199.  
  200. FUNCTION CovertLottoNumToDate$ (lottoNumX)
  201.     DIM numberOfDays1463, yr, mo
  202.     numberOfDays1463 = INT(lottoNumX - 1463) / 3 * 7
  203.     yr = 2017
  204.     mo = 6
  205.     WHILE numberOfDays1463 > daysInMonth%(mo, yr) - 1
  206.         numberOfDays1463 = numberOfDays1463 - daysInMonth%(mo, yr)
  207.         mo = mo + 1
  208.         IF mo = 13 THEN mo = 1: yr = yr + 1
  209.     WEND
  210.     ' date shound be yr, m0, numberOfDays1465
  211.     CovertLottoNumToDate$ = lottoday$(lottoNumX) + _TRIM$(STR$(numberOfDays1463 + 1)) + "/" + msNomeMesi(mo) + "/" + _TRIM$(STR$(yr))
  212.  
  213. FUNCTION lottoday$ (lottoNum)
  214.     IF lottoNum MOD 3 = 1 THEN lottoday$ = "Martedi, "
  215.     IF lottoNum MOD 3 = 2 THEN lottoday$ = "Giovedi, "
  216.     IF lottoNum MOD 3 = 0 THEN lottoday$ = "Sabato, "
  217.  
  218. FUNCTION daysInMonth% (mNum, yearNum)
  219.     DIM copyM, copyY
  220.     copyM = mNum
  221.     IF mNum = 13 THEN copyM = 1: copyY = yearNum + 1 ELSE copyY = yearNum
  222.     SELECT CASE copyM
  223.         CASE 1, 3, 5, 7, 8, 10, 12: daysInMonth% = 31
  224.         CASE 4, 6, 9, 11: daysInMonth% = 30
  225.         CASE 2: daysInMonth% = daysInFeb%(copyY)
  226.     END SELECT
  227.  
  228. FUNCTION daysInFeb% (yr) 'from Pete's calendar this is a very clear calc
  229.     DIM days AS INTEGER
  230.     IF yr MOD 4 = 0 THEN
  231.         IF yr MOD 100 = 0 THEN
  232.             IF yr MOD 400 = 0 THEN days = 29
  233.         ELSE
  234.             days = 29
  235.         END IF
  236.     END IF
  237.     IF days THEN daysInFeb% = days ELSE daysInFeb% = 28
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  

so it works but if it reaches the last continuous extraction it doesn't go back

I arrived until 2021
and back says minus extraction

after all it works
but I have to figure out how to fix it when it passes today's date
and return to the first draw with the date of the first

thanks bplus
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #113 on: July 17, 2020, 12:21:14 pm »
Code: QB64: [Select]
  1. lineNum = 1
  2. a = fileDAT(lineNum)
  3. lineNum2 = 1
  4. a2 = fileDAT(lineNum2)
  5. '''''''''''''''''''''''''''''''''''''''''''''''''''''''' lottoNum = 1465
  6.  

When we set our line numbers from the Click or Keypress, we can also get the date for each extraction:
Code: QB64: [Select]
  1. lottoNum = val(left$(a, 4))
  2. lottoNum2 = val(left$(a2, 4))
  3. lottoDate$ = ConvertLottoNumToDate$(lottNum)   ' fix spelling of the function it's convert with an n
  4. lottoDate2$ = ConvertLottoNumToDate$(lottNum2) ' fix spelling of the function it's convert with an n
  5.  


Now this section can be labeled better with dates:
Code: QB64: [Select]
  1. screenDataLine:
  2. LOCATE 1, 1
  3. PRINT "estraz: "; CovertLottoNumToDate$(lottoNum);" " LEFT$(a, 4)  '<<<<  lottoDate$ and lottoNum
  4. LOCATE 1, 1
  5. 'PRINT "estraz: "; LEFT$(a, 4); '"  line:"; 'STR$(lineNum); ""
  6. aPlace = 5
  7. FOR row = 1 TO 11
  8.     FOR col = 1 TO 5
  9.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2);
  10.         aPlace = aPlace + 2
  11.     NEXT
  12. '-------------------------------------------------- Right side
  13. LOCATE 1, 15 + 43
  14. PRINT "estraz "; LEFT$(a2, 4); "   line:"; STR$(lineNum2); '< a2 now <<<< NOW!! lottoDate2$ and lottoNum2
  15. aPlace = 5

Probably don't need the weekday names they are built into functions and the labels can be moved to top with the other data setup.
« Last Edit: July 17, 2020, 12:44:48 pm by bplus »

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
Re: help my
« Reply #114 on: July 17, 2020, 02:26:09 pm »
Code: QB64: [Select]
  1. lineNum = 1
  2. a = fileDAT(lineNum)
  3. lineNum2 = 1
  4. a2 = fileDAT(lineNum2)
  5. '''''''''''''''''''''''''''''''''''''''''''''''''''''''' lottoNum = 1465
  6.  

When we set our line numbers from the Click or Keypress, we can also get the date for each extraction:
Code: QB64: [Select]
  1. lottoNum = val(left$(a, 4))
  2. lottoNum2 = val(left$(a2, 4))
  3. lottoDate$ = ConvertLottoNumToDate$(lottNum)   ' fix spelling of the function it's convert with an n
  4. lottoDate2$ = ConvertLottoNumToDate$(lottNum2) ' fix spelling of the function it's convert with an n
  5.  


Now this section can be labeled better with dates:
Code: QB64: [Select]
  1. screenDataLine:
  2. LOCATE 1, 1
  3. PRINT "estraz: "; CovertLottoNumToDate$(lottoNum);" " LEFT$(a, 4)  '<<<<  lottoDate$ and lottoNum
  4. LOCATE 1, 1
  5. 'PRINT "estraz: "; LEFT$(a, 4); '"  line:"; 'STR$(lineNum); ""
  6. aPlace = 5
  7. FOR row = 1 TO 11
  8.     FOR col = 1 TO 5
  9.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2);
  10.         aPlace = aPlace + 2
  11.     NEXT
  12. '-------------------------------------------------- Right side
  13. LOCATE 1, 15 + 43
  14. PRINT "estraz "; LEFT$(a2, 4); "   line:"; STR$(lineNum2); '< a2 now <<<< NOW!! lottoDate2$ and lottoNum2
  15. aPlace = 5

Probably don't need the weekday names they are built into functions and the labels can be moved to top with the other data setup.
dim lottoDate$
or
dim lottoDate as string
however, it does not convert the string variable to a number
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #115 on: July 17, 2020, 02:38:14 pm »
Code: QB64: [Select]
  1. lottoNum = VAL(LEFT$(a, 4))
  2. lottoNum2 = VAL(LEFT$(a2, 4))
  3. lottoDate$ = ConvertLottoNumToDate$(lottNum)   ' fix spelling of the function it's convert with an n
  4. lottoDate2$ = ConvertLottoNumToDate$(lottNum2) ' fix spelling of the function it's convert with an n
  5.  

This has to be done AFTER you get new a and a2 from file array, which is AFTER you hit up arrow or down or after +/- or after you click up / down.

Before all that the FUNCTION convert.... is misspelled it is missing an n. You have to change the function name and then where it is set near bottom of the function. That is what is red lined because could not find the function because I misspelled it. It is NOT covert, it is convert.

If you wait another couple hours I will have that and a bunch of other things cleaned up and have the code looking spiffy! :) I have to run errands again.

After spiffy, I will try and figure want you want between the 2 screens. I see you have commented out the right side diff 30's coloring.
« Last Edit: July 17, 2020, 02:40:28 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #116 on: July 17, 2020, 03:21:43 pm »
Spiffy enough for now:
Code: QB64: [Select]
  1. _TITLE "Lotto Data"
  2. 'for typo's   yep lineMun blah!  b+ mod of kiara mod of b+ 2020-07-15
  3. '2020-07-17 remove weekday names, move labels into there, fix bottom line up/down click
  4. '           fix function convertLottoNum2Date$ spelling
  5. '           clean out some redundant code loops
  6.  
  7. DEFINT A-Z ' everything is integer unless DIM or suffix
  8. CONST nRows = 11 '                          rows of 5 data points in each line of fileDat
  9.  
  10. DIM count '                                 for number of lines in the data file
  11.  
  12. DIM lineNum, lineNum2 '                     for tracking array access this is actual file line of data we are screening
  13. DIM a AS STRING, a2 AS STRING '             extraction lines of data
  14. DIM lottoNum, lottoNum2 '                   for extractions
  15. DIM lottoDate$, lottoDate2$ '               for the dates of lottos
  16.  
  17. ' user inputs
  18. DIM Q$ '                                    for INKEY$
  19. DIM mb, mx, my, oldmouse '                  Mouse stuff oldmouse is trick Steve McNeill showed us to get ONE mouse click!
  20.  
  21. ' these would normally go in SUBs or FUNCTIONs but we are using GOSUBs here
  22. DIM shiftRight, shiftRight2 '               screening data left and right, normally these would be CONSTANTs
  23. shiftRight = 11 '                           according to screen fit
  24. shiftRight2 = 65 '                          according to screen fit
  25.  
  26. DIM row, col, aPlace '                      for screening Data from a string
  27. DIM rowCnt, y, rowPlus '                    for loading lineDAT() from a file string
  28. DIM lineDAT(1 TO 5, 1 TO nRows) AS INTEGER 'an  array to load from each line from DAT
  29.  
  30. DIM i '                                     common use for indexing
  31.  
  32. DIM SHARED msNomeMesi(1 TO 12) AS STRING ' matrice di stringhe
  33. msNomeMesi(1) = "Gennaio"
  34. msNomeMesi(2) = "Febbraio"
  35. msNomeMesi(3) = "Marzo"
  36. msNomeMesi(4) = "Aprile"
  37. msNomeMesi(5) = "Maggio"
  38. msNomeMesi(6) = "Giugno"
  39. msNomeMesi(7) = "Luglio"
  40. msNomeMesi(8) = "Agosto"
  41. msNomeMesi(9) = "Settembre"
  42. msNomeMesi(10) = "Ottobre"
  43. msNomeMesi(11) = "Novembre"
  44. msNomeMesi(12) = "Dicembre"
  45.  
  46. DIM labels(1 TO 11) AS STRING ' setup screen labels for reporting data
  47. labels(1) = "BARI"
  48. labels(2) = "CAGLIARI"
  49. labels(3) = "FIRENZE"
  50. labels(4) = "GENOVA"
  51. labels(5) = "MILANO"
  52. labels(6) = "NAPOLI"
  53. labels(7) = "PALERMO"
  54. labels(8) = "ROMA"
  55. labels(9) = "TORINO"
  56. labels(10) = "VENEZIA"
  57. labels(11) = "NAZIONALE"
  58.  
  59. '-------------------------------- start Main setup get file data loaded into array
  60.  
  61. 'count lines in file
  62. OPEN "lotto.dat" FOR INPUT AS #1
  63.     INPUT #1, a
  64.     '          debug check inputs from file
  65.     'PRINT a
  66.     'INPUT " OK enter "; w$
  67.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  68.  
  69. 'now we now size of file so ready an array to load file Data
  70. DIM fileDAT(1 TO count) AS STRING
  71. OPEN "lotto.dat" FOR INPUT AS #1
  72. FOR i = 1 TO count
  73.     INPUT #1, a
  74.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  75.  
  76. 'get/set first line and get a data string from the FileDAT array  (left set on screen)
  77. lineNum = 1
  78. a = fileDAT(lineNum)
  79. lottoNum = VAL(LEFT$(a, 4))
  80. lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  81.  
  82. 'get/set right side start variables
  83. lineNum2 = 1
  84. a2 = fileDAT(lineNum2)
  85. lottoNum2 = VAL(LEFT$(a2, 4))
  86. lottoDate2$ = ConvertLottoNumToDate$(lottoNum2)
  87.  
  88. DO '------------------------------------------------ Main Loop User selects data to compare
  89.     CLS
  90.     Q$ = INKEY$
  91.     IF Q$ = "+" THEN lineNum = lineNum + 1
  92.     IF Q$ = "-" THEN lineNum = lineNum - 1
  93.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum2 = lineNum2 + 1
  94.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum2 = lineNum2 - 1
  95.  
  96.     mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  97.     'LOCATE 3, 1: PRINT mx, my
  98.     IF mb AND oldmouse = 0 AND my > 24 THEN ' <<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  99.         '_DELAY .25 '        just one click please!
  100.         IF 3 <= mx AND mx <= 11 THEN lineNum = lineNum + 1
  101.         IF 14 <= mx AND mx <= 23 THEN lineNum = lineNum - 1
  102.         IF 56 <= mx AND mx <= 64 THEN lineNum2 = lineNum2 + 1
  103.         IF 67 <= mx AND mx <= 76 THEN lineNum2 = lineNum2 - 1
  104.     END IF
  105.     oldmouse = _MOUSEBUTTON(1) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  106.     IF lineNum > count THEN lineNum = 1
  107.     IF lineNum < 1 THEN lineNum = count
  108.     IF lineNum2 > count THEN lineNum2 = 1
  109.     IF lineNum2 < 1 THEN lineNum2 = count
  110.  
  111.     'get new data line
  112.     a = fileDAT(lineNum) 'left side data
  113.     lottoNum = VAL(LEFT$(a, 4))
  114.     lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  115.  
  116.     a2 = fileDAT(lineNum2) 'right side data
  117.     lottoNum2 = VAL(LEFT$(a2, 4))
  118.     lottoDate2$ = ConvertLottoNumToDate$(lottoNum2)
  119.  
  120.     'print out the data from the new line
  121.     GOSUB labelScreen
  122.     GOSUB screenDataLine
  123.     GOSUB loadLineDAT_Mark30s
  124.     _DISPLAY
  125.     _LIMIT 30
  126.  
  127. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  128. rowCnt = 1: y = 1
  129. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  130.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  131.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  132.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  133. COLOR 9 'blue marker  seacrh through columes for  30's
  134. FOR col = 1 TO 5 'for each of the columes of data
  135.     FOR row = 1 TO 10 'for each of the rows of dat
  136.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  137.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  138.                 LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, row));
  139.                 LOCATE rowPlus * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, rowPlus));
  140.             END IF
  141.         NEXT
  142.     NEXT
  143. ''----------------------------- plug in new color routine here for right side ???
  144. 'rowCnt = 1: y = 1
  145. 'FOR i = 5 TO LEN(a2) STEP 2 ' is marking off the start of each data 2 digit integer
  146. '    lineDAT(rowCnt, y) = VAL(MID$(a2, i, 2)) 'convert data item to integer
  147. '    rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  148. '    IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  149. 'NEXT
  150. 'COLOR 9 'blue marker  seacrh through columes for  30's
  151. 'FOR col = 1 TO 5 'for each of the columes of data
  152. '    FOR row = 1 TO 10 'for each of the rows of dat
  153. '        FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  154. '            'IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  155. '            '    LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, row));
  156. '            '    LOCATE rowPlus * 2 + 1, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, rowPlus));
  157. '            'END IF
  158. '        NEXT
  159. '    NEXT
  160. 'NEXT
  161.  
  162. screenDataLine:
  163. LOCATE 1, 1
  164. PRINT lottoNum; lottoDate$;
  165. LOCATE 1, 48
  166. PRINT lottoNum2; lottoDate2$;
  167. aPlace = 5
  168. FOR row = 1 TO 11
  169.     FOR col = 1 TO 5
  170.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2); ' Left side
  171.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT MID$(a2, aPlace, 2); '<< a2 now Right Side
  172.         aPlace = aPlace + 2
  173.     NEXT
  174.  
  175. labelScreen:
  176. FOR i = 1 TO 11
  177.     LOCATE i * 2 + 1, 1: PRINT labels(i)
  178.     LOCATE i * 2 + 1, 55: PRINT labels(i)
  179. LOCATE 25, 1
  180. PRINT "  Fino / Up  Giu / Down        : Fare clic su :        Fino / Up  Giu / Down";
  181. '      12345678901234567890123456789012345678901234567890123456789012345678901234567890
  182. '               1         2         3         4         5         6         7         8
  183.  
  184. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  185.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  186.  
  187. FUNCTION diff30in90 (a, b) 'default integers a-z
  188.     DIM hi, lo
  189.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  190.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  191.     IF hi - lo = 30 THEN
  192.         diff30in90 = -1
  193.     ELSE
  194.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  195.     END IF
  196.  
  197. ' -----------------------------------------------------  Convert Lotto Num to Date Function and helpers
  198. FUNCTION ConvertLottoNumToDate$ (lottoNumX)
  199.     DIM numberOfDays1463, yr, mo
  200.     numberOfDays1463 = INT(lottoNumX - 1463) / 3 * 7
  201.     yr = 2017
  202.     mo = 6
  203.     WHILE numberOfDays1463 > daysInMonth%(mo, yr) - 1
  204.         numberOfDays1463 = numberOfDays1463 - daysInMonth%(mo, yr)
  205.         mo = mo + 1
  206.         IF mo = 13 THEN mo = 1: yr = yr + 1
  207.     WEND
  208.     ' date shound be day name date/month/year for Italians
  209.     ConvertLottoNumToDate$ = lottoday$(lottoNumX) + _TRIM$(STR$(numberOfDays1463 + 1)) + "/" + msNomeMesi(mo) + "/" + _TRIM$(STR$(yr))
  210.  
  211. FUNCTION lottoday$ (lottoNum)
  212.     IF lottoNum MOD 3 = 1 THEN lottoday$ = "Martedi, "
  213.     IF lottoNum MOD 3 = 2 THEN lottoday$ = "Giovedi, "
  214.     IF lottoNum MOD 3 = 0 THEN lottoday$ = "Sabato, "
  215.  
  216. FUNCTION daysInMonth% (mNum, yearNum)
  217.     DIM copyM, copyY
  218.     copyM = mNum
  219.     IF mNum = 13 THEN copyM = 1: copyY = yearNum + 1 ELSE copyY = yearNum
  220.     SELECT CASE copyM
  221.         CASE 1, 3, 5, 7, 8, 10, 12: daysInMonth% = 31
  222.         CASE 4, 6, 9, 11: daysInMonth% = 30
  223.         CASE 2: daysInMonth% = daysInFeb%(copyY)
  224.     END SELECT
  225.  
  226. FUNCTION daysInFeb% (yr) 'from Pete's calendar this is a very clear calc
  227.     DIM days AS INTEGER
  228.     IF yr MOD 4 = 0 THEN
  229.         IF yr MOD 100 = 0 THEN
  230.             IF yr MOD 400 = 0 THEN days = 29
  231.         ELSE
  232.             days = 29
  233.         END IF
  234.     END IF
  235.     IF days THEN daysInFeb% = days ELSE daysInFeb% = 28
  236.  

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
Re: help my
« Reply #117 on: July 17, 2020, 03:38:27 pm »
thanks perfect master

Spiffy enough for now:
Code: QB64: [Select]
  1. _TITLE "Lotto Data"
  2. 'for typo's   yep lineMun blah!  b+ mod of kiara mod of b+ 2020-07-15
  3. '2020-07-17 remove weekday names, move labels into there, fix bottom line up/down click
  4. '           fix function convertLottoNum2Date$ spelling
  5. '           clean out some redundant code loops
  6.  
  7. DEFINT A-Z ' everything is integer unless DIM or suffix
  8. CONST nRows = 11 '                          rows of 5 data points in each line of fileDat
  9.  
  10. DIM count '                                 for number of lines in the data file
  11.  
  12. DIM lineNum, lineNum2 '                     for tracking array access this is actual file line of data we are screening
  13. DIM a AS STRING, a2 AS STRING '             extraction lines of data
  14. DIM lottoNum, lottoNum2 '                   for extractions
  15. DIM lottoDate$, lottoDate2$ '               for the dates of lottos
  16.  
  17. ' user inputs
  18. DIM Q$ '                                    for INKEY$
  19. DIM mb, mx, my, oldmouse '                  Mouse stuff oldmouse is trick Steve McNeill showed us to get ONE mouse click!
  20.  
  21. ' these would normally go in SUBs or FUNCTIONs but we are using GOSUBs here
  22. DIM shiftRight, shiftRight2 '               screening data left and right, normally these would be CONSTANTs
  23. shiftRight = 11 '                           according to screen fit
  24. shiftRight2 = 65 '                          according to screen fit
  25.  
  26. DIM row, col, aPlace '                      for screening Data from a string
  27. DIM rowCnt, y, rowPlus '                    for loading lineDAT() from a file string
  28. DIM lineDAT(1 TO 5, 1 TO nRows) AS INTEGER 'an  array to load from each line from DAT
  29.  
  30. DIM i '                                     common use for indexing
  31.  
  32. DIM SHARED msNomeMesi(1 TO 12) AS STRING ' matrice di stringhe
  33. msNomeMesi(1) = "Gennaio"
  34. msNomeMesi(2) = "Febbraio"
  35. msNomeMesi(3) = "Marzo"
  36. msNomeMesi(4) = "Aprile"
  37. msNomeMesi(5) = "Maggio"
  38. msNomeMesi(6) = "Giugno"
  39. msNomeMesi(7) = "Luglio"
  40. msNomeMesi(8) = "Agosto"
  41. msNomeMesi(9) = "Settembre"
  42. msNomeMesi(10) = "Ottobre"
  43. msNomeMesi(11) = "Novembre"
  44. msNomeMesi(12) = "Dicembre"
  45.  
  46. DIM labels(1 TO 11) AS STRING ' setup screen labels for reporting data
  47. labels(1) = "BARI"
  48. labels(2) = "CAGLIARI"
  49. labels(3) = "FIRENZE"
  50. labels(4) = "GENOVA"
  51. labels(5) = "MILANO"
  52. labels(6) = "NAPOLI"
  53. labels(7) = "PALERMO"
  54. labels(8) = "ROMA"
  55. labels(9) = "TORINO"
  56. labels(10) = "VENEZIA"
  57. labels(11) = "NAZIONALE"
  58.  
  59. '-------------------------------- start Main setup get file data loaded into array
  60.  
  61. 'count lines in file
  62. OPEN "lotto.dat" FOR INPUT AS #1
  63.     INPUT #1, a
  64.     '          debug check inputs from file
  65.     'PRINT a
  66.     'INPUT " OK enter "; w$
  67.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  68.  
  69. 'now we now size of file so ready an array to load file Data
  70. DIM fileDAT(1 TO count) AS STRING
  71. OPEN "lotto.dat" FOR INPUT AS #1
  72. FOR i = 1 TO count
  73.     INPUT #1, a
  74.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  75.  
  76. 'get/set first line and get a data string from the FileDAT array  (left set on screen)
  77. lineNum = 1
  78. a = fileDAT(lineNum)
  79. lottoNum = VAL(LEFT$(a, 4))
  80. lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  81.  
  82. 'get/set right side start variables
  83. lineNum2 = 1
  84. a2 = fileDAT(lineNum2)
  85. lottoNum2 = VAL(LEFT$(a2, 4))
  86. lottoDate2$ = ConvertLottoNumToDate$(lottoNum2)
  87.  
  88. DO '------------------------------------------------ Main Loop User selects data to compare
  89.     CLS
  90.     Q$ = INKEY$
  91.     IF Q$ = "+" THEN lineNum = lineNum + 1
  92.     IF Q$ = "-" THEN lineNum = lineNum - 1
  93.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum2 = lineNum2 + 1
  94.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum2 = lineNum2 - 1
  95.  
  96.     mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  97.     'LOCATE 3, 1: PRINT mx, my
  98.     IF mb AND oldmouse = 0 AND my > 24 THEN ' <<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  99.         '_DELAY .25 '        just one click please!
  100.         IF 3 <= mx AND mx <= 11 THEN lineNum = lineNum + 1
  101.         IF 14 <= mx AND mx <= 23 THEN lineNum = lineNum - 1
  102.         IF 56 <= mx AND mx <= 64 THEN lineNum2 = lineNum2 + 1
  103.         IF 67 <= mx AND mx <= 76 THEN lineNum2 = lineNum2 - 1
  104.     END IF
  105.     oldmouse = _MOUSEBUTTON(1) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  106.     IF lineNum > count THEN lineNum = 1
  107.     IF lineNum < 1 THEN lineNum = count
  108.     IF lineNum2 > count THEN lineNum2 = 1
  109.     IF lineNum2 < 1 THEN lineNum2 = count
  110.  
  111.     'get new data line
  112.     a = fileDAT(lineNum) 'left side data
  113.     lottoNum = VAL(LEFT$(a, 4))
  114.     lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  115.  
  116.     a2 = fileDAT(lineNum2) 'right side data
  117.     lottoNum2 = VAL(LEFT$(a2, 4))
  118.     lottoDate2$ = ConvertLottoNumToDate$(lottoNum2)
  119.  
  120.     'print out the data from the new line
  121.     GOSUB labelScreen
  122.     GOSUB screenDataLine
  123.     GOSUB loadLineDAT_Mark30s
  124.     _DISPLAY
  125.     _LIMIT 30
  126.  
  127. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  128. rowCnt = 1: y = 1
  129. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  130.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  131.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  132.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  133. COLOR 9 'blue marker  seacrh through columes for  30's
  134. FOR col = 1 TO 5 'for each of the columes of data
  135.     FOR row = 1 TO 10 'for each of the rows of dat
  136.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  137.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  138.                 LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, row));
  139.                 LOCATE rowPlus * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, rowPlus));
  140.             END IF
  141.         NEXT
  142.     NEXT
  143. ''----------------------------- plug in new color routine here for right side ???
  144. 'rowCnt = 1: y = 1
  145. 'FOR i = 5 TO LEN(a2) STEP 2 ' is marking off the start of each data 2 digit integer
  146. '    lineDAT(rowCnt, y) = VAL(MID$(a2, i, 2)) 'convert data item to integer
  147. '    rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  148. '    IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  149. 'NEXT
  150. 'COLOR 9 'blue marker  seacrh through columes for  30's
  151. 'FOR col = 1 TO 5 'for each of the columes of data
  152. '    FOR row = 1 TO 10 'for each of the rows of dat
  153. '        FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  154. '            'IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  155. '            '    LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, row));
  156. '            '    LOCATE rowPlus * 2 + 1, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, rowPlus));
  157. '            'END IF
  158. '        NEXT
  159. '    NEXT
  160. 'NEXT
  161.  
  162. screenDataLine:
  163. LOCATE 1, 1
  164. PRINT lottoNum; lottoDate$;
  165. LOCATE 1, 48
  166. PRINT lottoNum2; lottoDate2$;
  167. aPlace = 5
  168. FOR row = 1 TO 11
  169.     FOR col = 1 TO 5
  170.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2); ' Left side
  171.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT MID$(a2, aPlace, 2); '<< a2 now Right Side
  172.         aPlace = aPlace + 2
  173.     NEXT
  174.  
  175. labelScreen:
  176. FOR i = 1 TO 11
  177.     LOCATE i * 2 + 1, 1: PRINT labels(i)
  178.     LOCATE i * 2 + 1, 55: PRINT labels(i)
  179. LOCATE 25, 1
  180. PRINT "  Fino / Up  Giu / Down        : Fare clic su :        Fino / Up  Giu / Down";
  181. '      12345678901234567890123456789012345678901234567890123456789012345678901234567890
  182. '               1         2         3         4         5         6         7         8
  183.  
  184. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  185.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  186.  
  187. FUNCTION diff30in90 (a, b) 'default integers a-z
  188.     DIM hi, lo
  189.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  190.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  191.     IF hi - lo = 30 THEN
  192.         diff30in90 = -1
  193.     ELSE
  194.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  195.     END IF
  196.  
  197. ' -----------------------------------------------------  Convert Lotto Num to Date Function and helpers
  198. FUNCTION ConvertLottoNumToDate$ (lottoNumX)
  199.     DIM numberOfDays1463, yr, mo
  200.     numberOfDays1463 = INT(lottoNumX - 1463) / 3 * 7
  201.     yr = 2017
  202.     mo = 6
  203.     WHILE numberOfDays1463 > daysInMonth%(mo, yr) - 1
  204.         numberOfDays1463 = numberOfDays1463 - daysInMonth%(mo, yr)
  205.         mo = mo + 1
  206.         IF mo = 13 THEN mo = 1: yr = yr + 1
  207.     WEND
  208.     ' date shound be day name date/month/year for Italians
  209.     ConvertLottoNumToDate$ = lottoday$(lottoNumX) + _TRIM$(STR$(numberOfDays1463 + 1)) + "/" + msNomeMesi(mo) + "/" + _TRIM$(STR$(yr))
  210.  
  211. FUNCTION lottoday$ (lottoNum)
  212.     IF lottoNum MOD 3 = 1 THEN lottoday$ = "Martedi, "
  213.     IF lottoNum MOD 3 = 2 THEN lottoday$ = "Giovedi, "
  214.     IF lottoNum MOD 3 = 0 THEN lottoday$ = "Sabato, "
  215.  
  216. FUNCTION daysInMonth% (mNum, yearNum)
  217.     DIM copyM, copyY
  218.     copyM = mNum
  219.     IF mNum = 13 THEN copyM = 1: copyY = yearNum + 1 ELSE copyY = yearNum
  220.     SELECT CASE copyM
  221.         CASE 1, 3, 5, 7, 8, 10, 12: daysInMonth% = 31
  222.         CASE 4, 6, 9, 11: daysInMonth% = 30
  223.         CASE 2: daysInMonth% = daysInFeb%(copyY)
  224.     END SELECT
  225.  
  226. FUNCTION daysInFeb% (yr) 'from Pete's calendar this is a very clear calc
  227.     DIM days AS INTEGER
  228.     IF yr MOD 4 = 0 THEN
  229.         IF yr MOD 100 = 0 THEN
  230.             IF yr MOD 400 = 0 THEN days = 29
  231.         ELSE
  232.             days = 29
  233.         END IF
  234.     END IF
  235.     IF days THEN daysInFeb% = days ELSE daysInFeb% = 28
  236.  

I try to learn and I saw that I made many mistakes changing everything
and I had done so I don't know if I was wrong to do this
I show you the code that I tried to modify
even if you say it is badly modified, it works

Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!  b+ mod of kiara mod of b+ 2020-07-15
  2.  
  3. DEFINT A-Z ' everything is integer unless DIM or suffix
  4. CONST nRows = 11 'rows of 5 data points in each line of fileDat
  5. DIM a AS STRING, a2 AS STRING, count, i, lineNum, lineNum2 ' for file and array access
  6. DIM Q$ '                             for INKEY$
  7. DIM row, col, aPlace '               for screening Data from a string
  8. DIM rowCnt, y, rowPlus '       for loading lineDAT() from a file string
  9. DIM lineDAT(1 TO 5, 1 TO nRows) AS INTEGER 'an  array to load from each line from DAT
  10. DIM shiftRight
  11. DIM shiftRight2
  12. DIM mb, mx, my, oldmouse ' oldmouse is trick Steve McNeill showed us to get ONE mouse click!
  13. DIM lottoNum, lottoNum2
  14. '---------------------------------------------------------------------------------------------------
  15. DIM SHARED msNomeMesi(12) AS STRING ' matrice di stringhe
  16. msNomeMesi(1) = "Gennaio"
  17. msNomeMesi(2) = "Febbraio"
  18. msNomeMesi(3) = "Marzo"
  19. msNomeMesi(4) = "Aprile"
  20. msNomeMesi(5) = "Maggio"
  21. msNomeMesi(6) = "Giugno"
  22. msNomeMesi(7) = "Luglio"
  23. msNomeMesi(8) = "Agosto"
  24. msNomeMesi(9) = "Settembre"
  25. msNomeMesi(10) = "Ottobre"
  26. msNomeMesi(11) = "Novembre"
  27. msNomeMesi(12) = "Dicembre"
  28.  
  29. DIM SHARED msSettimana(7) AS STRING ' matrice di stringhe
  30. msSettimana(1) = "Domenica"
  31. msSettimana(2) = "Lunedi"
  32. msSettimana(3) = "Martedi"
  33. msSettimana(4) = "Mercoledi"
  34. msSettimana(5) = "Giovedi"
  35. msSettimana(6) = "Venerdi"
  36. msSettimana(7) = "Sabato"
  37.  
  38.  
  39.  
  40. '-------------------------------------------------------------------------------------------------
  41. shiftRight2 = 65
  42. shiftRight = 11
  43.  
  44.  
  45. 'count lines in file
  46. OPEN "lotto.dat" FOR INPUT AS #1
  47.     INPUT #1, a
  48.     '          debug check inputs from file
  49.     'PRINT a
  50.     'INPUT " OK enter "; w$
  51.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  52.  
  53. 'now we now size of file so ready an array to load file Data
  54. DIM fileDAT(1 TO count) AS STRING
  55. OPEN "lotto.dat" FOR INPUT AS #1
  56. FOR i = 1 TO count
  57.     INPUT #1, a
  58.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  59.  
  60. ' NOW all the data if loaded into fileDAT() array, 480 strings of Lottory data
  61.  
  62. GOSUB labelScreen
  63.  
  64. 'set first line and get a data string from the FileDAT array
  65. lineNum = 1
  66. a = fileDAT(lineNum)
  67. lineNum2 = 1
  68. a2 = fileDAT(lineNum2)
  69. lottoNum = 1465
  70. lottoNum2 = 1465
  71.     CLS
  72.     Q$ = INKEY$
  73.     IF Q$ = "+" THEN lottoNum = lottoNum + 1
  74.     IF Q$ = "-" THEN lottoNum = lottoNum - 1
  75.     IF Q$ = CHR$(0) + CHR$(72) THEN lottoNum2 = lottoNum2 + 1
  76.     IF Q$ = CHR$(0) + CHR$(80) THEN lottoNum2 = lottoNum2 - 1
  77.  
  78.     IF Q$ = "+" THEN lineNum = lineNum + 1
  79.     IF Q$ = "-" THEN lineNum = lineNum - 1
  80.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum2 = lineNum2 + 1
  81.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum2 = lineNum2 - 1
  82.  
  83.     mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  84.     'LOCATE 3, 1: PRINT mx, my
  85.     IF mb AND oldmouse = 0 AND my > 24 THEN ' <<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  86.         '_DELAY .25 '        just one click please!
  87.         IF 17 <= mx AND mx <= 25 THEN lineNum = lineNum + 1
  88.         IF 28 <= mx AND mx <= 37 THEN lineNum = lineNum - 1
  89.         IF 44 <= mx AND mx <= 52 THEN lineNum2 = lineNum2 + 1
  90.         IF 55 <= mx AND mx <= 64 THEN lineNum2 = lineNum2 - 1
  91.     END IF
  92.     oldmouse = _MOUSEBUTTON(1) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  93.     IF lineNum2 > count THEN lineNum2 = 1
  94.     IF lineNum2 < 1 THEN lineNum2 = count
  95.  
  96.     IF lineNum > count THEN lineNum = 1
  97.     IF lineNum < 1 THEN lineNum = count
  98.  
  99.     'get new data line
  100.     a = fileDAT(lineNum)
  101.  
  102.     a2 = fileDAT(lineNum2)
  103.     'print out the data from the new line
  104.  
  105.     GOSUB labelScreen
  106.     GOSUB screenDataLine
  107.     GOSUB loadLineDAT_Mark30s
  108.     _DISPLAY
  109.     _LIMIT 30
  110.  
  111. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  112. rowCnt = 1: y = 1
  113. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  114.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  115.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  116.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  117. COLOR 9 'blue marker  seacrh through columes for  30's
  118. FOR col = 1 TO 5 'for each of the columes of data
  119.     FOR row = 1 TO 10 'for each of the rows of dat
  120.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  121.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  122.                 LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, row));
  123.                 LOCATE rowPlus * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, rowPlus));
  124.             END IF
  125.         NEXT
  126.     NEXT
  127. '---------------------------------------------------- right side  a2 data line
  128. rowCnt = 1: y = 1
  129. FOR i = 5 TO LEN(a2) STEP 2 ' is marking off the start of each data 2 digit integer
  130.     lineDAT(rowCnt, y) = VAL(MID$(a2, i, 2)) 'convert data item to integer
  131.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  132.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  133. COLOR 9 'blue marker  seacrh through columes for  30's
  134. FOR col = 1 TO 5 'for each of the columes of data
  135.     FOR row = 1 TO 10 'for each of the rows of dat
  136.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  137.             ' IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  138.             'LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, row));
  139.             'LOCATE rowPlus * 2 + 1, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, rowPlus));
  140.             'END IF
  141.         NEXT
  142.     NEXT
  143.  
  144.  
  145. screenDataLine:
  146. LOCATE 1, 26
  147. PRINT LEFT$(a, 4)
  148. LOCATE 1, 1
  149. PRINT CovertLottoNumToDate$(lottoNum)
  150. LOCATE 1, 1
  151. 'PRINT "estraz: "; LEFT$(a, 4); '"  line:"; 'STR$(lineNum); ""
  152. aPlace = 5
  153. FOR row = 1 TO 11
  154.     FOR col = 1 TO 5
  155.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2);
  156.         aPlace = aPlace + 2
  157.     NEXT
  158. '-------------------------------------------------- Right side
  159. LOCATE 1, 48
  160. PRINT LEFT$(a2, 4)
  161. LOCATE 1, 55
  162. PRINT CovertLottoNumToDate$(lottoNum2)
  163. 'PRINT "estraz "; LEFT$(a2, 4); "   line:"; STR$(lineNum2); '<<<<<<<<<<<<<<< a2 now
  164. aPlace = 5
  165. FOR row = 1 TO 11
  166.     FOR col = 1 TO 5
  167.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT MID$(a2, aPlace, 2); '<<<<<<<<<<<<<<< a2 now
  168.         aPlace = aPlace + 2
  169.     NEXT
  170.  
  171. labelScreen:
  172. DIM labels(11) AS STRING ' setup screen labels for reporting data
  173. labels(1) = "BARI"
  174. labels(2) = "CAGLIARI"
  175. labels(3) = "FIRENZE"
  176. labels(4) = "GENOVA"
  177. labels(5) = "MILANO"
  178. labels(6) = "NAPOLI"
  179. labels(7) = "PALERMO"
  180. labels(8) = "ROMA"
  181. labels(9) = "TORINO"
  182. labels(10) = "VENEZIA"
  183. labels(11) = "NAZIONALE"
  184. FOR i = 1 TO 11
  185.     LOCATE i * 2 + 1, 1: PRINT labels(i)
  186. LOCATE 25, 1
  187. FOR i = 1 TO 11
  188.     LOCATE i * 2 + 1, 55: PRINT labels(i)
  189. LOCATE 25, 1
  190.  
  191.  
  192. PRINT " Fare clic su:  Fino / Up  Giu / Down      Fino / Up  Giu / Down";
  193. '      12345678901234567890123456789012345678901234567890123456789012345678901234567890
  194. '               1         2         3         4         5         6         7         8
  195.  
  196. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  197.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  198.  
  199. FUNCTION diff30in90 (a, b) 'default integers a-z
  200.     DIM hi, lo
  201.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  202.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  203.     IF hi - lo = 30 THEN
  204.         diff30in90 = -1
  205.     ELSE
  206.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  207.     END IF
  208.  
  209. FUNCTION CovertLottoNumToDate$ (lottoNumX)
  210.     DIM numberOfDays1463, yr, mo
  211.     numberOfDays1463 = INT(lottoNumX - 1463) / 3 * 7
  212.     yr = 2017
  213.     mo = 6
  214.     WHILE numberOfDays1463 > daysInMonth%(mo, yr) - 1
  215.         numberOfDays1463 = numberOfDays1463 - daysInMonth%(mo, yr)
  216.         mo = mo + 1
  217.         IF mo = 13 THEN mo = 1: yr = yr + 1
  218.     WEND
  219.     ' date shound be yr, m0, numberOfDays1465
  220.     CovertLottoNumToDate$ = lottoday$(lottoNumX) + _TRIM$(STR$(numberOfDays1463 + 1)) + "/" + msNomeMesi(mo) + "/" + _TRIM$(STR$(yr))
  221.  
  222. FUNCTION lottoday$ (lottoNum)
  223.     IF lottoNum MOD 3 = 1 THEN lottoday$ = "Martedi, "
  224.     IF lottoNum MOD 3 = 2 THEN lottoday$ = "Giovedi, "
  225.     IF lottoNum MOD 3 = 0 THEN lottoday$ = "Sabato, "
  226.  
  227. FUNCTION daysInMonth% (mNum, yearNum)
  228.     DIM copyM, copyY
  229.     copyM = mNum
  230.     IF mNum = 13 THEN copyM = 1: copyY = yearNum + 1 ELSE copyY = yearNum
  231.     SELECT CASE copyM
  232.         CASE 1, 3, 5, 7, 8, 10, 12: daysInMonth% = 31
  233.         CASE 4, 6, 9, 11: daysInMonth% = 30
  234.         CASE 2: daysInMonth% = daysInFeb%(copyY)
  235.     END SELECT
  236.  
  237. FUNCTION daysInFeb% (yr) 'from Pete's calendar this is a very clear calc
  238.     DIM days AS INTEGER
  239.     IF yr MOD 4 = 0 THEN
  240.         IF yr MOD 100 = 0 THEN
  241.             IF yr MOD 400 = 0 THEN days = 29
  242.         ELSE
  243.             days = 29
  244.         END IF
  245.     END IF
  246.     IF days THEN daysInFeb% = days ELSE daysInFeb% = 28
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  

you can see that it works dates go back and forth

but your code is better
but your code is better than mine

now I have to solve the problem to verify the game on the correct extraction
right extraction
the two missing elements of distance 30
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #118 on: July 17, 2020, 04:37:43 pm »
Quote
you can see that it works dates go back and forth

👍
YES! 

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #119 on: July 17, 2020, 05:17:30 pm »
Looking for 67 and 4 in a line on the right side for this pair of 30's on left side?
  [ You are not allowed to view this attachment ]  

Correct?