Author Topic: help my  (Read 41385 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #45 on: July 02, 2020, 07:19:40 pm »
Quote
an array would be a variable containing more content

only variable that can hold multiple values

Si Una variabile con molti valori indicizzati
yes, a variable with many indexed values


Quote
can I contain how many contents? is there a limit?

DIM ilMioArray(1 TO 20)  ' this allows the array ilMioArray() to hold 20 integers
questo permette all'array ilMioArray() di contenere 20 numeri interi

DIM ilMioArray(1 to 1000) 'this allows 1000 elements or integer
'questo permette 1000 elementi o numeri interi

You access each by the index in between ( ), the 5th one is ilMioArray(5)
Si accede ciascuno dall'indice in mezzo ( ), il quinto è ilMioArray(5)

To assign the 5th integer in ilMioArray() like this:
ilMioArray(5) = some integer say for instance 7
Per assegnare il quinto numero intero in ilMioArray() in questo modo:
ilMioArray(5) - alcuni numeri interi dicono per esempio 7

Assigning many values at once to many array variables is done usually with FOR loops and i for indice.
L'assegnazione di più valori contemporaneamente a molte variabili di matrice viene eseguita in genere con cicli FOR e i per l'indice.
For i = 1 to 20
    ilMioArray(i) = i  'this puts the i value into the array(i) variable
Next

like this:

index          variable      =  value
i = 1 then ilMioArray(1) = 1
i = 2 then ilMioArray(2) = 2
i = 3 then ilMioArray(3) = 3
i = 4 then ilMioArray(3) = 4
.
.
.
i = 19 then ilMioArray(19) = 19
i = 20 then ilMioArray(20) = 20



Quote
those on the right in the image what are they?

PRINT "modificare il contenuto della mia matrice  'modify my array contents"
FOR i = 1 to 20
    ilMioArray(i) = ilMioArray(i) ^ 2 + 1 ' al quadrato piu (+) 1   'squared plus 1
NEXT

x^2 = x * x  or 3^2 = 3*3 = 9  or 5^2 = 5*5 = 25  or 12^2 = 12*12 =144
       
index         variable       = value
i = 1 then ilMioArray(1) = 1^2 + 1 = 2
i = 2 then ilMioArray(2) = 2^2 + 1 = 5
i = 3 then ilMioArray(3) = 3^2 + 1 = 10
i = 4 then ilMioArray(3) = 4^2 + 1 = 17
.
.
.
i = 19 then ilMioArray(19) = 19^2 + 1 = 362
i = 20 then ilMioArray(20) = 20^2 + 1 = 401
« Last Edit: July 02, 2020, 07:33:26 pm by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: help my
« Reply #46 on: July 02, 2020, 07:40:06 pm »
One of the easiest ways for beginners to think of arrays is to think of them as variables with the same name, but different numbers.

Let's say I give you homework of:  "Ask 5 people to enter their name, and then tell them all hello in a single uninterrupted sentence."

Now, you could go this route:

Code: [Select]
INPUT "Please tell me your name"; name1$
INPUT "Please tell me your name"; name2$
INPUT "Please tell me your name"; name3$
INPUT "Please tell me your name"; name4$
INPUT "Please tell me your name"; name5$

PRINT "Hello"; name1$; "," ; name2$; ","; name3$; ","; name4$; ","; name5$

OR, you could use an array to store the names.

Code: [Select]
DIM nam(1 TO 5) AS STRING
FOR I = 1 TO 5
   INPUT "Please tell me your name"; nam(I)
NEXT

PRINT "Hello ";
FOR I = 1 TO 5
    PRINT ","; nam(I);
NEXT

Now, with just 5 names, the code isn't very different in size or complexity, but change that to, "Get 500 people to give you their names"....

Arrays basically are nothing more than just a simple way to stick numbers to the end of variables, to allow for ease of mass handling them.  name1, name2, name3, name4, name5, nameN all are handled in one simple DIM nam(1 TO N) statement.  ;)
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: help my
« Reply #47 on: July 02, 2020, 07:47:18 pm »
Quote

later you said to load a file into an array

how can i upload it?

Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!
  2.  
  3. DEFINT A-Z 'everything is integer unless DIM or suffix
  4.  
  5. DIM a AS STRING, count, i, lineNum, Q$, num AS INTEGER
  6.  
  7. 'count lines in file  contare le righe nel file
  8. OPEN "lotto.dat" FOR INPUT AS #1
  9.     INPUT #1, a
  10.     'PRINT a
  11.     'INPUT " OK enter "; w$
  12.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  13.  
  14. 'now we know the size of the file so we are ready to DIM an array
  15. 'ora sappiamo la dimensione del file in modo da essere pronti a DIM un array
  16. DIM fileDAT(1 TO count) AS STRING
  17. OPEN "lotto.dat" FOR INPUT AS #1
  18. FOR i = 1 TO count
  19.     INPUT #1, a
  20.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  21.  
« Last Edit: July 02, 2020, 07:55:36 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #48 on: July 02, 2020, 09:48:50 pm »
There is light at end of tunnel but it's a little advanced.
  [ You are not allowed to view this attachment ]  

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
Re: help my
« Reply #49 on: July 03, 2020, 03:40:27 am »
thanks to you too good explanation

One of the easiest ways for beginners to think of arrays is to think of them as variables with the same name, but different numbers.

Let's say I give you homework of:  "Ask 5 people to enter their name, and then tell them all hello in a single uninterrupted sentence."

Now, you could go this route:

Code: [Select]
INPUT "Please tell me your name"; name1$
INPUT "Please tell me your name"; name2$
INPUT "Please tell me your name"; name3$
INPUT "Please tell me your name"; name4$
INPUT "Please tell me your name"; name5$

PRINT "Hello"; name1$; "," ; name2$; ","; name3$; ","; name4$; ","; name5$

OR, you could use an array to store the names.

Code: [Select]
DIM nam(1 TO 5) AS STRING
FOR I = 1 TO 5
   INPUT "Please tell me your name"; nam(I)
NEXT

PRINT "Hello ";
FOR I = 1 TO 5
    PRINT ","; nam(I);
NEXT

Now, with just 5 names, the code isn't very different in size or complexity, but change that to, "Get 500 people to give you their names"....

Arrays basically are nothing more than just a simple way to stick numbers to the end of variables, to allow for ease of mass handling them.  name1, name2, name3, name4, name5, nameN all are handled in one simple DIM nam(1 TO N) statement.  ;)
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
Re: help my
« Reply #50 on: July 03, 2020, 03:41:35 am »
now I am entering the variable you are a true master of qb64

Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!
  2.  
  3. DEFINT A-Z 'everything is integer unless DIM or suffix
  4.  
  5. DIM a AS STRING, count, i, lineNum, Q$, num AS INTEGER
  6.  
  7. 'count lines in file  contare le righe nel file
  8. OPEN "lotto.dat" FOR INPUT AS #1
  9.     INPUT #1, a
  10.     'PRINT a
  11.     'INPUT " OK enter "; w$
  12.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  13.  
  14. 'now we know the size of the file so we are ready to DIM an array
  15. 'ora sappiamo la dimensione del file in modo da essere pronti a DIM un array
  16. DIM fileDAT(1 TO count) AS STRING
  17. OPEN "lotto.dat" FOR INPUT AS #1
  18. FOR i = 1 TO count
  19.     INPUT #1, a
  20.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  21.  
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
Re: help my
« Reply #51 on: July 03, 2020, 04:04:24 am »
gives me an error where am I wrong I inserted the arrays wrong?

where am i wrong?

Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!
  2.  
  3. DEFINT A-Z 'everything is integer unless DIM or suffix
  4.  
  5. DIM a AS STRING, count, i, lineNum, Q$, num AS INTEGER
  6.  
  7. 'count lines in file  contare le righe nel file
  8. OPEN "lotto.dat" FOR INPUT AS #1
  9.     INPUT #1, a
  10.     'PRINT a
  11.     'INPUT " OK enter "; w$
  12.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  13.  
  14. 'now we know the size of the file so we are ready to DIM an array
  15. 'ora sappiamo la dimensione del file in modo da essere pronti a DIM un array
  16. DIM fileDAT(1 TO count) AS STRING
  17. OPEN "lotto.dat" FOR INPUT AS #1
  18. FOR i = 1 TO count
  19.     INPUT #1, a
  20.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  21. 'CLS: PRINT count '480 lines
  22. 'END
  23. 'CLS
  24.  
  25. LOCATE 1, 1
  26. PRINT "BARI"
  27. LOCATE 3, 1
  28. PRINT "CAGLIARI"
  29. LOCATE 5, 1
  30. PRINT "FIRENZE"
  31. LOCATE 7, 1
  32. PRINT "GENOVA"
  33. LOCATE 9, 1
  34. PRINT "MILANO"
  35. LOCATE 11, 1
  36. PRINT "NAPOLI"
  37. LOCATE 13, 1
  38. PRINT "PALERMO"
  39. LOCATE 15, 1
  40. PRINT "ROMA"
  41. LOCATE 17, 1
  42. PRINT "TORINO"
  43. LOCATE 19, 1
  44. PRINT "VENEZIA"
  45. LOCATE 21, 1
  46. PRINT "NAZIONALE"
  47.  
  48.  
  49. LOCATE 23, 1: COLOR 4
  50. PRINT " + to move on"
  51. LOCATE 23, 16: COLOR 3
  52. PRINT "- to back"
  53.  
  54. lineNum = 1
  55. GOSUB get_a
  56.  
  57.  
  58.  
  59.     Q$ = INKEY$
  60.     IF Q$ = "+" THEN lineNum = lineNum + 1
  61.     IF lineNum > count THEN lineNum = 1
  62.  
  63.     IF Q$ = "-" THEN lineNum = lineNum - 1
  64.     IF lineNum < 1 THEN lineNum = count
  65.  
  66.     GOSUB get_a
  67.  
  68.  
  69.     LOCATE 1, 34
  70.     PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum)
  71.  
  72.     REM bari
  73.     LOCATE 1, 13
  74.     PRINT fileDAT(i)
  75.     LOCATE 1, 16
  76.     PRINT fileDAT(i)
  77.     LOCATE 1, 19
  78.     PRINT fileDAT(i)
  79.     LOCATE 1, 22
  80.     PRINT fileDAT(i)
  81.     LOCATE 1, 25
  82.     PRINT fileDAT(i)
  83.  
  84.     REM cagliari
  85.     LOCATE 3, 13
  86.     PRINT fileDAT(i)
  87.     LOCATE 3, 16
  88.     PRINT fileDAT(i)
  89.     LOCATE 3, 19
  90.     PRINT fileDAT(i)
  91.     LOCATE 3, 22
  92.     PRINT fileDAT(i)
  93.     LOCATE 3, 25
  94.     PRINT fileDAT(i)
  95.  
  96.     REM firenze
  97.     LOCATE 5, 13
  98.     PRINT fileDAT(i)
  99.     LOCATE 5, 16
  100.     PRINT fileDAT(i)
  101.     LOCATE 5, 19
  102.     PRINT fileDAT(i)
  103.     LOCATE 5, 22
  104.     PRINT fileDAT(i)
  105.     LOCATE 5, 25
  106.     PRINT fileDAT(i)
  107.  
  108.     REM genova
  109.     LOCATE 7, 13
  110.     PRINT fileDAT(i)
  111.     LOCATE 7, 16
  112.     PRINT fileDAT(i)
  113.     LOCATE 7, 19
  114.     PRINT fileDAT(i)
  115.     LOCATE 7, 22
  116.     PRINT fileDAT(i)
  117.     LOCATE 7, 25
  118.     PRINT fileDAT(i)
  119.  
  120.     REM milano
  121.     LOCATE 9, 13
  122.     PRINT fileDAT(i)
  123.     LOCATE 9, 16
  124.     PRINT fileDAT(i)
  125.     LOCATE 9, 19
  126.     PRINT fileDAT(i)
  127.     LOCATE 9, 22
  128.     PRINT fileDAT(i)
  129.     LOCATE 9, 25
  130.     PRINT fileDAT(i)
  131.  
  132.     REM napoli
  133.     LOCATE 11, 13
  134.     PRINT fileDAT(i)
  135.     LOCATE 11, 16
  136.     PRINT fileDAT(i)
  137.     LOCATE 11, 19
  138.     PRINT fileDAT(i)
  139.     LOCATE 11, 22
  140.     PRINT fileDAT(i)
  141.     LOCATE 11, 25
  142.     PRINT fileDAT(i)
  143.  
  144.     REM palermo
  145.     LOCATE 13, 13
  146.     PRINT fileDAT(i)
  147.     LOCATE 13, 16
  148.     PRINT fileDAT(i)
  149.     LOCATE 13, 19
  150.     PRINT fileDAT(i)
  151.     LOCATE 13, 22
  152.     PRINT fileDAT(i)
  153.     LOCATE 13, 25
  154.     PRINT fileDAT(i)
  155.  
  156.     REM roma
  157.     LOCATE 15, 13
  158.     PRINT fileDAT(i)
  159.     LOCATE 15, 16
  160.     PRINT fileDAT(i)
  161.     LOCATE 15, 19
  162.     PRINT fileDAT(i)
  163.     LOCATE 15, 22
  164.     PRINT fileDAT(i)
  165.     LOCATE 15, 25
  166.     PRINT fileDAT(i)
  167.  
  168.     REM torino
  169.     LOCATE 17, 13
  170.     PRINT fileDAT(i)
  171.     LOCATE 17, 16
  172.     PRINT fileDAT(i)
  173.     LOCATE 17, 19
  174.     PRINT fileDAT(i)
  175.     LOCATE 17, 22
  176.     PRINT fileDAT(i)
  177.     LOCATE 17, 25
  178.     PRINT fileDAT(i)
  179.  
  180.     REM venezia
  181.     LOCATE 19, 13
  182.     PRINT fileDAT(i)
  183.     LOCATE 19, 16
  184.     PRINT fileDAT(i)
  185.     LOCATE 19, 19
  186.     PRINT fileDAT(i)
  187.     LOCATE 19, 22
  188.     PRINT fileDAT(i)
  189.     LOCATE 19, 25
  190.     PRINT fileDAT(i)
  191.  
  192.     REM nazionale
  193.     LOCATE 21, 13
  194.     PRINT fileDAT(i)
  195.     LOCATE 21, 16
  196.     PRINT fileDAT(i)
  197.     LOCATE 21, 19
  198.     PRINT fileDAT(i)
  199.     LOCATE 21, 22
  200.     PRINT fileDAT(i)
  201.     LOCATE 21, 25
  202.     PRINT fileDAT(i)
  203.  
  204.     _LIMIT 30
  205.  
  206.  
  207. 'this sub retrieves a line number from file  the hard way
  208. get_a:
  209. num = 0
  210. OPEN "lotto.dat" FOR INPUT AS #1
  211.     INPUT #1, a
  212.     IF LEN(_TRIM$(a)) THEN num = num + 1
  213.     IF num = lineNum THEN EXIT WHILE 'a is set on line we want
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: help my
« Reply #52 on: July 03, 2020, 07:21:40 am »
Hi Kiara87
fine exercise to write a lotto program.

about
Quote
gives me an error where am I wrong I inserted the arrays wrong?

where am i wrong?

can you be more specific?
In the bottom part of window of QB64 IDE there is a feedback message about the error? Or do you get error on runtime after pressing F5?
thanks for clearer informations
Programming isn't difficult, only it's  consuming time and coffee

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
Re: help my
« Reply #53 on: July 03, 2020, 08:28:19 am »
I leave the image as an attachment
putting this code gives me error inserting array

Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!
  2.  
  3. DEFINT A-Z 'everything is integer unless DIM or suffix
  4.  
  5. DIM a AS STRING, count, i, lineNum, Q$, num AS INTEGER
  6.  
  7. 'count lines in file  contare le righe nel file
  8. OPEN "lotto.dat" FOR INPUT AS #1
  9.     INPUT #1, a
  10.     'PRINT a
  11.     'INPUT " OK enter "; w$
  12.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  13.  
  14. 'now we know the size of the file so we are ready to DIM an array
  15. 'ora sappiamo la dimensione del file in modo da essere pronti a DIM un array
  16. DIM fileDAT(1 TO count) AS STRING
  17. OPEN "lotto.dat" FOR INPUT AS #1
  18. FOR i = 1 TO count
  19.     INPUT #1, a
  20.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  21. 'CLS: PRINT count '480 lines
  22. 'END
  23. 'CLS
  24.  
  25. LOCATE 1, 1
  26. PRINT "BARI"
  27. LOCATE 3, 1
  28. PRINT "CAGLIARI"
  29. LOCATE 5, 1
  30. PRINT "FIRENZE"
  31. LOCATE 7, 1
  32. PRINT "GENOVA"
  33. LOCATE 9, 1
  34. PRINT "MILANO"
  35. LOCATE 11, 1
  36. PRINT "NAPOLI"
  37. LOCATE 13, 1
  38. PRINT "PALERMO"
  39. LOCATE 15, 1
  40. PRINT "ROMA"
  41. LOCATE 17, 1
  42. PRINT "TORINO"
  43. LOCATE 19, 1
  44. PRINT "VENEZIA"
  45. LOCATE 21, 1
  46. PRINT "NAZIONALE"
  47.  
  48.  
  49. LOCATE 23, 1: COLOR 4
  50. PRINT " + to move on"
  51. LOCATE 23, 16: COLOR 3
  52. PRINT "- to back"
  53.  
  54. lineNum = 1
  55. GOSUB get_a
  56.  
  57.  
  58.  
  59.     Q$ = INKEY$
  60.     IF Q$ = "+" THEN lineNum = lineNum + 1
  61.     IF lineNum > count THEN lineNum = 1
  62.  
  63.     IF Q$ = "-" THEN lineNum = lineNum - 1
  64.     IF lineNum < 1 THEN lineNum = count
  65.  
  66.     GOSUB get_a
  67.  
  68.  
  69.     LOCATE 1, 34
  70.     PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum)
  71.  
  72.     REM bari
  73.     LOCATE 1, 13
  74.     PRINT fileDAT(i)
  75.     LOCATE 1, 16
  76.     PRINT fileDAT(i)
  77.     LOCATE 1, 19
  78.     PRINT fileDAT(i)
  79.     LOCATE 1, 22
  80.     PRINT fileDAT(i)
  81.     LOCATE 1, 25
  82.     PRINT fileDAT(i)
  83.  
  84.     REM cagliari
  85.     LOCATE 3, 13
  86.     PRINT fileDAT(i)
  87.     LOCATE 3, 16
  88.     PRINT fileDAT(i)
  89.     LOCATE 3, 19
  90.     PRINT fileDAT(i)
  91.     LOCATE 3, 22
  92.     PRINT fileDAT(i)
  93.     LOCATE 3, 25
  94.     PRINT fileDAT(i)
  95.  
  96.     REM firenze
  97.     LOCATE 5, 13
  98.     PRINT fileDAT(i)
  99.     LOCATE 5, 16
  100.     PRINT fileDAT(i)
  101.     LOCATE 5, 19
  102.     PRINT fileDAT(i)
  103.     LOCATE 5, 22
  104.     PRINT fileDAT(i)
  105.     LOCATE 5, 25
  106.     PRINT fileDAT(i)
  107.  
  108.     REM genova
  109.     LOCATE 7, 13
  110.     PRINT fileDAT(i)
  111.     LOCATE 7, 16
  112.     PRINT fileDAT(i)
  113.     LOCATE 7, 19
  114.     PRINT fileDAT(i)
  115.     LOCATE 7, 22
  116.     PRINT fileDAT(i)
  117.     LOCATE 7, 25
  118.     PRINT fileDAT(i)
  119.  
  120.     REM milano
  121.     LOCATE 9, 13
  122.     PRINT fileDAT(i)
  123.     LOCATE 9, 16
  124.     PRINT fileDAT(i)
  125.     LOCATE 9, 19
  126.     PRINT fileDAT(i)
  127.     LOCATE 9, 22
  128.     PRINT fileDAT(i)
  129.     LOCATE 9, 25
  130.     PRINT fileDAT(i)
  131.  
  132.     REM napoli
  133.     LOCATE 11, 13
  134.     PRINT fileDAT(i)
  135.     LOCATE 11, 16
  136.     PRINT fileDAT(i)
  137.     LOCATE 11, 19
  138.     PRINT fileDAT(i)
  139.     LOCATE 11, 22
  140.     PRINT fileDAT(i)
  141.     LOCATE 11, 25
  142.     PRINT fileDAT(i)
  143.  
  144.     REM palermo
  145.     LOCATE 13, 13
  146.     PRINT fileDAT(i)
  147.     LOCATE 13, 16
  148.     PRINT fileDAT(i)
  149.     LOCATE 13, 19
  150.     PRINT fileDAT(i)
  151.     LOCATE 13, 22
  152.     PRINT fileDAT(i)
  153.     LOCATE 13, 25
  154.     PRINT fileDAT(i)
  155.  
  156.     REM roma
  157.     LOCATE 15, 13
  158.     PRINT fileDAT(i)
  159.     LOCATE 15, 16
  160.     PRINT fileDAT(i)
  161.     LOCATE 15, 19
  162.     PRINT fileDAT(i)
  163.     LOCATE 15, 22
  164.     PRINT fileDAT(i)
  165.     LOCATE 15, 25
  166.     PRINT fileDAT(i)
  167.  
  168.     REM torino
  169.     LOCATE 17, 13
  170.     PRINT fileDAT(i)
  171.     LOCATE 17, 16
  172.     PRINT fileDAT(i)
  173.     LOCATE 17, 19
  174.     PRINT fileDAT(i)
  175.     LOCATE 17, 22
  176.     PRINT fileDAT(i)
  177.     LOCATE 17, 25
  178.     PRINT fileDAT(i)
  179.  
  180.     REM venezia
  181.     LOCATE 19, 13
  182.     PRINT fileDAT(i)
  183.     LOCATE 19, 16
  184.     PRINT fileDAT(i)
  185.     LOCATE 19, 19
  186.     PRINT fileDAT(i)
  187.     LOCATE 19, 22
  188.     PRINT fileDAT(i)
  189.     LOCATE 19, 25
  190.     PRINT fileDAT(i)
  191.  
  192.     REM nazionale
  193.     LOCATE 21, 13
  194.     PRINT fileDAT(i)
  195.     LOCATE 21, 16
  196.     PRINT fileDAT(i)
  197.     LOCATE 21, 19
  198.     PRINT fileDAT(i)
  199.     LOCATE 21, 22
  200.     PRINT fileDAT(i)
  201.     LOCATE 21, 25
  202.     PRINT fileDAT(i)
  203.  
  204.     _LIMIT 30
  205.  
  206.  
  207. 'this sub retrieves a line number from file  the hard way
  208. get_a:
  209. num = 0
  210. OPEN "lotto.dat" FOR INPUT AS #1
  211.     INPUT #1, a
  212.     IF LEN(_TRIM$(a)) THEN num = num + 1
  213.     IF num = lineNum THEN EXIT WHILE 'a is set on line we want
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
Hi Kiara87
fine exercise to write a lotto program.

about
can you be more specific?
In the bottom part of window of QB64 IDE there is a feedback message about the error? Or do you get error on runtime after pressing F5?
thanks for clearer informations
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 #54 on: July 03, 2020, 10:40:16 am »
I leave the image as an attachment
putting this code gives me error inserting array

Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!
  2.  
  3. DEFINT A-Z 'everything is integer unless DIM or suffix
  4.  
  5. DIM a AS STRING, count, i, lineNum, Q$, num AS INTEGER
  6.  
  7. 'count lines in file  contare le righe nel file
  8. OPEN "lotto.dat" FOR INPUT AS #1
  9.     INPUT #1, a
  10.     'PRINT a
  11.     'INPUT " OK enter "; w$
  12.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  13.  
  14. 'now we know the size of the file so we are ready to DIM an array
  15. 'ora sappiamo la dimensione del file in modo da essere pronti a DIM un array
  16. DIM fileDAT(1 TO count) AS STRING
  17. OPEN "lotto.dat" FOR INPUT AS #1
  18. FOR i = 1 TO count
  19.     INPUT #1, a
  20.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  21. 'CLS: PRINT count '480 lines
  22. 'END
  23. 'CLS
  24.  
  25. LOCATE 1, 1
  26. PRINT "BARI"
  27. LOCATE 3, 1
  28. PRINT "CAGLIARI"
  29. LOCATE 5, 1
  30. PRINT "FIRENZE"
  31. LOCATE 7, 1
  32. PRINT "GENOVA"
  33. LOCATE 9, 1
  34. PRINT "MILANO"
  35. LOCATE 11, 1
  36. PRINT "NAPOLI"
  37. LOCATE 13, 1
  38. PRINT "PALERMO"
  39. LOCATE 15, 1
  40. PRINT "ROMA"
  41. LOCATE 17, 1
  42. PRINT "TORINO"
  43. LOCATE 19, 1
  44. PRINT "VENEZIA"
  45. LOCATE 21, 1
  46. PRINT "NAZIONALE"
  47.  
  48.  
  49. LOCATE 23, 1: COLOR 4
  50. PRINT " + to move on"
  51. LOCATE 23, 16: COLOR 3
  52. PRINT "- to back"
  53.  
  54. lineNum = 1
  55. GOSUB get_a
  56.  
  57.  
  58.  
  59.     Q$ = INKEY$
  60.     IF Q$ = "+" THEN lineNum = lineNum + 1
  61.     IF lineNum > count THEN lineNum = 1
  62.  
  63.     IF Q$ = "-" THEN lineNum = lineNum - 1
  64.     IF lineNum < 1 THEN lineNum = count
  65.  
  66.     GOSUB get_a
  67.  
  68.  
  69.     LOCATE 1, 34
  70.     PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum)
  71.  
  72.     REM bari
  73.     LOCATE 1, 13
  74.     PRINT fileDAT(i)
  75.     LOCATE 1, 16
  76.     PRINT fileDAT(i)
  77.     LOCATE 1, 19
  78.     PRINT fileDAT(i)
  79.     LOCATE 1, 22
  80.     PRINT fileDAT(i)
  81.     LOCATE 1, 25
  82.     PRINT fileDAT(i)
  83.  
  84.     REM cagliari
  85.     LOCATE 3, 13
  86.     PRINT fileDAT(i)
  87.     LOCATE 3, 16
  88.     PRINT fileDAT(i)
  89.     LOCATE 3, 19
  90.     PRINT fileDAT(i)
  91.     LOCATE 3, 22
  92.     PRINT fileDAT(i)
  93.     LOCATE 3, 25
  94.     PRINT fileDAT(i)
  95.  
  96.     REM firenze
  97.     LOCATE 5, 13
  98.     PRINT fileDAT(i)
  99.     LOCATE 5, 16
  100.     PRINT fileDAT(i)
  101.     LOCATE 5, 19
  102.     PRINT fileDAT(i)
  103.     LOCATE 5, 22
  104.     PRINT fileDAT(i)
  105.     LOCATE 5, 25
  106.     PRINT fileDAT(i)
  107.  
  108.     REM genova
  109.     LOCATE 7, 13
  110.     PRINT fileDAT(i)
  111.     LOCATE 7, 16
  112.     PRINT fileDAT(i)
  113.     LOCATE 7, 19
  114.     PRINT fileDAT(i)
  115.     LOCATE 7, 22
  116.     PRINT fileDAT(i)
  117.     LOCATE 7, 25
  118.     PRINT fileDAT(i)
  119.  
  120.     REM milano
  121.     LOCATE 9, 13
  122.     PRINT fileDAT(i)
  123.     LOCATE 9, 16
  124.     PRINT fileDAT(i)
  125.     LOCATE 9, 19
  126.     PRINT fileDAT(i)
  127.     LOCATE 9, 22
  128.     PRINT fileDAT(i)
  129.     LOCATE 9, 25
  130.     PRINT fileDAT(i)
  131.  
  132.     REM napoli
  133.     LOCATE 11, 13
  134.     PRINT fileDAT(i)
  135.     LOCATE 11, 16
  136.     PRINT fileDAT(i)
  137.     LOCATE 11, 19
  138.     PRINT fileDAT(i)
  139.     LOCATE 11, 22
  140.     PRINT fileDAT(i)
  141.     LOCATE 11, 25
  142.     PRINT fileDAT(i)
  143.  
  144.     REM palermo
  145.     LOCATE 13, 13
  146.     PRINT fileDAT(i)
  147.     LOCATE 13, 16
  148.     PRINT fileDAT(i)
  149.     LOCATE 13, 19
  150.     PRINT fileDAT(i)
  151.     LOCATE 13, 22
  152.     PRINT fileDAT(i)
  153.     LOCATE 13, 25
  154.     PRINT fileDAT(i)
  155.  
  156.     REM roma
  157.     LOCATE 15, 13
  158.     PRINT fileDAT(i)
  159.     LOCATE 15, 16
  160.     PRINT fileDAT(i)
  161.     LOCATE 15, 19
  162.     PRINT fileDAT(i)
  163.     LOCATE 15, 22
  164.     PRINT fileDAT(i)
  165.     LOCATE 15, 25
  166.     PRINT fileDAT(i)
  167.  
  168.     REM torino
  169.     LOCATE 17, 13
  170.     PRINT fileDAT(i)
  171.     LOCATE 17, 16
  172.     PRINT fileDAT(i)
  173.     LOCATE 17, 19
  174.     PRINT fileDAT(i)
  175.     LOCATE 17, 22
  176.     PRINT fileDAT(i)
  177.     LOCATE 17, 25
  178.     PRINT fileDAT(i)
  179.  
  180.     REM venezia
  181.     LOCATE 19, 13
  182.     PRINT fileDAT(i)
  183.     LOCATE 19, 16
  184.     PRINT fileDAT(i)
  185.     LOCATE 19, 19
  186.     PRINT fileDAT(i)
  187.     LOCATE 19, 22
  188.     PRINT fileDAT(i)
  189.     LOCATE 19, 25
  190.     PRINT fileDAT(i)
  191.  
  192.     REM nazionale
  193.     LOCATE 21, 13
  194.     PRINT fileDAT(i)
  195.     LOCATE 21, 16
  196.     PRINT fileDAT(i)
  197.     LOCATE 21, 19
  198.     PRINT fileDAT(i)
  199.     LOCATE 21, 22
  200.     PRINT fileDAT(i)
  201.     LOCATE 21, 25
  202.     PRINT fileDAT(i)
  203.  
  204.     _LIMIT 30
  205.  
  206.  
  207. 'this sub retrieves a line number from file  the hard way
  208. get_a:
  209. num = 0
  210. OPEN "lotto.dat" FOR INPUT AS #1
  211.     INPUT #1, a
  212.     IF LEN(_TRIM$(a)) THEN num = num + 1
  213.     IF num = lineNum THEN EXIT WHILE 'a is set on line we want
  214.  
  215.  
  216.  

Oh no! hai sostituito l'intero fileDAT(i) in tutte le istruzioni PRINT! Yikes!!!
Oh no! you replaced the whole fileDAT(i) in all the PRINT statements! Yikes!!!
Ecco il piano generale:
1. contare il numero di righe nel file, ottenere il conteggio
2. DIM una matrice di stringhe alla dimensione del conteggio fileDAT(1 per contare)
3. Caricare i dati del file nel file di arrayDAT

Here is the general plan:
1. count number of lines in the file, get count
2. DIM an string array to the size of count fileDAT(1 to count)
3. Load the file data into the array fileDAT

Now understand each line, each index of fileDAT is just 1 line = the a string variable you use to display the lottery data on screen. We have it all worked out for the variable a string just set:
Ora capire ogni riga, ogni indice di fileDAT è solo 1 riga - la variabile di stringa che si utilizza per visualizzare i dati della lotteria sullo schermo. Abbiamo tutto elaborato per la variabile una stringa appena impostato
Code: QB64: [Select]
  1. a = lineDAT(lineNum)


Questa parte ottiene i dati di linea dal file, ma ora abbiamo il file caricato in un array
This part gets the line data out of the file but now we have the file loaded into an array
Code: QB64: [Select]
  1.     Q$ = INKEY$
  2.     IF Q$ = "+" THEN lineNum = lineNum + 1
  3.     IF lineNum > count THEN lineNum = 1
  4.  
  5.     IF Q$ = "-" THEN lineNum = lineNum - 1
  6.     IF lineNum < 1 THEN lineNum = count
  7.  
  8.     'GOSUB get_a  ' >>>>>>>>>>>>>>>>   this gets the line data from file don't need any more!!!
  9.  
  10.  

Non ho più bisogno di questo:
Don't need this any more:
Code: QB64: [Select]
  1. 'this sub retrieves a line number from file  the hard way
  2. get_a:
  3. num = 0
  4. OPEN "lotto.dat" FOR INPUT AS #1
  5.     INPUT #1, a
  6.     IF LEN(_TRIM$(a)) THEN num = num + 1
  7.     IF num = lineNum THEN EXIT WHILE 'a is set on line we want
  8.  

Ora con file caricato in un array tutto ciò che serve è questo:
Now with file loaded into an array all we need is this:
Code: QB64: [Select]
  1.     Q$ = INKEY$
  2.     IF Q$ = "+" THEN lineNum = lineNum + 1
  3.     IF lineNum > count THEN lineNum = 1
  4.  
  5.     IF Q$ = "-" THEN lineNum = lineNum - 1
  6.     IF lineNum < 1 THEN lineNum = count
  7.  
  8.     'GOSUB get_a  ' >>>>>>>>>>>>>>>>   this gets the line data from file don't need any more!!!
  9.    
  10.      a = fileDAT(lineNum)  ' <<<< we now get the file line out of the array!!!! yeah, hurrah, applause please ;-))
  11.  

Here is my working copy:
Ecco la mia copia di lavoro:
Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!
  2.  
  3. DEFINT A-Z 'everything is integer unless DIM or suffix
  4.  
  5. DIM a AS STRING, count, i, lineNum, Q$, num AS INTEGER
  6.  
  7. 'count lines in file  contare le righe nel file
  8. OPEN "lotto.dat" FOR INPUT AS #1
  9.     INPUT #1, a
  10.     'PRINT a
  11.     'INPUT " OK enter "; w$
  12.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  13.  
  14. 'now we now size of file so ready an array to load file Data, we know what size we need
  15. 'ora sappiamo la dimensione del file in modo da essere pronti a DIM un array
  16. DIM fileDAT(1 TO count) AS STRING
  17. OPEN "lotto.dat" FOR INPUT AS #1
  18. FOR i = 1 TO count
  19.     INPUT #1, a
  20.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  21.  
  22.  
  23. ' setup screen labels for reporting data
  24. LOCATE 1, 1
  25. PRINT "BARI"
  26. LOCATE 3, 1
  27. PRINT "CAGLIARI"
  28. LOCATE 5, 1
  29. PRINT "FIRENZE"
  30. LOCATE 7, 1
  31. PRINT "GENOVA"
  32. LOCATE 9, 1
  33. PRINT "MILANO"
  34. LOCATE 11, 1
  35. PRINT "NAPOLI"
  36. LOCATE 13, 1
  37. PRINT "PALERMO"
  38. LOCATE 15, 1
  39. PRINT "ROMA"
  40. LOCATE 17, 1
  41. PRINT "TORINO"
  42. LOCATE 19, 1
  43. PRINT "VENEZIA"
  44. LOCATE 21, 1
  45. PRINT "NAZIONALE"
  46. 'some directions
  47. LOCATE 23, 1
  48. PRINT " + to move on"
  49. LOCATE 23, 16
  50. PRINT "- to back"
  51.  
  52. 'set first line and get a data string from the FileDAT array
  53. lineNum = 1
  54. a = fileDAT(lineNum)
  55.     Q$ = INKEY$
  56.     IF Q$ = "+" THEN lineNum = lineNum + 1
  57.     IF lineNum > count THEN lineNum = 1
  58.     IF Q$ = "-" THEN lineNum = lineNum - 1
  59.     IF lineNum < 1 THEN lineNum = count
  60.     'get new data line
  61.     a = fileDAT(lineNum)
  62.  
  63.     'print out the data from the new line
  64.  
  65.  
  66.     LOCATE 1, 34
  67.     PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum)
  68.  
  69.     REM bari
  70.     LOCATE 1, 13
  71.     PRINT VAL(MID$(a, 5, 2))
  72.     LOCATE 1, 16
  73.     PRINT VAL(MID$(a, 7, 2))
  74.     LOCATE 1, 19
  75.     PRINT VAL(MID$(a, 9, 2))
  76.     LOCATE 1, 22
  77.     PRINT VAL(MID$(a, 11, 2))
  78.     LOCATE 1, 25
  79.     PRINT VAL(MID$(a, 13, 2))
  80.  
  81.     REM cagliari
  82.     LOCATE 3, 13
  83.     PRINT VAL(MID$(a, 15, 2))
  84.     LOCATE 3, 16
  85.     PRINT VAL(MID$(a, 17, 2))
  86.     LOCATE 3, 19
  87.     PRINT VAL(MID$(a, 19, 2))
  88.     LOCATE 3, 22
  89.     PRINT VAL(MID$(a, 21, 2))
  90.     LOCATE 3, 25
  91.     PRINT VAL(MID$(a, 23, 2))
  92.  
  93.     REM firenze
  94.     LOCATE 5, 13
  95.     PRINT VAL(MID$(a, 25, 2))
  96.     LOCATE 5, 16
  97.     PRINT VAL(MID$(a, 27, 2))
  98.     LOCATE 5, 19
  99.     PRINT VAL(MID$(a, 29, 2))
  100.     LOCATE 5, 22
  101.     PRINT VAL(MID$(a, 31, 2))
  102.     LOCATE 5, 25
  103.     PRINT VAL(MID$(a, 33, 2))
  104.  
  105.     REM genova
  106.     LOCATE 7, 13
  107.     PRINT VAL(MID$(a, 35, 2))
  108.     LOCATE 7, 16
  109.     PRINT VAL(MID$(a, 37, 2))
  110.     LOCATE 7, 19
  111.     PRINT VAL(MID$(a, 39, 2))
  112.     LOCATE 7, 22
  113.     PRINT VAL(MID$(a, 41, 2))
  114.     LOCATE 7, 25
  115.     PRINT VAL(MID$(a, 43, 2))
  116.  
  117.     REM milano
  118.     LOCATE 9, 13
  119.     PRINT VAL(MID$(a, 45, 2))
  120.     LOCATE 9, 16
  121.     PRINT VAL(MID$(a, 47, 2))
  122.     LOCATE 9, 19
  123.     PRINT VAL(MID$(a, 49, 2))
  124.     LOCATE 9, 22
  125.     PRINT VAL(MID$(a, 51, 2))
  126.     LOCATE 9, 25
  127.     PRINT VAL(MID$(a, 53, 2))
  128.  
  129.     REM napoli
  130.     LOCATE 11, 13
  131.     PRINT VAL(MID$(a, 55, 2))
  132.     LOCATE 11, 16
  133.     PRINT VAL(MID$(a, 57, 2))
  134.     LOCATE 11, 19
  135.     PRINT VAL(MID$(a, 59, 2))
  136.     LOCATE 11, 22
  137.     PRINT VAL(MID$(a, 61, 2))
  138.     LOCATE 11, 25
  139.     PRINT VAL(MID$(a, 63, 2))
  140.  
  141.     REM palermo
  142.     LOCATE 13, 13
  143.     PRINT VAL(MID$(a, 65, 2))
  144.     LOCATE 13, 16
  145.     PRINT VAL(MID$(a, 67, 2))
  146.     LOCATE 13, 19
  147.     PRINT VAL(MID$(a, 69, 2))
  148.     LOCATE 13, 22
  149.     PRINT VAL(MID$(a, 71, 2))
  150.     LOCATE 13, 25
  151.     PRINT VAL(MID$(a, 73, 2))
  152.  
  153.     REM roma
  154.     LOCATE 15, 13
  155.     PRINT VAL(MID$(a, 75, 2))
  156.     LOCATE 15, 16
  157.     PRINT VAL(MID$(a, 77, 2))
  158.     LOCATE 15, 19
  159.     PRINT VAL(MID$(a, 79, 2))
  160.     LOCATE 15, 22
  161.     PRINT VAL(MID$(a, 81, 2))
  162.     LOCATE 15, 25
  163.     PRINT VAL(MID$(a, 83, 2))
  164.  
  165.     REM torino
  166.     LOCATE 17, 13
  167.     PRINT VAL(MID$(a, 85, 2))
  168.     LOCATE 17, 16
  169.     PRINT VAL(MID$(a, 87, 2))
  170.     LOCATE 17, 19
  171.     PRINT VAL(MID$(a, 89, 2))
  172.     LOCATE 17, 22
  173.     PRINT VAL(MID$(a, 91, 2))
  174.     LOCATE 17, 25
  175.     PRINT VAL(MID$(a, 93, 2))
  176.  
  177.     REM venezia
  178.     LOCATE 19, 13
  179.     PRINT VAL(MID$(a, 95, 2))
  180.     LOCATE 19, 16
  181.     PRINT VAL(MID$(a, 97, 2))
  182.     LOCATE 19, 19
  183.     PRINT VAL(MID$(a, 99, 2))
  184.     LOCATE 19, 22
  185.     PRINT VAL(MID$(a, 101, 2))
  186.     LOCATE 19, 25
  187.     PRINT VAL(MID$(a, 103, 2))
  188.  
  189.     REM nazionale
  190.     LOCATE 21, 13
  191.     PRINT VAL(MID$(a, 105, 2))
  192.     LOCATE 21, 16
  193.     PRINT VAL(MID$(a, 107, 2))
  194.     LOCATE 21, 19
  195.     PRINT VAL(MID$(a, 109, 2))
  196.     LOCATE 21, 22
  197.     PRINT VAL(MID$(a, 111, 2))
  198.     LOCATE 21, 25
  199.     PRINT VAL(MID$(a, 113, 2))
  200.  
  201.     _LIMIT 30
  202.  
  203. FUNCTION diff30in90 (a, b) 'default integers a-z
  204.     DIM hi, lo
  205.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  206.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  207.     IF hi - lo = 30 THEN
  208.         diff30in90 = -1
  209.     ELSE
  210.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  211.     END IF
  212.  
  213.  
  214.  
  215.  

It may not seem like a great advancement but it is! It is a great real example of getting file contents into an array which is allot easier to work with that opening the file accessing a line and then closing again, doing that every time you hit the plus or minus key, yikes!

Potrebbe non sembrare un grande progresso, ma lo è! È un grande vero esempio di ottenere il contenuto del file in una matrice che è più facile lavorare con quella che apre il file accedendo a una riga e poi chiude di nuovo, facendo lo stesso tempo che si preme il tasto più o meno, yikes!

😊 I like the Italian translation for yikes!
« Last Edit: July 03, 2020, 11:16:04 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #55 on: July 03, 2020, 11:47:54 am »
Then I made this into a GOSUB to get it out of way when reading main programming execution:
Poi ho fatto questo in un GOSUB per farlo fuori strada durante la lettura di esecuzione di programmazione principale:
Code: QB64: [Select]
  1. ' setup screen labels for reporting data
  2. LOCATE 1, 1
  3. PRINT "BARI"
  4. LOCATE 3, 1
  5. PRINT "CAGLIARI"
  6. LOCATE 5, 1
  7. PRINT "FIRENZE"
  8. LOCATE 7, 1
  9. PRINT "GENOVA"
  10. LOCATE 9, 1
  11. PRINT "MILANO"
  12. LOCATE 11, 1
  13. PRINT "NAPOLI"
  14. LOCATE 13, 1
  15. PRINT "PALERMO"
  16. LOCATE 15, 1
  17. PRINT "ROMA"
  18. LOCATE 17, 1
  19. PRINT "TORINO"
  20. LOCATE 19, 1
  21. PRINT "VENEZIA"
  22. LOCATE 21, 1
  23. PRINT "NAZIONALE"
  24. 'some directions
  25. LOCATE 23, 1
  26. PRINT " + to move on"
  27. LOCATE 23, 16
  28. PRINT "- to back"
  29.  
Appena aggiunto "labelScreen:" all'inizio e "RETURN" nella parte inferiore e spostato il blocco di codice sotto l'istruzione end line.
Just added "labelScreen:" to the top and "RETURN" at the bottom and moved the code block under the END line statement.


Did the same move out of the way trick with this section:
Ha fatto lo stesso mossa fuori del trucco modo con questa sezione:
Code: QB64: [Select]
  1.     'print out the data from the new line
  2.     LOCATE 1, 34
  3.     PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum)
  4.  
  5.     REM bari
  6.     LOCATE 1, 13
  7.     PRINT VAL(MID$(a, 5, 2))
  8.     LOCATE 1, 16
  9.     PRINT VAL(MID$(a, 7, 2))
  10.     LOCATE 1, 19
  11.     PRINT VAL(MID$(a, 9, 2))
  12.     LOCATE 1, 22
  13.     PRINT VAL(MID$(a, 11, 2))
  14.     LOCATE 1, 25
  15.     PRINT VAL(MID$(a, 13, 2))
  16.  
  17.     REM cagliari
  18.     LOCATE 3, 13
  19.     PRINT VAL(MID$(a, 15, 2))
  20.     LOCATE 3, 16
  21.     PRINT VAL(MID$(a, 17, 2))
  22.     LOCATE 3, 19
  23.     PRINT VAL(MID$(a, 19, 2))
  24.     LOCATE 3, 22
  25.     PRINT VAL(MID$(a, 21, 2))
  26.     LOCATE 3, 25
  27.     PRINT VAL(MID$(a, 23, 2))
  28.  
  29.     REM firenze
  30.     LOCATE 5, 13
  31.     PRINT VAL(MID$(a, 25, 2))
  32.     LOCATE 5, 16
  33.     PRINT VAL(MID$(a, 27, 2))
  34.     LOCATE 5, 19
  35.     PRINT VAL(MID$(a, 29, 2))
  36.     LOCATE 5, 22
  37.     PRINT VAL(MID$(a, 31, 2))
  38.     LOCATE 5, 25
  39.     PRINT VAL(MID$(a, 33, 2))
  40.  
  41.     REM genova
  42.     LOCATE 7, 13
  43.     PRINT VAL(MID$(a, 35, 2))
  44.     LOCATE 7, 16
  45.     PRINT VAL(MID$(a, 37, 2))
  46.     LOCATE 7, 19
  47.     PRINT VAL(MID$(a, 39, 2))
  48.     LOCATE 7, 22
  49.     PRINT VAL(MID$(a, 41, 2))
  50.     LOCATE 7, 25
  51.     PRINT VAL(MID$(a, 43, 2))
  52.  
  53.     REM milano
  54.     LOCATE 9, 13
  55.     PRINT VAL(MID$(a, 45, 2))
  56.     LOCATE 9, 16
  57.     PRINT VAL(MID$(a, 47, 2))
  58.     LOCATE 9, 19
  59.     PRINT VAL(MID$(a, 49, 2))
  60.     LOCATE 9, 22
  61.     PRINT VAL(MID$(a, 51, 2))
  62.     LOCATE 9, 25
  63.     PRINT VAL(MID$(a, 53, 2))
  64.  
  65.     REM napoli
  66.     LOCATE 11, 13
  67.     PRINT VAL(MID$(a, 55, 2))
  68.     LOCATE 11, 16
  69.     PRINT VAL(MID$(a, 57, 2))
  70.     LOCATE 11, 19
  71.     PRINT VAL(MID$(a, 59, 2))
  72.     LOCATE 11, 22
  73.     PRINT VAL(MID$(a, 61, 2))
  74.     LOCATE 11, 25
  75.     PRINT VAL(MID$(a, 63, 2))
  76.  
  77.     REM palermo
  78.     LOCATE 13, 13
  79.     PRINT VAL(MID$(a, 65, 2))
  80.     LOCATE 13, 16
  81.     PRINT VAL(MID$(a, 67, 2))
  82.     LOCATE 13, 19
  83.     PRINT VAL(MID$(a, 69, 2))
  84.     LOCATE 13, 22
  85.     PRINT VAL(MID$(a, 71, 2))
  86.     LOCATE 13, 25
  87.     PRINT VAL(MID$(a, 73, 2))
  88.  
  89.     REM roma
  90.     LOCATE 15, 13
  91.     PRINT VAL(MID$(a, 75, 2))
  92.     LOCATE 15, 16
  93.     PRINT VAL(MID$(a, 77, 2))
  94.     LOCATE 15, 19
  95.     PRINT VAL(MID$(a, 79, 2))
  96.     LOCATE 15, 22
  97.     PRINT VAL(MID$(a, 81, 2))
  98.     LOCATE 15, 25
  99.     PRINT VAL(MID$(a, 83, 2))
  100.  
  101.     REM torino
  102.     LOCATE 17, 13
  103.     PRINT VAL(MID$(a, 85, 2))
  104.     LOCATE 17, 16
  105.     PRINT VAL(MID$(a, 87, 2))
  106.     LOCATE 17, 19
  107.     PRINT VAL(MID$(a, 89, 2))
  108.     LOCATE 17, 22
  109.     PRINT VAL(MID$(a, 91, 2))
  110.     LOCATE 17, 25
  111.     PRINT VAL(MID$(a, 93, 2))
  112.  
  113.     REM venezia
  114.     LOCATE 19, 13
  115.     PRINT VAL(MID$(a, 95, 2))
  116.     LOCATE 19, 16
  117.     PRINT VAL(MID$(a, 97, 2))
  118.     LOCATE 19, 19
  119.     PRINT VAL(MID$(a, 99, 2))
  120.     LOCATE 19, 22
  121.     PRINT VAL(MID$(a, 101, 2))
  122.     LOCATE 19, 25
  123.     PRINT VAL(MID$(a, 103, 2))
  124.  
  125.     REM nazionale
  126.     LOCATE 21, 13
  127.     PRINT VAL(MID$(a, 105, 2))
  128.     LOCATE 21, 16
  129.     PRINT VAL(MID$(a, 107, 2))
  130.     LOCATE 21, 19
  131.     PRINT VAL(MID$(a, 109, 2))
  132.     LOCATE 21, 22
  133.     PRINT VAL(MID$(a, 111, 2))
  134.     LOCATE 21, 25
  135.     PRINT VAL(MID$(a, 113, 2))
  136.  
I labeled it screenDataLine: and put RETURN at the bottom of it and moved it below END.
L'ho etichettato screenDataLine: e mettere RETURN nella parte inferiore di esso e spostato sotto END.

Then I called these two GOSUBs at same place in main code where they were before the move:
Poi ho chiamato questi due GOSUB nello stesso posto nel codice principale dove erano prima dello spostamento:
Code: QB64: [Select]
  1.     CLS
  2.     GOSUB labelScreen
  3.     GOSUB screenDataLine
  4.  
Oh I found out I had to CLS between call so old lineNum data gets cleared for next line of data.
Oh ho scoperto che ho dovuto CLS tra chiamata così vecchi dati lineNum viene cancellata per la prossima linea di dati.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #56 on: July 03, 2020, 11:53:50 am »
Here is the part of mastery of Basic, I converted the commented out code to the block of code above it in the GOSUB routine. I needed to do that to make it easy to process the 30's stuff.
Ecco la parte della padronanza di Basic, ho convertito il codice commentato al blocco di codice sopra di esso nella routine GOSUB. Avevo bisogno di farlo per rendere più facile l'elaborazione della roba degli anni '30.
Code: QB64: [Select]
  1. screenDataLine:
  2. LOCATE 1, 34
  3. PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum);
  4. aPlace = 5
  5. FOR row = 1 TO 11
  6.     FOR col = 1 TO 5
  7.         LOCATE row * 2, col * 3 - 2: PRINT MID$(a, aPlace, 2);
  8.         aPlace = aPlace + 2
  9.     NEXT
  10.  
  11. '=========================== the above does this ==============================
  12. 'LOCATE 1, 34
  13. 'PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum)
  14.  
  15. 'REM bari
  16. 'LOCATE 1, 13
  17. 'PRINT VAL(MID$(a, 5, 2))
  18. 'LOCATE 1, 16
  19. 'PRINT VAL(MID$(a, 7, 2))
  20. 'LOCATE 1, 19
  21. 'PRINT VAL(MID$(a, 9, 2))
  22. 'LOCATE 1, 22
  23. 'PRINT VAL(MID$(a, 11, 2))
  24. 'LOCATE 1, 25
  25. 'PRINT VAL(MID$(a, 13, 2))
  26.  
  27. 'REM cagliari
  28. 'LOCATE 3, 13
  29. 'PRINT VAL(MID$(a, 15, 2))
  30. 'LOCATE 3, 16
  31. 'PRINT VAL(MID$(a, 17, 2))
  32. 'LOCATE 3, 19
  33. 'PRINT VAL(MID$(a, 19, 2))
  34. 'LOCATE 3, 22
  35. 'PRINT VAL(MID$(a, 21, 2))
  36. 'LOCATE 3, 25
  37. 'PRINT VAL(MID$(a, 23, 2))
  38.  
  39. 'REM firenze
  40. 'LOCATE 5, 13
  41. 'PRINT VAL(MID$(a, 25, 2))
  42. 'LOCATE 5, 16
  43. 'PRINT VAL(MID$(a, 27, 2))
  44. 'LOCATE 5, 19
  45. 'PRINT VAL(MID$(a, 29, 2))
  46. 'LOCATE 5, 22
  47. 'PRINT VAL(MID$(a, 31, 2))
  48. 'LOCATE 5, 25
  49. 'PRINT VAL(MID$(a, 33, 2))
  50.  
  51. 'REM genova
  52. 'LOCATE 7, 13
  53. 'PRINT VAL(MID$(a, 35, 2))
  54. 'LOCATE 7, 16
  55. 'PRINT VAL(MID$(a, 37, 2))
  56. 'LOCATE 7, 19
  57. 'PRINT VAL(MID$(a, 39, 2))
  58. 'LOCATE 7, 22
  59. 'PRINT VAL(MID$(a, 41, 2))
  60. 'LOCATE 7, 25
  61. 'PRINT VAL(MID$(a, 43, 2))
  62.  
  63. 'REM milano
  64. 'LOCATE 9, 13
  65. 'PRINT VAL(MID$(a, 45, 2))
  66. 'LOCATE 9, 16
  67. 'PRINT VAL(MID$(a, 47, 2))
  68. 'LOCATE 9, 19
  69. 'PRINT VAL(MID$(a, 49, 2))
  70. 'LOCATE 9, 22
  71. 'PRINT VAL(MID$(a, 51, 2))
  72. 'LOCATE 9, 25
  73. 'PRINT VAL(MID$(a, 53, 2))
  74.  
  75. 'REM napoli
  76. 'LOCATE 11, 13
  77. 'PRINT VAL(MID$(a, 55, 2))
  78. 'LOCATE 11, 16
  79. 'PRINT VAL(MID$(a, 57, 2))
  80. 'LOCATE 11, 19
  81. 'PRINT VAL(MID$(a, 59, 2))
  82. 'LOCATE 11, 22
  83. 'PRINT VAL(MID$(a, 61, 2))
  84. 'LOCATE 11, 25
  85. 'PRINT VAL(MID$(a, 63, 2))
  86.  
  87. 'REM palermo
  88. 'LOCATE 13, 13
  89. 'PRINT VAL(MID$(a, 65, 2))
  90. 'LOCATE 13, 16
  91. 'PRINT VAL(MID$(a, 67, 2))
  92. 'LOCATE 13, 19
  93. 'PRINT VAL(MID$(a, 69, 2))
  94. 'LOCATE 13, 22
  95. 'PRINT VAL(MID$(a, 71, 2))
  96. 'LOCATE 13, 25
  97. 'PRINT VAL(MID$(a, 73, 2))
  98.  
  99. 'REM roma
  100. 'LOCATE 15, 13
  101. 'PRINT VAL(MID$(a, 75, 2))
  102. 'LOCATE 15, 16
  103. 'PRINT VAL(MID$(a, 77, 2))
  104. 'LOCATE 15, 19
  105. 'PRINT VAL(MID$(a, 79, 2))
  106. 'LOCATE 15, 22
  107. 'PRINT VAL(MID$(a, 81, 2))
  108. 'LOCATE 15, 25
  109. 'PRINT VAL(MID$(a, 83, 2))
  110.  
  111. 'REM torino
  112. 'LOCATE 17, 13
  113. 'PRINT VAL(MID$(a, 85, 2))
  114. 'LOCATE 17, 16
  115. 'PRINT VAL(MID$(a, 87, 2))
  116. 'LOCATE 17, 19
  117. 'PRINT VAL(MID$(a, 89, 2))
  118. 'LOCATE 17, 22
  119. 'PRINT VAL(MID$(a, 91, 2))
  120. 'LOCATE 17, 25
  121. 'PRINT VAL(MID$(a, 93, 2))
  122.  
  123. 'REM venezia
  124. 'LOCATE 19, 13
  125. 'PRINT VAL(MID$(a, 95, 2))
  126. 'LOCATE 19, 16
  127. 'PRINT VAL(MID$(a, 97, 2))
  128. 'LOCATE 19, 19
  129. 'PRINT VAL(MID$(a, 99, 2))
  130. 'LOCATE 19, 22
  131. 'PRINT VAL(MID$(a, 101, 2))
  132. 'LOCATE 19, 25
  133. 'PRINT VAL(MID$(a, 103, 2))
  134.  
  135. 'REM nazionale
  136. 'LOCATE 21, 13
  137. 'PRINT VAL(MID$(a, 105, 2))
  138. 'LOCATE 21, 16
  139. 'PRINT VAL(MID$(a, 107, 2))
  140. 'LOCATE 21, 19
  141. 'PRINT VAL(MID$(a, 109, 2))
  142. 'LOCATE 21, 22
  143. 'PRINT VAL(MID$(a, 111, 2))
  144. 'LOCATE 21, 25
  145. 'PRINT VAL(MID$(a, 113, 2))
  146. '========================================================================
  147.  
  148.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #57 on: July 03, 2020, 12:13:30 pm »
So far, functionally, I changed absolutely nothing BUT NOW I am setup to put the screened data into a 5 column X 11 row array to process the 30's.
Finora, funzionalmente, ho cambiato assolutamente nulla MA ora sono configurato per mettere i dati schermati in un array di righe X 11 di 5 colonne per elaborare il 30.


Put this at the top part of main code with the other DIM statements, make room for another array:
Mettere questo nella parte superiore del codice principale con le altre istruzioni DIM, fare spazio per un altro array:
Code: QB64: [Select]
  1. CONST nRows = 11
  2. DIM lineDAT(1 TO 5, 1 TO nRows) AS INTEGER 'an  array to load from each line from DAT

This code loads that array (might take a little more than Beginner skills) and uses it to get the 30's in a GOSUB:
Questo codice carica tale matrice (potrebbe richiedere un po 'più di abilità principianti) e lo usa per ottenere il 30's in un GOSUB:
Code: QB64: [Select]
  1. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  2. rowCnt = 1: y = 1
  3. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  4.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  5.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  6.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  7. COLOR 9 'blue marker  seacrh through columes for  30's
  8. FOR col = 1 TO 5 'for each of the columes of data
  9.     FOR row = 1 TO 10 'for each of the rows of dat
  10.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  11.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  12.                 LOCATE row * 2, col * 3 - 2: PRINT DD$(lineDAT(col, row));
  13.                 LOCATE rowPlus * 2, col * 3 - 2: PRINT DD$(lineDAT(col, rowPlus));
  14.             END IF
  15.         NEXT
  16.     NEXT
  17.  

Ho dovuto fare un FUNCTION per convertire il numero intero di nuovo in un 2 caratteri String:
I had to make a FUNCTION to convert the integer back to a 2 character String:
Code: QB64: [Select]
  1. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  2.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)

and this FUNCTION you've seen before:
e questa FUNCTION che avete visto prima:
Code: QB64: [Select]
  1. FUNCTION diff30in90 (a, b) 'default integers a-z
  2.     DIM hi, lo
  3.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  4.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  5.     IF hi - lo = 30 THEN
  6.         diff30in90 = -1
  7.     ELSE
  8.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  9.     END IF
  10.  
« Last Edit: July 03, 2020, 12:19:51 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: help my
« Reply #58 on: July 03, 2020, 12:17:18 pm »
Put altogether we get this:
Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!
  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, count, i, lineNum ' for file and array access
  6. DIM Q$ '                             for INKEY$
  7. DIM row, col, aPlace '               for screening Data from a string
  8. DIM rowCnt, x, y, d, 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.  
  11. 'count lines in file
  12. OPEN "lotto.dat" FOR INPUT AS #1
  13.     INPUT #1, a
  14.     '          debug check inputs from file
  15.     'PRINT a
  16.     'INPUT " OK enter "; w$
  17.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  18.  
  19. 'now we now size of file so ready an array to load file Data
  20. DIM fileDAT(1 TO count) AS STRING
  21. OPEN "lotto.dat" FOR INPUT AS #1
  22. FOR i = 1 TO count
  23.     INPUT #1, a
  24.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  25.  
  26. ' NOW all the data if loaded into fileDAT() array, 480 strings of Lottory data
  27.  
  28. GOSUB labelScreen
  29.  
  30. 'set first line and get a data string from the FileDAT array
  31. lineNum = 1
  32. a = fileDAT(lineNum)
  33.     Q$ = INKEY$
  34.     IF Q$ = "+" THEN lineNum = lineNum + 1
  35.     IF lineNum > count THEN lineNum = 1
  36.     IF Q$ = "-" THEN lineNum = lineNum - 1
  37.     IF lineNum < 1 THEN lineNum = count
  38.  
  39.     'get new data line
  40.     a = fileDAT(lineNum)
  41.  
  42.     'print out the data from the new line
  43.     CLS
  44.     GOSUB labelScreen
  45.     GOSUB screenDataLine
  46.     GOSUB loadLineDAT_Mark30s
  47.     _DISPLAY
  48.     _LIMIT 30
  49.  
  50.  
  51. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  52. rowCnt = 1: y = 1
  53. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  54.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  55.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  56.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  57. COLOR 9 'blue marker  seacrh through columes for  30's
  58. FOR col = 1 TO 5 'for each of the columes of data
  59.     FOR row = 1 TO 10 'for each of the rows of dat
  60.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  61.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  62.                 LOCATE row * 2, col * 3 - 2: PRINT DD$(lineDAT(col, row));
  63.                 LOCATE rowPlus * 2, col * 3 - 2: PRINT DD$(lineDAT(col, rowPlus));
  64.             END IF
  65.         NEXT
  66.     NEXT
  67.  
  68.  
  69. screenDataLine:
  70. LOCATE 1, 34
  71. PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum);
  72. aPlace = 5
  73. FOR row = 1 TO 11
  74.     FOR col = 1 TO 5
  75.         LOCATE row * 2, col * 3 - 2: PRINT MID$(a, aPlace, 2);
  76.         aPlace = aPlace + 2
  77.     NEXT
  78.  
  79. '=========================== the above does this ==============================
  80. 'LOCATE 1, 34
  81. 'PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum)
  82.  
  83. 'REM bari
  84. 'LOCATE 1, 13
  85. 'PRINT VAL(MID$(a, 5, 2))
  86. 'LOCATE 1, 16
  87. 'PRINT VAL(MID$(a, 7, 2))
  88. 'LOCATE 1, 19
  89. 'PRINT VAL(MID$(a, 9, 2))
  90. 'LOCATE 1, 22
  91. 'PRINT VAL(MID$(a, 11, 2))
  92. 'LOCATE 1, 25
  93. 'PRINT VAL(MID$(a, 13, 2))
  94.  
  95. 'REM cagliari
  96. 'LOCATE 3, 13
  97. 'PRINT VAL(MID$(a, 15, 2))
  98. 'LOCATE 3, 16
  99. 'PRINT VAL(MID$(a, 17, 2))
  100. 'LOCATE 3, 19
  101. 'PRINT VAL(MID$(a, 19, 2))
  102. 'LOCATE 3, 22
  103. 'PRINT VAL(MID$(a, 21, 2))
  104. 'LOCATE 3, 25
  105. 'PRINT VAL(MID$(a, 23, 2))
  106.  
  107. 'REM firenze
  108. 'LOCATE 5, 13
  109. 'PRINT VAL(MID$(a, 25, 2))
  110. 'LOCATE 5, 16
  111. 'PRINT VAL(MID$(a, 27, 2))
  112. 'LOCATE 5, 19
  113. 'PRINT VAL(MID$(a, 29, 2))
  114. 'LOCATE 5, 22
  115. 'PRINT VAL(MID$(a, 31, 2))
  116. 'LOCATE 5, 25
  117. 'PRINT VAL(MID$(a, 33, 2))
  118.  
  119. 'REM genova
  120. 'LOCATE 7, 13
  121. 'PRINT VAL(MID$(a, 35, 2))
  122. 'LOCATE 7, 16
  123. 'PRINT VAL(MID$(a, 37, 2))
  124. 'LOCATE 7, 19
  125. 'PRINT VAL(MID$(a, 39, 2))
  126. 'LOCATE 7, 22
  127. 'PRINT VAL(MID$(a, 41, 2))
  128. 'LOCATE 7, 25
  129. 'PRINT VAL(MID$(a, 43, 2))
  130.  
  131. 'REM milano
  132. 'LOCATE 9, 13
  133. 'PRINT VAL(MID$(a, 45, 2))
  134. 'LOCATE 9, 16
  135. 'PRINT VAL(MID$(a, 47, 2))
  136. 'LOCATE 9, 19
  137. 'PRINT VAL(MID$(a, 49, 2))
  138. 'LOCATE 9, 22
  139. 'PRINT VAL(MID$(a, 51, 2))
  140. 'LOCATE 9, 25
  141. 'PRINT VAL(MID$(a, 53, 2))
  142.  
  143. 'REM napoli
  144. 'LOCATE 11, 13
  145. 'PRINT VAL(MID$(a, 55, 2))
  146. 'LOCATE 11, 16
  147. 'PRINT VAL(MID$(a, 57, 2))
  148. 'LOCATE 11, 19
  149. 'PRINT VAL(MID$(a, 59, 2))
  150. 'LOCATE 11, 22
  151. 'PRINT VAL(MID$(a, 61, 2))
  152. 'LOCATE 11, 25
  153. 'PRINT VAL(MID$(a, 63, 2))
  154.  
  155. 'REM palermo
  156. 'LOCATE 13, 13
  157. 'PRINT VAL(MID$(a, 65, 2))
  158. 'LOCATE 13, 16
  159. 'PRINT VAL(MID$(a, 67, 2))
  160. 'LOCATE 13, 19
  161. 'PRINT VAL(MID$(a, 69, 2))
  162. 'LOCATE 13, 22
  163. 'PRINT VAL(MID$(a, 71, 2))
  164. 'LOCATE 13, 25
  165. 'PRINT VAL(MID$(a, 73, 2))
  166.  
  167. 'REM roma
  168. 'LOCATE 15, 13
  169. 'PRINT VAL(MID$(a, 75, 2))
  170. 'LOCATE 15, 16
  171. 'PRINT VAL(MID$(a, 77, 2))
  172. 'LOCATE 15, 19
  173. 'PRINT VAL(MID$(a, 79, 2))
  174. 'LOCATE 15, 22
  175. 'PRINT VAL(MID$(a, 81, 2))
  176. 'LOCATE 15, 25
  177. 'PRINT VAL(MID$(a, 83, 2))
  178.  
  179. 'REM torino
  180. 'LOCATE 17, 13
  181. 'PRINT VAL(MID$(a, 85, 2))
  182. 'LOCATE 17, 16
  183. 'PRINT VAL(MID$(a, 87, 2))
  184. 'LOCATE 17, 19
  185. 'PRINT VAL(MID$(a, 89, 2))
  186. 'LOCATE 17, 22
  187. 'PRINT VAL(MID$(a, 91, 2))
  188. 'LOCATE 17, 25
  189. 'PRINT VAL(MID$(a, 93, 2))
  190.  
  191. 'REM venezia
  192. 'LOCATE 19, 13
  193. 'PRINT VAL(MID$(a, 95, 2))
  194. 'LOCATE 19, 16
  195. 'PRINT VAL(MID$(a, 97, 2))
  196. 'LOCATE 19, 19
  197. 'PRINT VAL(MID$(a, 99, 2))
  198. 'LOCATE 19, 22
  199. 'PRINT VAL(MID$(a, 101, 2))
  200. 'LOCATE 19, 25
  201. 'PRINT VAL(MID$(a, 103, 2))
  202.  
  203. 'REM nazionale
  204. 'LOCATE 21, 13
  205. 'PRINT VAL(MID$(a, 105, 2))
  206. 'LOCATE 21, 16
  207. 'PRINT VAL(MID$(a, 107, 2))
  208. 'LOCATE 21, 19
  209. 'PRINT VAL(MID$(a, 109, 2))
  210. 'LOCATE 21, 22
  211. 'PRINT VAL(MID$(a, 111, 2))
  212. 'LOCATE 21, 25
  213. 'PRINT VAL(MID$(a, 113, 2))
  214. '========================================================================
  215.  
  216. labelScreen:
  217. ' setup screen labels for reporting data
  218. LOCATE 1, 1
  219. PRINT "BARI"
  220. LOCATE 3, 1
  221. PRINT "CAGLIARI"
  222. LOCATE 5, 1
  223. PRINT "FIRENZE"
  224. LOCATE 7, 1
  225. PRINT "GENOVA"
  226. LOCATE 9, 1
  227. PRINT "MILANO"
  228. LOCATE 11, 1
  229. PRINT "NAPOLI"
  230. LOCATE 13, 1
  231. PRINT "PALERMO"
  232. LOCATE 15, 1
  233. PRINT "ROMA"
  234. LOCATE 17, 1
  235. PRINT "TORINO"
  236. LOCATE 19, 1
  237. PRINT "VENEZIA"
  238. LOCATE 21, 1
  239. PRINT "NAZIONALE"
  240. 'some directions
  241. LOCATE 24, 1
  242. PRINT " + to move on";
  243. LOCATE 24, 16
  244. PRINT "- to back";
  245.  
  246. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  247.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  248.  
  249. FUNCTION diff30in90 (a, b) 'default integers a-z
  250.     DIM hi, lo
  251.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  252.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  253.     IF hi - lo = 30 THEN
  254.         diff30in90 = -1
  255.     ELSE
  256.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  257.     END IF
  258.  

And line 470 looks like this:
  [ You are not allowed to view this attachment ]  
« Last Edit: July 03, 2020, 12:21:56 pm by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: help my
« Reply #59 on: July 03, 2020, 05:09:30 pm »
@bplus
great job to modularize the code!

I think that this can be a good help to kiara87 to see and to understand the tecnique behind this code.
More modular more flexible!

About italian translator... 6- in top rating 0-10, otherwise D  in english rating.

Programming isn't difficult, only it's  consuming time and coffee