QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Kiara87 on June 30, 2020, 05:22:57 pm

Title: help my
Post by: Kiara87 on June 30, 2020, 05:22:57 pm

hello
I don't know if this is the right place to ask for the solution
I have a problem to solve my program created in QB64.
reads the .dat file only forward
clicking with the button +
works well scrolls the list inside the file
I need some instruction that when I click the button -   go back to the file list
what instruction should i use?

I leave here the listing and also the .dat file to read
I hope some good soul can help me
Title: Re: help my
Post by: Kiara87 on June 30, 2020, 05:24:31 pm
file .dat
Title: Re: help my
Post by: bplus on June 30, 2020, 09:24:40 pm
To go up and down a file listing, it would be best to load the file lines into an array.

It is allot easier to go up and down the lines of an array, in fact you can jump from one line to any other as easy as going up and down, if you use an array.

Welcome to the forum Kiara87, do you know about arrays?

When you open a file for INPUT you can only read down it, ... wait a second I did this the hard way, like what you are trying. I will try and dig up my code...  maybe we can save lessons on arrays for later! :-))


Oh you are using an array :P this is simple fix... 

oh no, "a" is just a string.

Working....




Title: Re: help my
Post by: bplus on June 30, 2020, 10:18:09 pm
I hope I did this in a way you can follow and I did it without arrays!

Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!
  2.  
  3. DIM a AS STRING, count AS INTEGER, lineNum AS INTEGER, Q$, num AS INTEGER
  4.  
  5. 'count lines in file
  6. OPEN "lotto.dat" FOR INPUT AS #1
  7.     INPUT #1, a
  8.     'PRINT a
  9.     'INPUT " OK enter "; w$
  10.     IF LEN(_TRIM$(a)) THEN count = count + 1
  11. 'CLS: PRINT count '480 lines
  12. 'END
  13. 'CLS
  14.  
  15. LOCATE 1, 1
  16. PRINT "BARI"
  17. LOCATE 3, 1
  18. PRINT "CAGLIARI"
  19. LOCATE 5, 1
  20. PRINT "FIRENZE"
  21. LOCATE 7, 1
  22. PRINT "GENOVA"
  23. LOCATE 9, 1
  24. PRINT "MILANO"
  25. LOCATE 11, 1
  26. PRINT "NAPOLI"
  27. LOCATE 13, 1
  28. PRINT "PALERMO"
  29. LOCATE 15, 1
  30. PRINT "ROMA"
  31. LOCATE 17, 1
  32. PRINT "TORINO"
  33. LOCATE 19, 1
  34. PRINT "VENEZIA"
  35. LOCATE 21, 1
  36. PRINT "NAZIONALE"
  37.  
  38.  
  39. LOCATE 23, 1: COLOR 4
  40. PRINT " + to move on"
  41. LOCATE 23, 16: COLOR 3
  42. PRINT "- to back"
  43.  
  44. lineNum = 1
  45. GOSUB get_a
  46.  
  47.  
  48.  
  49.     Q$ = INKEY$
  50.     IF Q$ = "+" THEN lineNum = lineNum + 1
  51.     IF lineNum > count THEN lineNum = 1
  52.  
  53.     IF Q$ = "-" THEN lineNum = lineNum - 1
  54.     IF lineNum < 1 THEN lineNum = count
  55.  
  56.     GOSUB get_a
  57.  
  58.  
  59.     LOCATE 1, 34
  60.     PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum)
  61.  
  62.     REM bari
  63.     LOCATE 1, 13
  64.     PRINT VAL(MID$(a, 5, 2))
  65.     LOCATE 1, 16
  66.     PRINT VAL(MID$(a, 7, 2))
  67.     LOCATE 1, 19
  68.     PRINT VAL(MID$(a, 9, 2))
  69.     LOCATE 1, 22
  70.     PRINT VAL(MID$(a, 11, 2))
  71.     LOCATE 1, 25
  72.     PRINT VAL(MID$(a, 13, 2))
  73.  
  74.     REM cagliari
  75.     LOCATE 3, 13
  76.     PRINT VAL(MID$(a, 15, 2))
  77.     LOCATE 3, 16
  78.     PRINT VAL(MID$(a, 17, 2))
  79.     LOCATE 3, 19
  80.     PRINT VAL(MID$(a, 19, 2))
  81.     LOCATE 3, 22
  82.     PRINT VAL(MID$(a, 21, 2))
  83.     LOCATE 3, 25
  84.     PRINT VAL(MID$(a, 23, 2))
  85.  
  86.     REM firenze
  87.     LOCATE 5, 13
  88.     PRINT VAL(MID$(a, 25, 2))
  89.     LOCATE 5, 16
  90.     PRINT VAL(MID$(a, 27, 2))
  91.     LOCATE 5, 19
  92.     PRINT VAL(MID$(a, 29, 2))
  93.     LOCATE 5, 22
  94.     PRINT VAL(MID$(a, 31, 2))
  95.     LOCATE 5, 25
  96.     PRINT VAL(MID$(a, 33, 2))
  97.  
  98.     REM genova
  99.     LOCATE 7, 13
  100.     PRINT VAL(MID$(a, 35, 2))
  101.     LOCATE 7, 16
  102.     PRINT VAL(MID$(a, 37, 2))
  103.     LOCATE 7, 19
  104.     PRINT VAL(MID$(a, 39, 2))
  105.     LOCATE 7, 22
  106.     PRINT VAL(MID$(a, 41, 2))
  107.     LOCATE 7, 25
  108.     PRINT VAL(MID$(a, 43, 2))
  109.  
  110.     REM milano
  111.     LOCATE 9, 13
  112.     PRINT VAL(MID$(a, 45, 2))
  113.     LOCATE 9, 16
  114.     PRINT VAL(MID$(a, 47, 2))
  115.     LOCATE 9, 19
  116.     PRINT VAL(MID$(a, 49, 2))
  117.     LOCATE 9, 22
  118.     PRINT VAL(MID$(a, 51, 2))
  119.     LOCATE 9, 25
  120.     PRINT VAL(MID$(a, 53, 2))
  121.  
  122.     REM napoli
  123.     LOCATE 11, 13
  124.     PRINT VAL(MID$(a, 55, 2))
  125.     LOCATE 11, 16
  126.     PRINT VAL(MID$(a, 57, 2))
  127.     LOCATE 11, 19
  128.     PRINT VAL(MID$(a, 59, 2))
  129.     LOCATE 11, 22
  130.     PRINT VAL(MID$(a, 61, 2))
  131.     LOCATE 11, 25
  132.     PRINT VAL(MID$(a, 63, 2))
  133.  
  134.     REM palermo
  135.     LOCATE 13, 13
  136.     PRINT VAL(MID$(a, 65, 2))
  137.     LOCATE 13, 16
  138.     PRINT VAL(MID$(a, 67, 2))
  139.     LOCATE 13, 19
  140.     PRINT VAL(MID$(a, 69, 2))
  141.     LOCATE 13, 22
  142.     PRINT VAL(MID$(a, 71, 2))
  143.     LOCATE 13, 25
  144.     PRINT VAL(MID$(a, 73, 2))
  145.  
  146.     REM roma
  147.     LOCATE 15, 13
  148.     PRINT VAL(MID$(a, 75, 2))
  149.     LOCATE 15, 16
  150.     PRINT VAL(MID$(a, 77, 2))
  151.     LOCATE 15, 19
  152.     PRINT VAL(MID$(a, 79, 2))
  153.     LOCATE 15, 22
  154.     PRINT VAL(MID$(a, 81, 2))
  155.     LOCATE 15, 25
  156.     PRINT VAL(MID$(a, 83, 2))
  157.  
  158.     REM torino
  159.     LOCATE 17, 13
  160.     PRINT VAL(MID$(a, 85, 2))
  161.     LOCATE 17, 16
  162.     PRINT VAL(MID$(a, 87, 2))
  163.     LOCATE 17, 19
  164.     PRINT VAL(MID$(a, 89, 2))
  165.     LOCATE 17, 22
  166.     PRINT VAL(MID$(a, 91, 2))
  167.     LOCATE 17, 25
  168.     PRINT VAL(MID$(a, 93, 2))
  169.  
  170.     REM venezia
  171.     LOCATE 19, 13
  172.     PRINT VAL(MID$(a, 95, 2))
  173.     LOCATE 19, 16
  174.     PRINT VAL(MID$(a, 97, 2))
  175.     LOCATE 19, 19
  176.     PRINT VAL(MID$(a, 99, 2))
  177.     LOCATE 19, 22
  178.     PRINT VAL(MID$(a, 101, 2))
  179.     LOCATE 19, 25
  180.     PRINT VAL(MID$(a, 103, 2))
  181.  
  182.     REM nazionale
  183.     LOCATE 21, 13
  184.     PRINT VAL(MID$(a, 105, 2))
  185.     LOCATE 21, 16
  186.     PRINT VAL(MID$(a, 107, 2))
  187.     LOCATE 21, 19
  188.     PRINT VAL(MID$(a, 109, 2))
  189.     LOCATE 21, 22
  190.     PRINT VAL(MID$(a, 111, 2))
  191.     LOCATE 21, 25
  192.     PRINT VAL(MID$(a, 113, 2))
  193.  
  194.     _LIMIT 30
  195.  
  196.  
  197. 'this sub retrieves a line number from file  the hard way
  198. get_a:
  199. num = 0
  200. OPEN "lotto.dat" FOR INPUT AS #1
  201.     INPUT #1, a
  202.     IF LEN(_TRIM$(a)) THEN num = num + 1
  203.     IF num = lineNum THEN EXIT WHILE 'a is set on line we want
  204.  
  205.  
  206.  
Title: Re: help my
Post by: bplus on June 30, 2020, 11:46:35 pm
Code: QB64: [Select]
  1. LP 7, 20, "One of the first SUBs I ever wrote was LP"
  2.  
  3. LP 9, 15, "L is for LOCATE"
  4. LP 10, 15, "P is for PRINT"
  5.  
  6. LP 12, 15, "It saved me all kinds of time typing LOCATE: aRow, aCol"
  7. LP 13, 15, "Then printing: PRINT mystr$."
  8.  
  9. LP 15, 15, "So now I am sharing it with you"
  10. LP 16, 15, "so you can save yourself some typing   and then"
  11. LP 17, 15, "you can share it with someone new."
  12.  
  13. ' L is for LOCATE P is for PRINT together they save you a whole lot of typing!
  14. SUB LP (row, column, Strng$)
  15.     LOCATE row, column: PRINT Strng$
  16.  
  17.  
Title: Re: help my
Post by: SMcNeill on July 01, 2020, 12:05:15 am
Just curious, but can't you use _PRINTSTRING instead of LP?
Title: Re: help my
Post by: bplus on July 01, 2020, 02:15:12 am
Just curious, but can't you use _PRINTSTRING instead of LP?

Not in 1991!

Of course I could use it now but then I'd have to explain _NEWIMAGE for graphics. Not sure the OP is ready for that.
Title: Re: help my
Post by: FellippeHeitor on July 01, 2020, 02:18:25 am
I have a problem to solve my program created in QB64.

Learning the syntax for SUB LP vs learning the syntax for _PRINTSTRING... I'm with Steve on this one 😉
Title: Re: help my
Post by: SMcNeill on July 01, 2020, 02:26:39 am
And _PRINTSTRING works in legacy modes.  (Even SCREEN 0.)
Title: Re: help my
Post by: bplus on July 01, 2020, 02:32:45 am
Yeah, OK your blowing my nostalgic moment :P

BTW this is how I learned SUB's back in the day.
Title: Re: help my
Post by: OldMoses on July 01, 2020, 07:02:14 am
In bplus' defense, LP is a lot quicker to type than _PRINTSTRING.
Title: Re: help my
Post by: Kiara87 on July 01, 2020, 07:45:01 am
thank bplus you very kind I am really grateful

thanks also to all of you who answered

bplus I wanted to do with arrays

but still they are beginners

I'm a beginner

thanks to this forum I will try to learn
Title: Re: help my
Post by: Kiara87 on July 01, 2020, 09:25:45 am
bplus thanks
i tried to put with arrays
i'm going crazy you can give me a tip of how i can do it
also to improve it because I have to make it sum the numbers and I think it takes more variables to do this

example of sum would be so?
MID$(a, 5, 2) > 30  MID$(a, 15, 2) then color 4
but the variable a it is of type string it cannot be added up
any suggestions?
Title: Re: help my
Post by: bplus on July 01, 2020, 09:36:04 am
bplus thanks
i tried to put with arrays
i'm going crazy you can give me a tip of how i can do it
also to improve it because I have to make it sum the numbers and I think it takes more variables to do this

example of sum would be so?
MID$(a, 5, 2) > 30  MID$(a, 15, 2) then color 4
but the variable a it is of type string it cannot be added up
any suggestions?

2nd thing first :)  assuming you want to add 30 to the 2nd VAL(MID$(a, 5, 2)

IF VAL(MID$(a, 5, 2)) > 30 +  VAL(MID$(a, 5, 2) THEN COLOR 4

VAL() changes string type to number for as far left to right as there are numbers.
eg VAL("123ABC") = 123

For arrays, I am afraid if I do it for you it will take you longer to learn. Can you show me what you've tried?
I would love to rewrite this program with an array :)

You will love how arrays make job easy if you can just get use to them.

PS sometimes when describing what you are having problem with to another person suddenly makes clear what you need to do, sometimes you just plain get stuck!
Title: Re: help my
Post by: bplus on July 01, 2020, 10:56:42 am
BTW there are more advanced ways to access a file that give up and down and all around flexibility for access but that is not a place to start. OPEN FOR INPUT is classic way to start learning file access. There are more flexible arrays that are started with REDIM, but again, that is not classic way to start learning arrays.

Question #1 about arrays, how big?

Because before you can use an array you have to DIM it (exceptions to almost every rule like if array size <=10 you don't have to DIM but I would anyway because you can then change to bigger by just changing number).

Think of DIM as reserving space in the computer memory bank. For variables reservations are easy they are known size but arrays? how many of these variables are wanting or be needing for the array though? You tell it through DIM statement DIM myArray$(100) that reserves space for 101 lines from 0 to 100. Now we can go from myArray$(0) to myArray$(100) without QB64 telling us our "subscript is out of bounds" referring to the number inside the parenthesis. It is usually called the index and it is usually given the variable name i, i for index.

OK so an array for our file, how big is that going to have to be? Most times we don't know and we just count the lines first like I did, so I knew not to go past a certain line number in file.

As usual with QB64 there are other ways to approach loading a file with unknown size into an array but let's stick with classic way from QB upon which QB64 was based, actually from GW BASIC upon which QB was based.

So enough lecture:
Code: QB64: [Select]
  1. 'count lines in file
  2. OPEN "lotto.dat" FOR INPUT AS #1
  3.     INPUT #1, a
  4.     'PRINT a
  5.     'INPUT " OK enter "; w$
  6.     IF LEN(_TRIM$(a)) THEN count = count + 1  'make sure we count real lines with stuff AKA contents

'set the size of the array
Code: QB64: [Select]
  1. DIM myArray$(count) ' we will leave myArray$(0) empty so that the Upper Bound of array matches the number of lines with stuff in them

Is that enough of a hint? Do you have that already?

Can you guess the next step: How to load the array? We practically have the code already! just add copy/paste and add or change one line.





Title: Re: help my
Post by: Kiara87 on July 01, 2020, 11:51:44 am
about the two statements to change the number value in the string
from these types of errors

1  https://imgur.com/0m667QA

2  https://imgur.com/GGBHMsd

my intention is this that you see in the image  --> https://imgur.com/eTR37ei

which finds a distance number 30 and then add it up

and print it

I wanted to do this I'm going crazy

I thank you for helping me six friendly


when he finds the distance 30 he colors the numbers in red the numbers must be vertical
Title: Re: help my
Post by: bplus on July 01, 2020, 12:02:51 pm
First red line:
Code: QB64: [Select]
  1. PRINT VAL("123ABC") 'will output 123 as number type
  2.  
  3. PRINT VAL("123ABC") + VAL(".563") 'should be output 123.563 but who knows what
  4.  
Title: Re: help my
Post by: bplus on July 01, 2020, 12:15:04 pm
After first red line, I think you will find answer in this example:
Code: QB64: [Select]
  1.  
  2. a$ = "12345678901234567890"
  3. FOR i = 3 TO 20 STEP 2
  4.     'ABS() 'makes all positive
  5.     IF ABS(VAL(MID$(a$, 1, 2)) - VAL(MID$(a$, i, 2))) > 30 THEN COLOR 12 ELSE COLOR 15
  6.     PRINT MID$(a$, 1, 2); "+"; MID$(a$, i, 2); "   SUM:"; VAL(MID$(a$, 1, 2)) + VAL(MID$(a$, i, 2))
  7.  

Title: Re: help my
Post by: Kiara87 on July 01, 2020, 12:17:48 pm
I didn't mean to print 123

I wanted to look for a distance of two numbers with distance 30 and color them as in the photo

maybe you need to do it with arrays to do this?

thanks bplus
Title: Re: help my
Post by: bplus on July 01, 2020, 12:19:41 pm
Check post above your last :)

To measure distance use ABS() because distance is not a negative number 10 - 40 = -30 but distance between 10 and 40 is 30 so ABS(10-40) = 30
Title: Re: help my
Post by: Kiara87 on July 01, 2020, 12:36:34 pm
ok I'm testing thanks bplus

Title: Re: help my
Post by: Kiara87 on July 01, 2020, 03:56:05 pm
https://imgur.com/l4J5Qmt

I'm running but I can't understand why the two numbers with distance 30 don't color me red

attached image

anyone to the solution?
Title: Re: help my
Post by: bplus on July 01, 2020, 04:21:21 pm
Hi @Kiara87

The a$ I used in the example for coloring represented the variable "a" you are pulling from the file = 1 row of numbers.

I didn't have a file line so I made one up to show as example.

For you, after you get "a" from the file, you will have a string of numbers that you are accessing with MID$(a, position, lengthOf2) just as you use these MID$ strings to show numbers, you use them to do calculations with VAL() to transform them into numbers to add subtract and use ABS() function.

To calculate the difference in one part of "a" with another part of "a" you have position = p for first number and position + some number for the other section of "a"   or position of first number and position of second number in "a".


You will have to do that for each and every number you want to compare and color red before you print each and every number.


To post code at this forum select all the code in QB64 IDE (editor) Copy it then here at forum Reply press the button with the QB64 icon in this forum editor you will get [ code = qb64 ][ / code ] without spaces in edit window of forum.
paste your code between the two brackets  ][  in the middle of the code tag.

st [ code = qb64 ] is before the start of your code and [ / code ] is after the end of your code. You can just type it in that way only without spaces inside the brackets.

Then maybe I can write in comments on your code for easier understanding. :)

Title: Re: help my
Post by: Kiara87 on July 01, 2020, 05:19:21 pm
I'm still trying
where I am wrong

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

Take just one thing you are printing for an example:
Code: QB64: [Select]
  1.     REM bari
  2.     LOCATE 1, 13
  3.     PRINT VAL(MID$(a, 5, 2))  '<<< the 5 in here id's the number.  
  4. ' I need to know what id number you want to compare this number to decide if it is red.
  5. ' If all the id's are a set amount from each other, do you want to compare
  6. 'MID$(a, 5, 2) to MID$(a, 35, 2)  and all the other MID$(a, x, 2) to MID$(a, x+30, 2) ????
  7.  
Title: Re: help my
Post by: Kiara87 on July 01, 2020, 05:41:46 pm
Code: QB64: [Select]
  1. REM cagliari
  2.     LOCATE 3, 13
  3.     PRINT VAL(MID$(a, 15, 2))  'I wanted to compare the first of Cagliari with the first of Milano that year the distance 30, and the two with the distance 30 color them red and all other numbers that remain white
  4. MID$(a, 45, 2)   TO MID$
    REM cagliari
    LOCATE 3, 13
    PRINT VAL(MID$(a, 15, 2))  'I wanted to compare the first of Cagliari with the first of Milano that year the distance 30, and the two with the distance 30 color them red and all other numbers that remain white
MID$(a, 45, 2)   TO MID$
Title: Re: help my
Post by: bplus on July 01, 2020, 05:47:50 pm
OK I think I have idea what you want, here is Bari started for you, you will have to do the rest (if it is right).
Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!
  2.  
  3. DIM a AS STRING, count AS INTEGER, lineNum AS INTEGER, Q$, num AS INTEGER
  4.  
  5. 'count lines in file
  6. OPEN "lotto.dat" FOR INPUT AS #1
  7.     INPUT #1, a
  8.     'PRINT a
  9.     'INPUT " OK enter "; w$
  10.     IF LEN(_TRIM$(a)) THEN count = count + 1
  11. 'CLS: PRINT count '480 lines
  12. 'END
  13. 'CLS
  14.  
  15. LOCATE 1, 1
  16. PRINT "BARI"
  17. LOCATE 3, 1
  18. PRINT "CAGLIARI"
  19. LOCATE 5, 1
  20. PRINT "FIRENZE"
  21. LOCATE 7, 1
  22. PRINT "GENOVA"
  23. LOCATE 9, 1
  24. PRINT "MILANO"
  25. LOCATE 11, 1
  26. PRINT "NAPOLI"
  27. LOCATE 13, 1
  28. PRINT "PALERMO"
  29. LOCATE 15, 1
  30. PRINT "ROMA"
  31. LOCATE 17, 1
  32. PRINT "TORINO"
  33. LOCATE 19, 1
  34. PRINT "VENEZIA"
  35. LOCATE 21, 1
  36. PRINT "NAZIONALE"
  37.  
  38. LOCATE 23, 1
  39. PRINT " + to move on"
  40. LOCATE 23, 16
  41. PRINT "- to back"
  42.  
  43.  
  44.  
  45. lineNum = 1
  46. GOSUB get_a
  47.  
  48.  
  49.     a$ = "12345678901234567890"
  50.     Q$ = INKEY$
  51.     IF Q$ = "+" THEN lineNum = lineNum + 1
  52.     IF lineNum > count THEN lineNum = 1
  53.  
  54.     IF Q$ = "-" THEN lineNum = lineNum - 1
  55.     IF lineNum < 1 THEN lineNum = count
  56.  
  57.  
  58.  
  59.     GOSUB get_a
  60.  
  61.  
  62.     LOCATE 1, 34
  63.     PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum)
  64.  
  65.     REM bari
  66.     LOCATE 1, 13
  67.     IF ABS(VAL(MID$(a, 5, 2)) - VAL(MID$(a, 15, 2))) > 30 THEN COLOR 2 ELSE COLOR 15
  68.     PRINT VAL(MID$(a, 5, 2))
  69.     LOCATE 1, 16
  70.     IF ABS(VAL(MID$(a, 7, 2)) - VAL(MID$(a, 17, 2))) > 30 THEN COLOR 2 ELSE COLOR 15
  71.     PRINT VAL(MID$(a, 7, 2))
  72.     LOCATE 1, 19
  73.     IF ABS(VAL(MID$(a, 8, 2)) - VAL(MID$(a, 19, 2))) > 30 THEN COLOR 2 ELSE COLOR 15
  74.     PRINT VAL(MID$(a, 9, 2))
  75.     LOCATE 1, 22
  76.     IF ABS(VAL(MID$(a, 11, 2)) - VAL(MID$(a, 21, 2))) > 30 THEN COLOR 2 ELSE COLOR 15
  77.     PRINT VAL(MID$(a, 11, 2))
  78.     LOCATE 1, 25
  79.     IF ABS(VAL(MID$(a, 13, 2)) - VAL(MID$(a, 23, 2))) > 30 THEN COLOR 2 ELSE COLOR 15
  80.     PRINT VAL(MID$(a, 13, 2))
  81.  
  82.     REM cagliari
  83.     LOCATE 3, 13
  84.     PRINT VAL(MID$(a, 15, 2))
  85.     LOCATE 3, 16
  86.     PRINT VAL(MID$(a, 17, 2))
  87.     LOCATE 3, 19
  88.     PRINT VAL(MID$(a, 19, 2))
  89.     LOCATE 3, 22
  90.     PRINT VAL(MID$(a, 21, 2))
  91.     LOCATE 3, 25
  92.     PRINT VAL(MID$(a, 23, 2))
  93.  
  94.     REM firenze
  95.     LOCATE 5, 13
  96.     PRINT VAL(MID$(a, 25, 2))
  97.     LOCATE 5, 16
  98.     PRINT VAL(MID$(a, 27, 2))
  99.     LOCATE 5, 19
  100.     PRINT VAL(MID$(a, 29, 2))
  101.     LOCATE 5, 22
  102.     PRINT VAL(MID$(a, 31, 2))
  103.     LOCATE 5, 25
  104.     PRINT VAL(MID$(a, 33, 2))
  105.  
  106.     REM genova
  107.     LOCATE 7, 13
  108.     PRINT VAL(MID$(a, 35, 2))
  109.     LOCATE 7, 16
  110.     PRINT VAL(MID$(a, 37, 2))
  111.     LOCATE 7, 19
  112.     PRINT VAL(MID$(a, 39, 2))
  113.     LOCATE 7, 22
  114.     PRINT VAL(MID$(a, 41, 2))
  115.     LOCATE 7, 25
  116.     PRINT VAL(MID$(a, 43, 2))
  117.  
  118.     REM milano
  119.     LOCATE 9, 13
  120.     PRINT VAL(MID$(a, 45, 2))
  121.     LOCATE 9, 16
  122.     PRINT VAL(MID$(a, 47, 2))
  123.     LOCATE 9, 19
  124.     PRINT VAL(MID$(a, 49, 2))
  125.     LOCATE 9, 22
  126.     PRINT VAL(MID$(a, 51, 2))
  127.     LOCATE 9, 25
  128.     PRINT VAL(MID$(a, 53, 2))
  129.  
  130.     REM napoli
  131.     LOCATE 11, 13
  132.     PRINT VAL(MID$(a, 55, 2))
  133.     LOCATE 11, 16
  134.     PRINT VAL(MID$(a, 57, 2))
  135.     LOCATE 11, 19
  136.     PRINT VAL(MID$(a, 59, 2))
  137.     LOCATE 11, 22
  138.     PRINT VAL(MID$(a, 61, 2))
  139.     LOCATE 11, 25
  140.     PRINT VAL(MID$(a, 63, 2))
  141.  
  142.     REM palermo
  143.     LOCATE 13, 13
  144.     PRINT VAL(MID$(a, 65, 2))
  145.     LOCATE 13, 16
  146.     PRINT VAL(MID$(a, 67, 2))
  147.     LOCATE 13, 19
  148.     PRINT VAL(MID$(a, 69, 2))
  149.     LOCATE 13, 22
  150.     PRINT VAL(MID$(a, 71, 2))
  151.     LOCATE 13, 25
  152.     PRINT VAL(MID$(a, 73, 2))
  153.  
  154.     REM roma
  155.     LOCATE 15, 13
  156.     PRINT VAL(MID$(a, 75, 2))
  157.     LOCATE 15, 16
  158.     PRINT VAL(MID$(a, 77, 2))
  159.     LOCATE 15, 19
  160.     PRINT VAL(MID$(a, 79, 2))
  161.     LOCATE 15, 22
  162.     PRINT VAL(MID$(a, 81, 2))
  163.     LOCATE 15, 25
  164.     PRINT VAL(MID$(a, 83, 2))
  165.  
  166.     REM torino
  167.     LOCATE 17, 13
  168.     PRINT VAL(MID$(a, 85, 2))
  169.     LOCATE 17, 16
  170.     PRINT VAL(MID$(a, 87, 2))
  171.     LOCATE 17, 19
  172.     PRINT VAL(MID$(a, 89, 2))
  173.     LOCATE 17, 22
  174.     PRINT VAL(MID$(a, 91, 2))
  175.     LOCATE 17, 25
  176.     PRINT VAL(MID$(a, 93, 2))
  177.  
  178.     REM venezia
  179.     LOCATE 19, 13
  180.     PRINT VAL(MID$(a, 95, 2))
  181.     LOCATE 19, 16
  182.     PRINT VAL(MID$(a, 97, 2))
  183.     LOCATE 19, 19
  184.     PRINT VAL(MID$(a, 99, 2))
  185.     LOCATE 19, 22
  186.     PRINT VAL(MID$(a, 101, 2))
  187.     LOCATE 19, 25
  188.     PRINT VAL(MID$(a, 103, 2))
  189.  
  190.     REM nazionale
  191.     LOCATE 21, 13
  192.     PRINT VAL(MID$(a, 105, 2))
  193.     LOCATE 21, 16
  194.     PRINT VAL(MID$(a, 107, 2))
  195.     LOCATE 21, 19
  196.     PRINT VAL(MID$(a, 109, 2))
  197.     LOCATE 21, 22
  198.     PRINT VAL(MID$(a, 111, 2))
  199.     LOCATE 21, 25
  200.     PRINT VAL(MID$(a, 113, 2))
  201.  
  202.     _LIMIT 30
  203.  
  204.  
  205. 'this sub retrieves a line number from file  the hard way
  206. get_a:
  207. num = 0
  208. OPEN "lotto.dat" FOR INPUT AS #1
  209.     INPUT #1, a
  210.     IF LEN(_TRIM$(a)) THEN num = num + 1
  211.     IF num = lineNum THEN EXIT WHILE 'a is set on line we want
  212.  
  213.  

Wait do you want to compare ( row, col )  to  ( row + 1, col ) and if they are different by 30 or more make them red?

Rows are 10 places apart, I edited above to compare each row and column with the next row and same column I think. Only first line Bari colored right??

Gotta go feed people :)
Title: Re: help my
Post by: Kiara87 on July 01, 2020, 06:29:34 pm
they must be the same vertical column the same position one below the other

and the two numbers with distance 30 I have to color them red

Note every single number comes in 90

so if there is the number 60

in the column below I find the number 90

if instead I find the number 61

in the column below I find the number 1
Title: Re: help my
Post by: bplus on July 01, 2020, 07:56:31 pm
Is first row Bari colored correctly?
Title: Re: help my
Post by: Kiara87 on July 01, 2020, 08:09:26 pm
no because it must be colored only if the distance 30 is in the same row in the same row
the numbers must all be white, must turn red if under 82 there is 52 or 22 because 82 and 52  distance 30

22 and 52 distance 30

and 22 and 82 distance 30 going beyond  90

only the numbers with distance 30 that are one below the other in the same row must change color


I know and a somewhat complicated program, however, helps to learn new things
Thanks for your patience bplus
Title: Re: help my
Post by: Kiara87 on July 01, 2020, 08:19:18 pm
here are some examples of what the program should do

image

https://imgur.com/B47CquB

https://imgur.com/GOESC0i

https://imgur.com/RLT5LQX

https://imgur.com/imC9ru5

https://imgur.com/TTy9v9v

https://imgur.com/Jc9HlRb

https://imgur.com/lwoQoNj
Title: Re: help my
Post by: bplus on July 01, 2020, 08:34:39 pm
So exactly 30 or 60

89 - 30 = 59 red
59 - 30 = 29 red

12 + 30 = 42 red
42 + 30 = 72 red

but this is head scratcher (see attachment)
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: help my
Post by: Kiara87 on July 02, 2020, 01:08:58 am
example
29 89

it is always distance 30
in this game the numbers reach 90
exaple
29 89        89+30=119-90=29  <---- when it exceeds 90   -do the minus 90

in practice always a distance 30 because if the sum exceeds 90 then it subtracts 90

88 +30= 118    118-90= 28

28+30 =58

58+30=88

28-30=88  because the numbers reach 90 


Title: Re: help my
Post by: bplus on July 02, 2020, 10:11:31 am
Hi @Kiara87

So no 60's but new math on 30's. Why wasn't the 90 - 60 = 30 shaded in the screenshot I showed and blue circled, because don't check 90? only numbers less than 90?

OK this can be done now that I've leaned the new math 79 + 30 = 109 - 90 = 19 ha! ;-)

And we need to check down the whole column that one line in the data file makes.

We could make things easy on ourselves by loading a into an array with rows and columns just like the print out.

Starting at MID$(a, 5, 2) I think, every 2 digits is new number, 5 numbers make a row so the next row of numbers after 5 starts at 15 and the next starts at 25 and the next starts at 35... positions in the "a" string I am talking about.

How many rows in one line from the file? nRows = (len(a) - 4) /10 it's a constant for the DAT file we use, the first 4 digits are identifiers to line I suppose those should go in a separate array or just read off "a" when we need them.

DIM lineDAT(1 to 5, 1 to nRows) as INTEGER  'an  array to load from each line from DAT

rowCnt = 0 : x = 1 : y = 1
for i = 5 to len(a) step 2
    d = val(mid$(a, i, 2)) 'convert data item to iteger
    rowCnt = rowCnt + 1 ' increase column if at 6 start new row
    if rowCnt = 6 then x = 1 : y = y + 1
    lineDAT(x, y) = d
next

The above is NOT in code box because it is not tested in QB64.
 
That loads our line data array and it makes it easy to sweep through array and make red the items that are 30 from each other.

I would just print the array as white and then print the 30's red after a sweep the array check for 30's.

Before starting an 2D array for line data I would start an array for the file data and load whole file into array.
This is standard way to approach data from a file, load the file into an array in programs working memory it is way more efficient to process file data from some sort of array.

So next step is to do that, load the file data into an array of strings and we already know the amount of lines 480

Dim FileDAT(1 to 480) as STRING
Open File for input
for i = 1 to 480
   Get a line of data from file
   and set FileDAT(i) = to it
next i

'array loaded with data from file

' next use the the code we wrote to get a line number only this time we will get it from the array instead of the file

Let's see how far along you can get with that. Get the lines from the array and printout the screen of data.
Then we will work on scanning down the columns for 30's, the code above is start of that. We should also have to write a FUNCTION for your new math with 30s. ;-)

OK?

Oh, once we know what lineNum to get from key presses we just set a = LineDAT(lineNum) simple!
And now we can get any lineNum we want, we don't have to just go up and down the file for a data line.

   
Title: Re: help my
Post by: Kiara87 on July 02, 2020, 10:52:26 am
I also put the images that color all the numbers in green
I changed color I thought it was the fault of the color
on the other hand, even green makes tantrums
https://imgur.com/IHBBzi4 (https://imgur.com/IHBBzi4)
https://imgur.com/l8r0Zx0 (https://imgur.com/l8r0Zx0)
https://imgur.com/gNsecam (https://imgur.com/gNsecam)
https://imgur.com/OPApefR (https://imgur.com/OPApefR)
I only tried with an if condition

with only one condition  if
it works

the problem if I put only one condition I only check two numbers
other problem is when he finds the condition he colors all the numbers

while I wanted to color only the two of the found condition

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

Right, once you set color it won't unset unless you tell it to go back.
That's why I advise print the whole thing in white first and then go back and shade/color only the 30's.

Please read carefully my long post before your last. I will guide you to perfect app AND you will learn a little about arrays and subroutines, if you can hang in there. :) this is kind of accelerated learning of BASIC.

On a 2nd front, I am working on a 30's FUNCTION such that given 2 numbers, it will say if there is a 30 diff = -1 or NOT = 0

(-1 = True there is a diff (=difference) of 30, 0 = False there is not a difference of 30).

But I need a ruling on 90:

90 - 30 = 60 so shade 90 and 60 combo, right?

90 + 30 = 120 - 90 = 30 so shade 90 and 30 combo right?

Also no numbers should be 0, correct?
 
And 90 IS the maximum number, correct?



Title: Re: help my
Post by: bplus on July 02, 2020, 12:41:05 pm
@Kiara87

I have written a function to test 30 distance between 2 numbers from 1 to 90.

It returns -1 when the numbers are 30 apart and 0 if they are NOT.

Can you find 2 numbers when this returns the wrong answer?

Code: QB64: [Select]
  1. DEFINT A-Z
  2. _TITLE "Kiara87 diff30in90 function test" 'b+ 2020-07-02 this checks out for every example kiara87 has provided
  3.  
  4. ' interesting challenge numbers from 1 to 90 need to mark special if one number is 30 off the 2nd
  5.  
  6. 1 DO
  7.     CLS
  8.     INPUT "Please enter number (1 to 90) to check if 30 off (of 90) of another number "; n1
  9.     IF n1 > 90 THEN BEEP: GOTO 1
  10.     INPUT "Please enter 2nd number (1 to 90) for check "; n2
  11.     IF n2 > 90 THEN BEEP: GOTO 1
  12.     PRINT "diff30in90("; n1; ","; n2; ") FUNCTION returned:"; diff30in90(n1, n2)
  13.     _DELAY 4
  14. LOOP UNTIL n1 = 0 OR n2 = 0
  15.  
  16. FUNCTION diff30in90 (a, b) 'default integers a-z
  17.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  18.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  19.     IF hi - lo = 30 THEN
  20.         diff30in90 = -1
  21.     ELSE
  22.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  23.     END IF
Title: Re: help my
Post by: Kiara87 on July 02, 2020, 03:01:56 pm
hello bplus

yes the program returns perfect when from -1 the answer is right
if return 0

the answer is wrong

so your instructions work

I had read in the post what you wrote but I didn't understand everything well because I don't speak English well
now I will try to do it as you said with array
I am a beginner who is learning

and I also thank you for being a good teacher

pity that I cannot understand the English language

I use the google translator

thank you very much bplus
Code: QB64: [Select]
  1. DEFINT A-Z
  2. _TITLE "Kiara87 diff30in90 function test" 'b+ 2020-07-02 this checks out for every example kiara87 has provided
  3.  
  4. ' interesting challenge numbers from 1 to 90 need to mark special if one number is 30 off the 2nd
  5.  
  6. 1 DO
  7.     CLS
  8.     INPUT "Please enter number (1 to 90) to check if 30 off (of 90) of another number "; n1
  9.     IF n1 > 90 THEN BEEP: GOTO 1
  10.     INPUT "Please enter 2nd number (1 to 90) for check "; n2
  11.     IF n2 > 90 THEN BEEP: GOTO 1
  12.     PRINT "diff30in90("; n1; ","; n2; ") FUNCTION returned:"; diff30in90(n1, n2)
  13.     _DELAY 4
  14. LOOP UNTIL n1 = 0 OR n2 = 0
  15.  
  16. FUNCTION diff30in90 (a, b) 'default integers a-z
  17.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  18.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  19.     IF hi - lo = 30 THEN
  20.         diff30in90 = -1
  21.     ELSE
  22.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  23.     END IF
Title: Re: help my
Post by: bplus on July 02, 2020, 03:15:33 pm
@Kiara87

Thanks for confirmation, certification and validation of my function. I have already proceeded as if I were correct. ;-))

Quote
pity that I cannot understand the English language
Well that makes 2 of us!

I am working ahead, so I can show you light at the end of the tunnel.

My current task is reducing all those locate and  print lines to simple formula, so we don't have to type so much. ;-)

To be good programmer hate to type repetitive stuff!
Title: Re: help my
Post by: bplus on July 02, 2020, 03:19:12 pm
Did I leave enough help for loading the file into an array?

Should we talk more about arrays?
Title: Re: help my
Post by: Kiara87 on July 02, 2020, 04:01:10 pm
Did I leave enough help for loading the file into an array?

Should we talk more about arrays?

I'm trying to understand how an array works but the tutorials are in English

I know a bit of instructions but the arrays I hadn't studied

did I understand that you don't speak English well?
Title: Re: help my
Post by: bplus on July 02, 2020, 04:36:42 pm
Quote
did I understand that you don't speak English well?

Yes, but I was making a joke because English is my only language.

If you tell me your language I will use Bing to translate some of my words to yours (hopefully) and I might learn something too.
Title: Re: help my
Post by: Kiara87 on July 02, 2020, 04:42:46 pm
Yes, but I was making a joke because English is my only language.

If you tell me your language I will use Bing to translate some of my words to yours (hopefully) and I might learn something too.

I am Italian I speak and I can speak only Italian too much
Title: Re: help my
Post by: bplus on July 02, 2020, 05:27:52 pm
Code: QB64: [Select]
  1. _TITLE "#1 della lezione di matrice" 'Array lesson #1   b+ 2020-07-02
  2.  
  3. 'Riempire una matrice con numeri da 1 a 20
  4. 'Caricare un array con numeri da 1 a 20
  5. ' Fill = Riempire   Caricare = Load an array with numbers from 1 to 20
  6.  
  7. DIM ilMioArray(1 TO 20)
  8.  
  9. FOR i = 1 TO 20 ' i = indice
  10.     ilMioArray(i) = i
  11.  
  12. PRINT "visualizzare il mio array all'indietro     'show me the array backwards"
  13. FOR i = 20 TO 1 STEP -1
  14.     PRINT ilMioArray(i)
  15. PRINT "premere un tasto qualsiasi per continuare...  press any key to continue... "
  16.  
  17. PRINT "modificare il contenuto della mia matrice  'modify my array contents"
  18. FOR i = 20 TO 1 STEP -1
  19.     ilMioArray(i) = ilMioArray(i) ^ 2 + 1 ' al quadrato piu (+) 1   'squared plus 1
  20.  
  21. GOSUB visualizzare:
  22.  
  23. END ''''''''''''''''' don't go past here   'non andare passato qui
  24.  
  25. visualizzare:
  26. PRINT "visualizzare  'display"
  27. FOR i = 1 TO 20
  28.     PRINT "i ="; i; ", "; ilMioArray(i)
  29. PRINT "premere un tasto qualsiasi per continuare...  press any key to continue... "
  30.  
  31.  

The next step is loading a file into an array.
Il passaggio successivo consiste nel caricamento di un file in una matrice.

Want to give it a try?
Vuoi fare un tentativo?
Title: Re: help my
Post by: Kiara87 on July 02, 2020, 06:39:30 pm
https://imgur.com/yW5dIS6
another question

those on the right in the image what are they?

an array would be a variable containing more content

only variable that can hold multiple values

contained in the same variable
miaArray(i) = i

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

later you said to load a file into an array

how can i upload it?

example variabile a 100
Code: QB64: [Select]
  1. _TITLE "#1 della lezione di matrice" 'Array lesson #1   b+ 2020-07-02
  2.  
  3. 'Riempire una matrice con numeri da 1 a 20
  4. 'Caricare un array con numeri da 1 a 20
  5. ' Fill = Riempire   Caricare = Load an array with numbers from 1 to 20
  6.  
  7. DIM ilMioArray(1 TO 20)
  8.  
  9. FOR i = 1 TO 20 ' i = indice
  10.     ilMioArray(i) = i
  11.  
  12. PRINT "visualizzare il mio array all'indietro     'show me the array backwards"
  13. FOR i = 20 TO 1 STEP -1
  14.     PRINT ilMioArray(i)
  15. PRINT "premere un tasto qualsiasi per continuare...  press any key to continue... "
  16.  
  17. PRINT "modificare il contenuto della mia matrice  'modify my array contents"
  18. FOR i = 20 TO 1 STEP -1
  19.     ilMioArray(i) = ilMioArray(i) ^ 2 + 1 ' al quadrato piu (+) 1   'squared plus 1
  20.  
  21. GOSUB visualizzare:
  22.  
  23. END ''''''''''''''''' don't go past here   'non andare passato qui
  24.  
  25. visualizzare:
  26. PRINT "visualizzare  'display"
  27. FOR i = 1 TO 20
  28.     PRINT "i ="; i; ", "; ilMioArray(i)
  29. PRINT "premere un tasto qualsiasi per continuare...  press any key to continue... "
  30.  
  31.  

The next step is loading a file into an array.
Il passaggio successivo consiste nel caricamento di un file in una matrice.

Want to give it a try?
Vuoi fare un tentativo?
Title: Re: help my
Post by: bplus 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
Title: Re: help my
Post by: SMcNeill 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.  ;)
Title: Re: help my
Post by: bplus 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.  
Title: Re: help my
Post by: bplus on July 02, 2020, 09:48:50 pm
There is light at end of tunnel but it's a little advanced.
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: help my
Post by: Kiara87 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.  ;)
Title: Re: help my
Post by: Kiara87 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.  
Title: Re: help my
Post by: Kiara87 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.  
Title: Re: help my
Post by: TempodiBasic 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
Title: Re: help my
Post by: Kiara87 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
Title: Re: help my
Post by: bplus 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!
Title: Re: help my
Post by: bplus 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.
Title: Re: help my
Post by: bplus 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.  
Title: Re: help my
Post by: bplus 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.  
Title: Re: help my
Post by: bplus 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:
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: help my
Post by: TempodiBasic 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.

Title: Re: help my
Post by: bplus on July 03, 2020, 05:17: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.

Thanks @TempodiBasic  But the translations to Italian not so good? They were brought to you by Bing BTW.
Title: Re: help my
Post by: Kiara87 on July 03, 2020, 07:39:38 pm
Thank you so much bplus

you are a true master I am seeing techniques never seen before instructions that I didn't even know existed

i'm studying your code so i learn something 

I wanted to change the position where it prints the numbers I want to support them

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 = 4 TO 8  ' <----- changing this works moves the numbers to the right position '
  7.         LOCATE row * 2, col * 3 - 2: PRINT VAL(MID$(a, aPlace, 2));
  8.         aPlace = aPlace + 2
  9.     NEXT


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 10 'blue marker  seacrh through columes for  30's
  8. FOR col = 4 TO 8 'for each of the columes of data    <----I believe this function is for bringing the color over the numbers  but changing this gives me an error
  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 VAL(DD$(lineDAT(col, row)));
  13.                 LOCATE rowPlus * 2, col * 3 - 2: PRINT VAL(DD$(lineDAT(col, rowPlus)));
  14.             END IF
  15.         NEXT
  16.     NEXT
  17.  

test

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 10 'blue marker  seacrh through columes for  30's
  58. FOR col = 4 TO 8 '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 VAL(DD$(lineDAT(col, row)));
  63.                 LOCATE rowPlus * 2, col * 3 - 2: PRINT VAL(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 = 4 TO 8
  75.         LOCATE row * 2, col * 3 - 2: PRINT VAL(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 2, 1
  219. PRINT "BARI"
  220. LOCATE 4, 1
  221. PRINT "CAGLIARI"
  222. LOCATE 6, 1
  223. PRINT "FIRENZE"
  224. LOCATE 8, 1
  225. PRINT "GENOVA"
  226. LOCATE 10, 1
  227. PRINT "MILANO"
  228. LOCATE 12, 1
  229. PRINT "NAPOLI"
  230. LOCATE 14, 1
  231. PRINT "PALERMO"
  232. LOCATE 16, 1
  233. PRINT "ROMA"
  234. LOCATE 18, 1
  235. PRINT "TORINO"
  236. LOCATE 20, 1
  237. PRINT "VENEZIA"
  238. LOCATE 22, 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.  
  259.  
  260.  


Title: Re: help my
Post by: bplus on July 03, 2020, 07:57:27 pm
Quote
I wanted to change the position where it prints the numbers I want to support them

The column numbers are aligned to the array numbers, don't change those because they access exact parts of the array lineDAT().

You can shift the numbers over in the print on screen by adding to LOCATE lines, the col part:

It is Locate Row, Col  so maybe Col plus the amount you want to shift right say 20 characters
Set a variable called shiftRight = 20 will move text over 20 characters
Code: QB64: [Select]
  1. FOR col = 1 TO 5 'for each of the columes of data
  2.     FOR row = 1 TO 10 'for each of the rows of dat
  3.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  4.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  5.                 LOCATE row * 2, col * 3 - 2 + shiftRight: PRINT VAL(DD$(lineDAT(col, row)));  '>>>>>the VAL you added defeats the DD$ format
  6.                 LOCATE rowPlus * 2, col * 3 - 2 + shiftRight: PRINT VAL(DD$(lineDAT(col, rowPlus)));'>>>>>the VAL you added defeats the DD$ format
  7.             END IF
  8.         NEXT
  9.     NEXT
  10.  
  11.  

Remember to do it in the other print section also.

Good to fiddle with numbers and maybe break once or twice or 20 times :-))
(Just remember to keep a backup)

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. DIM shiftRight
  11. shiftRight = 20
  12.  
  13. 'count lines in file
  14. OPEN "lotto.dat" FOR INPUT AS #1
  15.     INPUT #1, a
  16.     '          debug check inputs from file
  17.     'PRINT a
  18.     'INPUT " OK enter "; w$
  19.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  20.  
  21. 'now we now size of file so ready an array to load file Data
  22. DIM fileDAT(1 TO count) AS STRING
  23. OPEN "lotto.dat" FOR INPUT AS #1
  24. FOR i = 1 TO count
  25.     INPUT #1, a
  26.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  27.  
  28. ' NOW all the data if loaded into fileDAT() array, 480 strings of Lottory data
  29.  
  30. GOSUB labelScreen
  31.  
  32. 'set first line and get a data string from the FileDAT array
  33. lineNum = 1
  34. a = fileDAT(lineNum)
  35.     Q$ = INKEY$
  36.     IF Q$ = "+" THEN lineNum = lineNum + 1
  37.     IF lineNum > count THEN lineNum = 1
  38.     IF Q$ = "-" THEN lineNum = lineNum - 1
  39.     IF lineNum < 1 THEN lineNum = count
  40.  
  41.     'get new data line
  42.     a = fileDAT(lineNum)
  43.  
  44.     'print out the data from the new line
  45.     CLS
  46.     GOSUB labelScreen
  47.     GOSUB screenDataLine
  48.     GOSUB loadLineDAT_Mark30s
  49.     _DISPLAY
  50.     _LIMIT 30
  51.  
  52.  
  53. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  54. rowCnt = 1: y = 1
  55. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  56.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  57.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  58.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  59. COLOR 9 'blue marker  seacrh through columes for  30's
  60. FOR col = 1 TO 5 'for each of the columes of data
  61.     FOR row = 1 TO 10 'for each of the rows of dat
  62.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  63.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  64.                 LOCATE row * 2, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, row));
  65.                 LOCATE rowPlus * 2, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, rowPlus));
  66.             END IF
  67.         NEXT
  68.     NEXT
  69.  
  70.  
  71. screenDataLine:
  72. LOCATE 1, 34
  73. PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum);
  74. aPlace = 5
  75. FOR row = 1 TO 11
  76.     FOR col = 1 TO 5
  77.         LOCATE row * 2, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2);
  78.         aPlace = aPlace + 2
  79.     NEXT
  80.  
  81. labelScreen:
  82. ' setup screen labels for reporting data
  83. LOCATE 1, 1
  84. PRINT "BARI"
  85. LOCATE 3, 1
  86. PRINT "CAGLIARI"
  87. LOCATE 5, 1
  88. PRINT "FIRENZE"
  89. LOCATE 7, 1
  90. PRINT "GENOVA"
  91. LOCATE 9, 1
  92. PRINT "MILANO"
  93. LOCATE 11, 1
  94. PRINT "NAPOLI"
  95. LOCATE 13, 1
  96. PRINT "PALERMO"
  97. LOCATE 15, 1
  98. PRINT "ROMA"
  99. LOCATE 17, 1
  100. PRINT "TORINO"
  101. LOCATE 19, 1
  102. PRINT "VENEZIA"
  103. LOCATE 21, 1
  104. PRINT "NAZIONALE"
  105. 'some directions
  106. LOCATE 24, 1
  107. PRINT " + to move on";
  108. LOCATE 24, 16
  109. PRINT "- to back";
  110.  
  111. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  112.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  113.  
  114. FUNCTION diff30in90 (a, b) 'default integers a-z
  115.     DIM hi, lo
  116.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  117.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  118.     IF hi - lo = 30 THEN
  119.         diff30in90 = -1
  120.     ELSE
  121.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  122.     END IF
  123.  
  124.  
  125.  
Title: Re: help my
Post by: Kiara87 on July 04, 2020, 09:35:16 am
many thanks now i try to finish the program thanks you helped me a lot

The column numbers are aligned to the array numbers, don't change those because they access exact parts of the array lineDAT().

You can shift the numbers over in the print on screen by adding to LOCATE lines, the col part:

It is Locate Row, Col  so maybe Col plus the amount you want to shift right say 20 characters
Set a variable called shiftRight = 20 will move text over 20 characters
Code: QB64: [Select]
  1. FOR col = 1 TO 5 'for each of the columes of data
  2.     FOR row = 1 TO 10 'for each of the rows of dat
  3.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  4.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  5.                 LOCATE row * 2, col * 3 - 2 + shiftRight: PRINT VAL(DD$(lineDAT(col, row)));  '>>>>>the VAL you added defeats the DD$ format
  6.                 LOCATE rowPlus * 2, col * 3 - 2 + shiftRight: PRINT VAL(DD$(lineDAT(col, rowPlus)));'>>>>>the VAL you added defeats the DD$ format
  7.             END IF
  8.         NEXT
  9.     NEXT
  10.  
  11.  

Remember to do it in the other print section also.

Good to fiddle with numbers and maybe break once or twice or 20 times :-))
(Just remember to keep a backup)

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. DIM shiftRight
  11. shiftRight = 20
  12.  
  13. 'count lines in file
  14. OPEN "lotto.dat" FOR INPUT AS #1
  15.     INPUT #1, a
  16.     '          debug check inputs from file
  17.     'PRINT a
  18.     'INPUT " OK enter "; w$
  19.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  20.  
  21. 'now we now size of file so ready an array to load file Data
  22. DIM fileDAT(1 TO count) AS STRING
  23. OPEN "lotto.dat" FOR INPUT AS #1
  24. FOR i = 1 TO count
  25.     INPUT #1, a
  26.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  27.  
  28. ' NOW all the data if loaded into fileDAT() array, 480 strings of Lottory data
  29.  
  30. GOSUB labelScreen
  31.  
  32. 'set first line and get a data string from the FileDAT array
  33. lineNum = 1
  34. a = fileDAT(lineNum)
  35.     Q$ = INKEY$
  36.     IF Q$ = "+" THEN lineNum = lineNum + 1
  37.     IF lineNum > count THEN lineNum = 1
  38.     IF Q$ = "-" THEN lineNum = lineNum - 1
  39.     IF lineNum < 1 THEN lineNum = count
  40.  
  41.     'get new data line
  42.     a = fileDAT(lineNum)
  43.  
  44.     'print out the data from the new line
  45.     CLS
  46.     GOSUB labelScreen
  47.     GOSUB screenDataLine
  48.     GOSUB loadLineDAT_Mark30s
  49.     _DISPLAY
  50.     _LIMIT 30
  51.  
  52.  
  53. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  54. rowCnt = 1: y = 1
  55. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  56.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  57.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  58.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  59. COLOR 9 'blue marker  seacrh through columes for  30's
  60. FOR col = 1 TO 5 'for each of the columes of data
  61.     FOR row = 1 TO 10 'for each of the rows of dat
  62.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  63.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  64.                 LOCATE row * 2, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, row));
  65.                 LOCATE rowPlus * 2, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, rowPlus));
  66.             END IF
  67.         NEXT
  68.     NEXT
  69.  
  70.  
  71. screenDataLine:
  72. LOCATE 1, 34
  73. PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum);
  74. aPlace = 5
  75. FOR row = 1 TO 11
  76.     FOR col = 1 TO 5
  77.         LOCATE row * 2, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2);
  78.         aPlace = aPlace + 2
  79.     NEXT
  80.  
  81. labelScreen:
  82. ' setup screen labels for reporting data
  83. LOCATE 1, 1
  84. PRINT "BARI"
  85. LOCATE 3, 1
  86. PRINT "CAGLIARI"
  87. LOCATE 5, 1
  88. PRINT "FIRENZE"
  89. LOCATE 7, 1
  90. PRINT "GENOVA"
  91. LOCATE 9, 1
  92. PRINT "MILANO"
  93. LOCATE 11, 1
  94. PRINT "NAPOLI"
  95. LOCATE 13, 1
  96. PRINT "PALERMO"
  97. LOCATE 15, 1
  98. PRINT "ROMA"
  99. LOCATE 17, 1
  100. PRINT "TORINO"
  101. LOCATE 19, 1
  102. PRINT "VENEZIA"
  103. LOCATE 21, 1
  104. PRINT "NAZIONALE"
  105. 'some directions
  106. LOCATE 24, 1
  107. PRINT " + to move on";
  108. LOCATE 24, 16
  109. PRINT "- to back";
  110.  
  111. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  112.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  113.  
  114. FUNCTION diff30in90 (a, b) 'default integers a-z
  115.     DIM hi, lo
  116.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  117.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  118.     IF hi - lo = 30 THEN
  119.         diff30in90 = -1
  120.     ELSE
  121.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  122.     END IF
  123.  
  124.  
  125.  
Title: Re: help my
Post by: bplus on July 04, 2020, 12:28:41 pm
@Kiara87

So I took numbers in string form and converted them to integers when loading the lineDAT() array because it made it easier to compare numbers and run the diff30in90 FUNCTION on them but to print them again from the array, I had to convert them back to strings.

Printing numbers on highly formatted screen is usually a nightmare without some format function to convert them to strings you have more control over.

The DD$ function took any positive number < 100 and made sure 1 digit numbers were aligned on right side with 0's padding (on left) and 0 is presented as "00" (if that should ever come up). I thought 0 padding good for displaying lottery numbers.

You could also pad with spaces instead but have to say
if number = 0 then myNumberFormat$ = " 0"

Alternate pad with spaces, assuming positive numbers for number 0 <= number < 100
Code: QB64: [Select]
  1. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  2.     IF number = 0 THEN DD$ = " 0" ELSE DD$ = RIGHT$("  " + _TRIM$(STR$(number)), 2)
I better test that...

Update: OK this works fine too:
Code: QB64: [Select]
  1. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  2.     DD$ = RIGHT$("  " + _TRIM$(STR$(number)), 2)

Title: Re: help my
Post by: TempodiBasic on July 04, 2020, 08:06:36 pm
example of program planning   [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: help my
Post by: TempodiBasic on July 05, 2020, 09:37:59 pm
@Kiara87
Ciao
ecco una versione del programma seguendo le vaghe indicazioni che hai fornito in questo thread.

1. è una versione che usa una sola stringa per caricare il file in memoria e poi analizzarlo.
2. esegue l'operazione sul file che hai fornito quindi cambiando file (lunghezza o tipo di dati registrati dentro) va adattato
3. ho seguito le impostazioni di Bplus usando i GOSUB più facili da comprendere e usare rispetto alle SUB e alle FUNCTION
ecco il codice sorgente in QB64
Code: QB64: [Select]
  1. ' Programma lotto di kiara87
  2. ' il programma legge i dati (numeri estratti da un file.dat)
  3. ' e permette di vedere  le estrazioni a video
  4. ' i numeri con distanza 30 sono evidenziati con colore reosso
  5. ' questi numeri vengono memorizzati e stampati
  6.  
  7. ' Nota 1: sono d'accordo con Bplus e' molto piu'
  8. ' rapido lavorare con dati in RAM che con dati su Disco HDD/SSD/USB/CD/DVD
  9.  
  10. ' valori COSTANTI  generali Vero e Falso
  11. CONST True = -1, False = NOT True
  12. ' le 11 ruote del lotto
  13. CONST Bari = 1, Cagliari = 2, Firenze = 3, Genova = 4, Milano = 5
  14. CONST Napoli = 6, Palermo = 7, Roma = 8, Torino = 9, Venezia = 10, Nazionale = 11
  15. CONST Cifra = 2 ' ogni numero estratto e' una cifra di due caratteri (01-90)
  16.  
  17. DIM a AS STRING ' una stringa per leggere i dati dal file
  18.  
  19. ' salta al sottoprogramma LeggiFile delimitato
  20. 'dalla Label LeggiFIle e dal RETURN
  21. GOSUB LeggiFile
  22.  
  23. ' il ciclo DO...LOOP UNTIL condizione e' un modo piu' moderno
  24. ' rispetto a Etichetta: .... IF condizione GOTO Etichetta
  25.     ' prende l'input dell'utente
  26.     z$ = UCASE$(INKEY$) ' Z$ mantiene il maiuscolo di Inkey$
  27.     GOSUB MostraRuote ' scrive il nome delle ruote del lotto
  28.     GOSUB MostraEstratti
  29.  
  30. LOOP UNTIL z$ = "Q"
  31.  
  32.  
  33. END ' indica la fine logica del programma
  34.  
  35.  
  36. '-----------------------AREA sottoprogrammi /SUBroutines
  37.  
  38. ' questa etichetta /label indica il punto di inizio
  39. ' del sottoprogramma (SUBroutine) LeggiFile scritto con vecchio stile GOSUB
  40. ' che usa una etichetta/label e un RETURN per riprendere da dove si era interotto
  41. ' nota1: un metodo ancora piu' antico e' il salto con GOTO
  42. '        che richiede una seconda etichetta per ritornare nel MAIN o programma principale
  43. ' nota2: un metodo migliore e' SUB nomeroutine....END SUB
  44. '        perche' permette la localizzazione delle variabili
  45. LeggiFile:
  46. 'se non trova lotto.dat segnala l'errore a video e termina il programma
  47. IF NOT _FILEEXISTS("lotto.dat") THEN PRINT "File non trovato": END
  48. ' apre il file lotto.dat per leggere in maniera sequenziale i dati
  49. OPEN "lotto.dat" FOR INPUT AS #1
  50. a = SPACE$(LOF(1)) ' riempe la variabile a di spazi fino alla grandezza in byte del file aperto
  51. INPUT #1, a ' legge con una unica operazione il file e lo pone nella variabiel a
  52. CLOSE #1 ' chiude il file appena letto
  53. ' indica il termine della SUBroutine LeggiFile
  54. ' e RITORNA alla riga di codice successiva al salto GOSUB
  55.  
  56. 'seconda SUBroutine /sottoprogramma
  57. MostraRuote:
  58. COLOR 7, 6
  59. LOCATE 1, 1
  60. PRINT "BARI"
  61. LOCATE 3, 1
  62. PRINT "CAGLIARI"
  63. LOCATE 5, 1
  64. PRINT "FIRENZE"
  65. LOCATE 7, 1
  66. PRINT "GENOVA"
  67. LOCATE 9, 1
  68. PRINT "MILANO"
  69. LOCATE 11, 1
  70. PRINT "NAPOLI"
  71. LOCATE 13, 1
  72. PRINT "PALERMO"
  73. LOCATE 15, 1
  74. PRINT "ROMA"
  75. LOCATE 17, 1
  76. PRINT "TORINO"
  77. LOCATE 19, 1
  78. PRINT "VENEZIA"
  79. LOCATE 21, 1
  80. PRINT "NAZIONALE"
  81. LOCATE 23, 1
  82. PRINT "premi q per terminare"
  83.  
  84. ' indica il termine della SUBroutine MostraRuote
  85. ' e RITORNA alla riga di codice successiva al salto GOSUB
  86.  
  87. 'terzo sottoprogramma o SUBroutine
  88. MostraEstratti:
  89.  
  90. ' le prime 4 cifre sembrano essere in numero della estrazione
  91. LOCATE 1, 40
  92. PRINT "estraz.num "; LEFT$(a, 4)
  93.  
  94. y = 13 ' prima posizione per il carattere da stampare
  95. FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR è di 5 perche' lo e' il tuo esempio
  96.     FOR V = Bari TO Nazionale ' per tutte le ruote
  97.         'posiziona il cursore
  98.         LOCATE (V * 2) - 1, y
  99.         ' verifica la condizione + o - 30
  100.         IF (V > 1) AND ABS((VAL(MID$(a, (V - 2) * 10 + 5 + ((x - 1) * 2), Cifra))) - (VAL(MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2), Cifra)))) = 30 THEN COLOR 4, 1 ELSE COLOR 15, 0
  101.         ' scrive il numero estratto
  102.         PRINT VAL(MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2), Cifra)); " ";
  103.     NEXT V
  104.     y = POS(0)
  105. ' indica il termine della SUBroutine MostraEstratti
  106. ' e RITORNA alla riga di codice successiva al salto GOSUB

@bplus
I have written this code to give an impulse to kiara87 to come nearer to programming world. The only goal has been to give a simple code with more comments into her native language because it seems that kiara87 has not so skills for english at this moment and she is newborn to programming world.
Title: Re: help my
Post by: bplus on July 05, 2020, 11:10:32 pm
@TempodiBasic

Well I hope your Italian is better than my English ;-))
Title: Re: help my
Post by: TempodiBasic on July 06, 2020, 12:34:19 pm
@bplus
Also I hope so! :-))
Title: Re: help my
Post by: TempodiBasic on July 06, 2020, 01:18:10 pm
@Kiara87
Salve, benvenuta nella community di QB64!

Usando il tuo lotto.dat io ho questo output allo schermo
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Quindi in questo output non va bene che è evidenziato solo il 41 ma deve essere evidenziato anche il 71.... non era molto chiara questa caratteristica ma non ci vuole molto per adattare il codice che ti ho postato.....il problema per me è che non era per niente chiaro che il confronto va fatto per qualsiasi elemento di una estrazione versus qualsiasi altro elemento della stessa estrazione... come mostri qui https://imgur.com/YalTULO (https://imgur.com/YalTULO)

in tal caso è bene usare un algoritmo leggermente differente anche senza array. Un po' di immaginazione da parte tua e troverai facilmente la strada. Programmare è trovare soluzioni,ma la vera difficoltà è definire bene il problema e il risultato che si vuole ottenere.
Ma come avevo detto all'inizio senza specifiche chiare da parte tua con un progetto tipo pseudocodice o flowchart o altro ancora che non tralascia alcun dettaglio è solo tempo perso.
In quanto ricevi feedback che non ti sono utili e ti possono portare fuori strada invece di aiutarti e nel frattempo chi risponde alle tue richieste usa tempo ed energie per elaborare risposte non efficaci.
Prima progettare, poi scrivere codice.

Good Luck!


@bplus
Yes man, your look is more insightful than mine! :-))
Title: Re: help my
Post by: Kiara87 on July 08, 2020, 04:38:39 pm
@TempodiBasic  and bplus
siete bravissimi tutti e due

you are both very good


ps:  vi invidio


I envy you


non so se google traduttore traduce bene questa parola in inglese


Title: Re: help my
Post by: bplus on July 08, 2020, 07:17:36 pm
Hi @Kiara87

Still practicing with lottery example? Have you tried arrays on anything else?
Title: Re: help my
Post by: Kiara87 on July 09, 2020, 09:48:30 am

I was trying to finish the program but I find myself with many difficulties I try not to give up but I see programming difficult
maybe I need a master as good as you
only that I don't understand English
I think my problem is to understand the programming logic I mean how can a programmer think
how to compose all the instructions to create the program

I won't give up
Title: Re: help my
Post by: bplus on July 09, 2020, 11:30:29 am
It is step by step logic. I play Sudoku allot to practice step by step logic frame of mind.

If get stuck, try practice with simpler examples of problem.

If you find yourself repeating steps over and over, you probably have a subroutine, look for the one or two variables that change each repetition.

Quote
I won't give up


Yes but do give up on the way that isn't working ;-))
Title: Re: help my
Post by: Kiara87 on July 09, 2020, 04:54:24 pm
with this game you learn to program  --> https://www.sudoku-it.com/

other people have also told me with  --> Torre de Hanoi 
source 
&t=1447s

these two games teach programming

yes or no?
Title: Re: help my
Post by: bplus on July 09, 2020, 06:15:13 pm
Sudoku helps train brain to think logically automatically.
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

But cool if you can make your own version. Here is my Sudoku Game:
https://qb64.freeforums.net/thread/109/sudoku-app

Yes I studied Towers of Hanoi too!
Code: QB64: [Select]
  1. _TITLE "Towers of Hanoi 1" 'B+ started 2019-02-28
  2. '2019-03-02 I've added mBox since post of original  Towers of Hanoi 1" 'B+ started 2019-02-28
  3. ' I found I needed to fix both mBox and getClick to clear old mb clicks
  4. ' this copy contains the faulty routines getClick and mBox BUT DOES WORK with _DELAY .2 added in here
  5. ' should be fixed in, Towers of Hanoi 1 test with new mBox" 'B+ started 2019-03-02
  6.  
  7. CONST xmax = 800
  8. CONST ymax = 600
  9. CONST eTitle$ = "Towers of Hanoi Error:"
  10. SCREEN _NEWIMAGE(xmax, ymax, 32)
  11. _SCREENMOVE 300, 20
  12. DIM SHARED nDisks AS INTEGER, hDisk AS INTEGER, wMult AS INTEGER
  13. nDisks = 10
  14. hDisk = 520 / nDisks
  15. wMult = 240 / nDisks
  16. DIM SHARED dpal(1 TO nDisks) AS _UNSIGNED LONG
  17. FOR i = 1 TO nDisks
  18.     dpal(i) = _RGB32(RND * 255, RND * 255, RND * 255)
  19. DIM SHARED tower(1 TO 3, 1 TO nDisks) AS INTEGER
  20.  
  21. 'init
  22. FOR i = 1 TO nDisks
  23.     tower(1, i) = nDisks + 1 - i
  24. updateScreen
  25.     'message click or press for fromt
  26.     fromT = 0: toT = 0
  27.     fromT = getTower%
  28.     PRINT "from tower "; fromT
  29.     IF topDiskValue(fromT) THEN
  30.         toT = getTower
  31.         PRINT "to tower "; toT
  32.         IF toT <> fromT THEN
  33.             'PRINT topDiskValue(tot), topDiskValue(fromt)
  34.             IF (topDiskValue(toT) > topDiskValue(fromT)) OR topDiskValue(toT) = 0 THEN
  35.                 tower(toT, topDiskPlace(toT) + 1) = topDiskValue(fromT)
  36.                 'PRINT "topDiskPlace(fromt)"; topDiskPlace(fromt)
  37.                 tower(fromT, topDiskPlace(fromT)) = 0
  38.                 updateScreen
  39.             ELSE
  40.                 mBox "Can't place a larger disk on top a smaller one.", eTitle$
  41.             END IF
  42.         ELSE
  43.             mBox "You attempted to move a disk to the same tower.", eTitle$
  44.         END IF
  45.     ELSE
  46.         IF fromT THEN mBox "There is no disk to move in tower" + STR$(fromT), eTitle$
  47.         _DELAY .2 '<<<<< damn it I should not need this!!!
  48.     END IF
  49.     fromT = 0: toT = 0
  50.     _LIMIT 30
  51. PRINT "Goodbye!"
  52.  
  53.  
  54. SUB getClick (mx, my, q)
  55.     WHILE _MOUSEINPUT: WEND '<<<<<<<<<<  clear previous mouse activity   ITS NOT CLEARING!!!!!!!!!!!!!!
  56.     _KEYCLEAR 'clear previous key presses
  57.     mx = -1: my = -1: q = 0
  58.     DO WHILE mx = -1 AND my = -1
  59.         q = _KEYHIT
  60.         IF q = 27 OR (q > 31 AND q < 126) THEN _KEYCLEAR: EXIT SUB
  61.         i = _MOUSEINPUT: mb = _MOUSEBUTTON(1)
  62.         DO WHILE mb 'wait for release
  63.             q = _KEYHIT
  64.             IF q = 27 OR (q > 31 AND q < 126) THEN EXIT SUB
  65.             i = _MOUSEINPUT: mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  66.             _LIMIT 1000
  67.         LOOP
  68.         _LIMIT 1000
  69.     LOOP
  70.  
  71. SUB updateScreen
  72.     CLS
  73.     LINE (0, 580)-STEP(xmax, 0)
  74.     FOR t = 1 TO 3
  75.         FOR i = 1 TO nDisks
  76.             IF tower(t, i) THEN
  77.                 xhalf = (tower(t, i) * wMult) / 2
  78.                 LINE (t * 250 - xhalf - 125, 580 - hDisk * i)-STEP(2 * xhalf, hDisk), dpal(tower(t, i)), BF
  79.             END IF
  80.         NEXT
  81.     NEXT
  82.     _PRINTSTRING (0, ymax - 18), SPACE$(11) + "Tower #1" + SPACE$(24) + "Tower #2" + SPACE$(23) + "Tower #3"
  83.  
  84. FUNCTION topDiskValue (t)
  85.     FOR i = nDisks TO 1 STEP -1
  86.         IF tower(t, i) THEN topDiskValue = tower(t, i): EXIT FUNCTION
  87.     NEXT
  88.  
  89. FUNCTION topDiskPlace (t)
  90.     FOR i = nDisks TO 1 STEP -1
  91.         IF tower(t, i) THEN topDiskPlace = i: EXIT FUNCTION
  92.     NEXT
  93.  
  94. FUNCTION getTower% ()
  95.     getClick mx, my, q
  96.     IF ABS(150 - mx) < 125 THEN t = 1
  97.     IF ABS(400 - mx) < 125 THEN t = 2
  98.     IF ABS(650 - mx) < 125 THEN t = 3
  99.     IF q THEN
  100.         IF INSTR("123", CHR$(q)) > 0 THEN t = INSTR("123", CHR$(q))
  101.         IF CHR$(q) = "q" OR q = 27 THEN END
  102.     END IF
  103.     getTower% = t
  104.  
  105. 'title$ limit is 55 chars, all lines are 58 chars max
  106. ' Develop from mBox v 2018-10-27 color change, fan fix, cls
  107. SUB mBox (m$, title$)
  108.  
  109.     'first screen dimensions items to restore at exit
  110.     DIM curRow AS INTEGER, curCol AS INTEGER
  111.     DIM curScrn AS LONG, backScrn AS LONG, mbx AS LONG 'some handles
  112.     DIM ti AS INTEGER, limit AS INTEGER 'ti = text index for t$(), limit is number of chars per line
  113.     DIM i AS INTEGER, j AS INTEGER, ff AS _BIT, add AS _BYTE 'index, flag and
  114.     DIM bxH AS INTEGER, bxW AS INTEGER 'first as cells then as pixels
  115.     DIM mb AS INTEGER, mx AS INTEGER, my AS INTEGER, mi AS INTEGER, grabx AS INTEGER, graby AS INTEGER
  116.     DIM tlx AS INTEGER, tly AS INTEGER 'top left corner of message box
  117.     DIM lastx AS INTEGER, lasty AS INTEGER, r AS INTEGER, kh AS LONG
  118.     DIM b$, c$, tail$, d$
  119.     DBLU = &HFF000066
  120.     LBLU = &HFFB0A0FF
  121.     BLK = &HFF000000
  122.     WHT = &HFFFFFFFF
  123.  
  124.     curRow = CSRLIN
  125.     curCol = POS(0)
  126.     sw = _WIDTH
  127.     sh = _HEIGHT
  128.     fg = _DEFAULTCOLOR
  129.     bg = _BACKGROUNDCOLOR
  130.     'screen snapshot
  131.     curScrn = _DEST
  132.     backScrn = _NEWIMAGE(sw, sh, 32)
  133.     _PUTIMAGE , curScrn, backScrn
  134.  
  135.     'setup t$() to store strings with ti as index, linit 58 chars per line max, b$ is for build
  136.     REDIM t$(0): ti = 0: limit = 58: b$ = ""
  137.     FOR i = 1 TO LEN(m$)
  138.         c$ = MID$(m$, i, 1)
  139.         'are there any new line signals, CR, LF or both? take CRLF or LFCR as one break but dbl LF or CR means blank line
  140.         SELECT CASE c$
  141.             CASE CHR$(13) 'load line
  142.                 IF MID$(m$, i + 1, 1) = CHR$(10) THEN i = i + 1
  143.                 t$(ti) = b$: b$ = "": ti = ti + 1: REDIM _PRESERVE t$(ti)
  144.             CASE CHR$(10)
  145.                 IF MID$(m$, i + 1, 1) = CHR$(13) THEN i = i + 1
  146.                 t$(ti) = b$: b$ = "": ti = ti + 1: REDIM _PRESERVE t$(ti)
  147.             CASE ELSE
  148.                 IF c$ = CHR$(9) THEN c$ = SPACE$(4): add = 4 ELSE add = 1
  149.                 IF LEN(b$) + add > limit THEN
  150.                     tail$ = "": ff = 0
  151.                     FOR j = LEN(b$) TO 1 STEP -1 'backup until find a space, save the tail end for next line
  152.                         d$ = MID$(b$, j, 1)
  153.                         IF d$ = " " THEN
  154.                             t$(ti) = MID$(b$, 1, j - 1): b$ = tail$ + c$: ti = ti + 1: REDIM _PRESERVE t$(ti)
  155.                             ff = 1 'found space flag
  156.                             EXIT FOR
  157.                         ELSE
  158.                             tail$ = d$ + tail$ 'the tail grows!
  159.                         END IF
  160.                     NEXT
  161.                     IF ff = 0 THEN 'no break? OK
  162.                         t$(ti) = b$: b$ = c$: ti = ti + 1: REDIM _PRESERVE t$(ti)
  163.                     END IF
  164.                 ELSE
  165.                     b$ = b$ + c$ 'just keep building the line
  166.                 END IF
  167.         END SELECT
  168.     NEXT
  169.     t$(ti) = b$
  170.     bxH = ti + 3: bxW = limit + 2
  171.  
  172.     'draw message box
  173.     mbx = _NEWIMAGE(60 * 8, (bxH + 1) * 16, 32)
  174.     _DEST mbx
  175.     COLOR DBLU, WHT
  176.     LOCATE 1, 1: PRINT LEFT$(SPACE$((bxW - LEN(title$) - 3) / 2) + title$ + SPACE$(bxW), bxW)
  177.     COLOR _RGB32(225, 225, 255), _RGB32(200, 0, 0)
  178.     LOCATE 1, bxW - 2: PRINT " X "
  179.     COLOR DBLU, LBLU
  180.     LOCATE 2, 1: PRINT SPACE$(bxW);
  181.     FOR r = 0 TO ti
  182.         LOCATE 1 + r + 2, 1: PRINT LEFT$(SPACE$((bxW - LEN(t$(r))) / 2) + t$(r) + SPACE$(bxW), bxW);
  183.     NEXT
  184.     LOCATE 1 + bxH, 1: PRINT SPACE$(limit + 2);
  185.  
  186.     'now for the action
  187.     _DEST curScrn
  188.  
  189.     'convert to pixels the top left corner of box at moment
  190.     bxW = bxW * 8: bxH = bxH * 16
  191.     tlx = (sw - bxW) / 2: tly = (sh - bxH) / 2
  192.     lastx = tlx: lasty = tly
  193.     'now allow user to move it around or just read it
  194.     WHILE 1
  195.         CLS
  196.         _PUTIMAGE , backScrn
  197.         _PUTIMAGE (tlx, tly), mbx, curScrn
  198.         _DISPLAY
  199.         WHILE _MOUSEINPUT: WEND
  200.         mx = _MOUSEX: my = _MOUSEY: mb = _MOUSEBUTTON(1)
  201.         IF mb THEN
  202.             IF mx >= tlx AND mx <= tlx + bxW AND my >= tly AND my <= tly + 16 THEN 'mouse down on title bar
  203.                 IF mx >= tlx + bxW - 24 THEN EXIT WHILE
  204.                 grabx = mx - tlx: graby = my - tly
  205.                 DO WHILE mb 'wait for release
  206.                     mi = _MOUSEINPUT: mb = _MOUSEBUTTON(1)
  207.                     mx = _MOUSEX: my = _MOUSEY
  208.                     IF mx - grabx >= 0 AND mx - grabx <= sw - bxW AND my - graby >= 0 AND my - graby <= sh - bxH THEN
  209.                         'attempt to speed up with less updates
  210.                         IF ((lastx - (mx - grabx)) ^ 2 + (lasty - (my - graby)) ^ 2) ^ .5 > 10 THEN
  211.                             tlx = mx - grabx: tly = my - graby
  212.                             CLS
  213.                             _PUTIMAGE , backScrn
  214.                             _PUTIMAGE (tlx, tly), mbx, curScrn
  215.                             lastx = tlx: lasty = tly
  216.                             _DISPLAY
  217.                         END IF
  218.                     END IF
  219.                     _LIMIT 600
  220.                 LOOP
  221.             END IF
  222.         END IF
  223.         kh = _KEYHIT
  224.         SELECT CASE kh
  225.             CASE 27, 13, 32: _DELAY .2: EXIT WHILE
  226.         END SELECT
  227.         _LIMIT 60
  228.     WEND
  229.     'put things back
  230.     COLOR fg, bg: CLS
  231.     _PUTIMAGE , backScrn
  232.     _DISPLAY
  233.     _FREEIMAGE backScrn
  234.     _FREEIMAGE mbx
  235.     _KEYCLEAR
  236.     LOCATE curRow, curCol
  237.  
  238.  
Title: Re: help my
Post by: Kiara87 on July 10, 2020, 03:03:27 am
@bplu a true master in programming
I hope one day I will become as good as you

i am trying to solve the sudoku even though i set it to easy mode
it is still very difficult for me
Title: Re: help my
Post by: SMcNeill on July 10, 2020, 03:40:43 am
If it helps, Kiara, remember this -- All computer programming breaks down to 3 steps:

1) Step by step commands
2) Decision making
3) Repetition

Take any problem facing you, and you can break its solution down to those 3 steps (including life problems).  Let's say I tell you, "Make me a peanut butter sandwich."   How do you accomplish that task?

Get up.
Go in kitchen.
Get a knife.
Get bread.
Get peanut butter.
Open bread, remove a slice.
Put knife in peanut butter.
Remove knife from peanut butter.
Wipe knife on bread.
Put down knife.
Remove slice of bread from pack.
Place bread on bread.

And there's the biggest problem programmers usually face -- we think "fix a sandwich", and we do it.  The computer has to have that instruction broken down step-by-step, to accomplish the same task...  It's not the complexity of the problem that confound us; it's the simplicity of the computer.

Even with the above set of instructions, it's probably not enough for your pet robot to make that sandwich.  "Get up" implies it was down somewhere.  "Go in kitchen" is vague.  From Where?  How many steps?  How many turns around corners, or up and down steps?  Whose kitchen?

The trick is to break your problem down into smaller stages, and then see if there's a set of computer commands to fulfill those needs.  If not, break those needs down smaller, until there are.

For example let's say I tell you to, "Print the contents of a file for me."

Breaking that order down to its components, we have to:

Choose a file.
Open that file.
Load the contents of that file in memory.
Print that file.
Repeat the last two steps until the whole file is printed.
Close the file.

Now, we have a basic step-by-step road map of how our program will look.

INPUT "Give me the name of the file you want to print ", filename$
OPEN filename$ FOR INPUT AS #1
DO
    LINE INPUT #1, text$
    PRINT text$
LOOP UNTIL EOF(1)
CLOSE #1


Take your complex problem and break it down to its step-by-step components.  If you can do that, you can write your own computer programs.
Title: Re: help my
Post by: _vince on July 10, 2020, 07:21:02 am
Take any problem facing you, and you can break its solution down to those 3 steps (including life problems).  Let's say I tell you, "Make me a peanut butter sandwich."   How do you accomplish that task?

I think Steve's trying to say leave the coding to bplus and make him a sandwich
Title: Re: help my
Post by: bplus on July 10, 2020, 11:31:23 am
LOL I do like simple things like Peanut Butter and Jelly sandwiches. Gots to have the jelly though!

I guess I like making things simple, certainly things presented simply. But what I really like is thinking of something and seeing it work on the computer screen. That sense of power overcomes all the tedium and frustration that comes from practice with Basic.

I've been working on Sudoku for way over a year, just to check and see if my advanced level puzzles generated from my program are both unique and solvable. I think I have unique but solvable, still uncertain about that one.

Tower of Hanoi is boring after you "get" what it takes to solve the puzzle, it's about 10 or 20 steps repeated over and over in a certain order, so easy for a human to loose track of that order and start going backwards again! 🤦‍♂️

Title: Re: help my
Post by: Kiara87 on July 10, 2020, 06:06:18 pm
If it helps, Kiara, remember this -- All computer programming breaks down to 3 steps:

1) Step by step commands
2) Decision making
3) Repetition

Take any problem facing you, and you can break its solution down to those 3 steps (including life problems).  Let's say I tell you, "Make me a peanut butter sandwich."   How do you accomplish that task?

Get up.
Go in kitchen.
Get a knife.
Get bread.
Get peanut butter.
Open bread, remove a slice.
Put knife in peanut butter.
Remove knife from peanut butter.
Wipe knife on bread.
Put down knife.
Remove slice of bread from pack.
Place bread on bread.

And there's the biggest problem programmers usually face -- we think "fix a sandwich", and we do it.  The computer has to have that instruction broken down step-by-step, to accomplish the same task...  It's not the complexity of the problem that confound us; it's the simplicity of the computer.

Even with the above set of instructions, it's probably not enough for your pet robot to make that sandwich.  "Get up" implies it was down somewhere.  "Go in kitchen" is vague.  From Where?  How many steps?  How many turns around corners, or up and down steps?  Whose kitchen?

The trick is to break your problem down into smaller stages, and then see if there's a set of computer commands to fulfill those needs.  If not, break those needs down smaller, until there are.

For example let's say I tell you to, "Print the contents of a file for me."

Breaking that order down to its components, we have to:

Choose a file.
Open that file.
Load the contents of that file in memory.
Print that file.
Repeat the last two steps until the whole file is printed.
Close the file.

Now, we have a basic step-by-step road map of how our program will look.

INPUT "Give me the name of the file you want to print ", filename$
OPEN filename$ FOR INPUT AS #1
DO
    LINE INPUT #1, text$
    PRINT text$
LOOP UNTIL EOF(1)
CLOSE #1


Take your complex problem and break it down to its step-by-step components.  If you can do that, you can write your own computer programs.

thanks steven for your suggestion



I also see that you are a good programmer

It is always an honor to have advice from you as an expert in programming
Title: Re: help my
Post by: Kiara87 on July 10, 2020, 06:11:28 pm
LOL I do like simple things like Peanut Butter and Jelly sandwiches. Gots to have the jelly though!

I guess I like making things simple, certainly things presented simply. But what I really like is thinking of something and seeing it work on the computer screen. That sense of power overcomes all the tedium and frustration that comes from practice with Basic.

I've been working on Sudoku for way over a year, just to check and see if my advanced level puzzles generated from my program are both unique and solvable. I think I have unique but solvable, still uncertain about that one.

Tower of Hanoi is boring after you "get" what it takes to solve the puzzle, it's about 10 or 20 steps repeated over and over in a certain order, so easy for a human to loose track of that order and start going backwards again! 🤦‍♂️

you are really good 
I'm also following your advice by playing with sudoku
this game is fantastic

I really like how you program I want to become as good as you
you can create anything with QB64

you are my master idol
Title: Re: help my
Post by: bplus on July 10, 2020, 06:57:37 pm
Quote
you are my master idol

Kind of embarrassing, kind of like it :)  Steve's OK too!

Here are some fun puzzles from a real master:  http://paulbourke.net/fun/
I just figured out the first one on the easy list.

Here is Terry Richie's QB64 tutorial that TempodiBasic and I can help you with :)
https://www.qb64sourcecode.com

Be sure to bookmark this:
https://www.qb64.org/wiki/Main_Page

Just 10,000 more hours of fun!
Title: Re: help my
Post by: TempodiBasic on July 10, 2020, 07:45:38 pm
Salve Kiara87
sembra che nonostante le difficoltà non demordi, brava questa è la prima dote di un buon programmatore la tenacia o la costanza se preferisci.

Dal mio codice vedo che non sei riuscita ad andare verso i tuoi obiettivi:
1 per ogni estrazione evidenziare le coppie di  numeri distanti 30 unità
2 salvare questa elaborazione per usarla altrove....

la  tua tenacia mi ha spinto a fornirti il compito risolto.... con tutta una serie di commenti in italiano... ma se vuoi attingere alla vera conoscenza nella programmazione impara un po' di inglese sia perchè le novità le trovi pubblicate in inglese perchè è una lingua universale... sia perchè puoi accedere alle risorse di tutto il mondo della programmazione.

Steve Bplus e _Vince ti hanno dato degli ottimi consigli sotto forma di lezioni che sembrano per principianti, ed in parte lo sono, ma sono sempre valide... sai come quando impari le 4 operazioni alle elementari ma le userai anche quando farai i calcoli di ingegneria o di fisica o di statistica combinatoria (come quella che stai cercando di sviluppare tu qui relativamente al gioco del lotto)

lo stile di programmazione che hai adottato tu con il tuo file Dafinire8.bas è detto spaghetti code perchè l'uso molteplice e continuo del GOTO se fosse evidenziato da un filo che segue il flusso di esecuzione del programma disegnerebbe una matassa di spaghetti ingarbugliati...
può funzionare, ma è molto difficile da correggere e da capire perchè ogni modifica che apporti non sai bene dove e cosa farà. Quindi difficile da costruire in maniera funzionale, difficile da capire quando lo rileggi dopo tempo, difficile da modificare per una espansione o per un adattamento ad un altro compito similare.
 
Lo stile di programmazione usato dai mitici amici Steve Bplus _Vince e tutti gli altri programmatori di questa community è prevalentemente modulare giacchè Qbasic e QB64 sono linguaggi procedurali o modulari... lo schema che ti ho postato come immagine in questo thread ti indica come progettare un programma per scriverlo in maniera efficiente, rapido, che funzioni, facile da capire, facile da modificare, facile da adattare....
è lo stesso suggerimento di Steve di suddividere l'azione che deve compiere il tuo programma in tante piccole azioni sequenziali e limitare ciascuna di queste in un blocco di codice detto procedura o subroutine o funzione (quando ti da indietro un risultato), e poi se possibile suddividere queste in ulteriori procedure più piccole fino a raggiungere un livello accettabile di semplicità. Fatto questo puoi iniziare a tradurre questo procedimento che si chiama ALGORITMO in CODICE SORGENTE ossia codice che usa parole tipiche di un linguaggio di programmazione e qui tu hai scelto il QB64.  Infine con la compilazione il compilatore traduce questo codice ad alto livello in codice binario (una sequenza di 0 e 1 ) che ha significato per la macchina computer e che esegue sempre e solo quello che tu gli hai detto di fare. Mai niente di più. Quindi quando non ottieni il risultato o l'algoritmo è sbagliato o il codice sorgente è sbagliato. In entrambi i casi l' errore è del programmatore. ;-)

e dopo tante chiacchiere ecco il codice sorgente in QB64 del programma cerca coppie di numeri a distanza di 30 unità nella estrazione del lotto leggendo i dati di estrazione da un file di testo in cui ogni riga contiene i dati come una sola cifra. (questa ti sembra una definizione più chiara del programma e di ciò che fa?)
1.
prendi i dati -->
    leggi i dati dal file e memorizzali in RAM (mediante variabili)-->
    apri il file di dati e leggi i dati e copiali in variabile/variabili dopo aver dichiarato le variabili


2.
analizza i dati estraendo i numeri distanti 30 in ogni estrazione lotto --> la singola sequenza della singola estrazione è formata da 4 cifre iniziali di riga che sono il numero estrazione e da 110 cifre che sono i numeri estratti (ogni numero estratto va da 01 a 90 rappresentati da 2 cifre) le ruote di estrazioni sono 11 e ogni estrazione ha 5 cifre estratte quindi 2*5*11 = 110

Accedendo al file in maniera binaria ossia a basso livello dobbiamo considerare che il segno che di andare a capo corrisponde ad altri 2 carattere CR+LF che corrispondono ai numeri ASCII 13 e 10, quindi accedendo in maniera binaria a basso livello ogni riga termina con questa coppia di numeri ASCII e quindi ogni riga è lunga in modalità testo 4+110 = 114 mentre in modalità binaria 4+110+CR+LF = 116 caratteri

3.
stampa e memorizza i dati estratti --> mostra con colore diverso a video e scrivi su file i dati estratti
ho trovato molto più semplice scrivere tutta la griglia di numeri non analizzati con il colore dei numeri NON distanti 30 e riscrivere poi in secondo tempo i numeri con distanza 30 in altro colore. Mentre la griglia di lettura ossia le ruote e il numero di estrazione hanno un colore diverso per meglio distinguerle. Nella stessa procedura di cerca distanza 30 ho messo la memorizzazione su file degli stessi, mentre il numero estrazione viene segnato nel ciclo (loop) principale.

Code: QB64: [Select]
  1. ' Programma lotto di kiara87
  2. ' il programma legge i dati (numeri estratti da un file.dat)
  3. ' e permette di vedere  le estrazioni a video
  4. ' i numeri con distanza 30 sono evidenziati con colore rosso
  5. ' questi numeri vengono memorizzati e stampati
  6.  
  7. ' Nota 1: sono d'accordo con Bplus e' molto piu'
  8. ' rapido lavorare con dati in RAM che con dati su Disco HDD/SSD/USB/CD/DVD
  9.  
  10. ' valori COSTANTI  generali Vero e Falso
  11. CONST True = -1, False = NOT True
  12. ' le 11 ruote del lotto
  13. CONST Bari = 1, Cagliari = 2, Firenze = 3, Genova = 4, Milano = 5
  14. CONST Napoli = 6, Palermo = 7, Roma = 8, Torino = 9, Venezia = 10, Nazionale = 11
  15. CONST Cifra = 2 ' ogni numero estratto e' una cifra di due caratteri (01-90)
  16.  
  17. DIM a AS STRING ' una stringa per leggere i dati dal file
  18.  
  19. ' salta al sottoprogramma LeggiFile delimitato
  20. ' dalla Label LeggiFIle e dal RETURN
  21. GOSUB LeggiFile
  22.  
  23. ' verifica che tutto il file sia letto
  24. 'FOR b = 1 TO LEN(a) - 116 STEP 116
  25. '    PRINT MID$(a, b, 116)
  26. '    '    PRINT INSTR(b, a, CHR$(13))
  27. '    _DELAY .1
  28. 'NEXT b
  29.  
  30.  
  31.  
  32. ' il ciclo DO...LOOP UNTIL condizione e' un modo piu' moderno
  33. ' rispetto a Etichetta: .... IF condizione GOTO Etichetta
  34. b = 1
  35. z$ = " "
  36. OPEN "distanza30.dat" FOR APPEND AS #2
  37.     IF z$ <> "" THEN
  38.         CLS ' questo risolve un glitch di output sullo schermo
  39.         ' in alternativa alla riga sopra CLS nel sottoblocco
  40.         ' MostraEstratti va stampata la stringa estratto e
  41.         ' non il suo valore corrispondente ottenuto con VAL
  42.         GOSUB MostraRuote ' scrive il nome delle ruote del lotto
  43.         GOSUB MostraEstratti
  44.     END IF
  45.     ' prende l'input dell'utente
  46.     z$ = UCASE$(INKEY$) ' Z$ mantiene il maiuscolo di Inkey$
  47.     IF z$ = "+" AND b < (LEN(a) - 116) THEN b = b + 116
  48.     IF z$ = "-" AND b > 116 THEN b = b - 116
  49. LOOP UNTIL z$ = "Q"
  50.  
  51. END ' indica la fine logica del programma
  52.  
  53.  
  54. '-----------------------AREA sottoprogrammi /SUBroutines
  55.  
  56. ' questa etichetta /label indica il punto di inizio
  57. ' del sottoprogramma (SUBroutine) LeggiFile scritto con vecchio stile GOSUB
  58. ' che usa una etichetta/label e un RETURN per riprendere da dove si era interotto
  59. ' nota1: un metodo ancora piu' antico e' il salto con GOTO
  60. '        che richiede una seconda etichetta per ritornare nel MAIN o programma principale
  61. ' nota2: un metodo migliore e' SUB nomeroutine....END SUB
  62. '        perche' permette la localizzazione delle variabili
  63. LeggiFile:
  64. 'se non trova lotto.dat segnala l'errore a video e termina il programma
  65. IF NOT _FILEEXISTS("lotto.dat") THEN PRINT "File non trovato": END
  66. '<--------------------
  67. ' questo metodo e' piu' lento
  68. ' apre il file lotto.dat per leggere in maniera sequenziale i dati
  69. 'OPEN "lotto.dat" FOR INPUT AS #1
  70. 'LINE INPUT #1, a  ' riempe la variabile a con una riga intera di valori
  71. '<--------------------
  72.  
  73. ' apre lotto.dat per leggerlo in maniera binaria
  74. OPEN "lotto.dat" FOR BINARY AS #1
  75. a = SPACE$(LOF(1)) ' riempe la variabile a di spazi fino alla grandezza in byte del file aperto
  76. GET #1, , a ' legge con una unica operazione il file e lo pone nella variabiel a
  77. CLOSE #1 ' chiude il file appena letto
  78. ' indica il termine della SUBroutine LeggiFile
  79. ' e RITORNA alla riga di codice successiva al salto GOSUB
  80.  
  81. 'seconda SUBroutine /sottoprogramma
  82. MostraRuote:
  83. COLOR 7, 6
  84. LOCATE 1, 1
  85. PRINT "BARI"
  86. LOCATE 3, 1
  87. PRINT "CAGLIARI"
  88. LOCATE 5, 1
  89. PRINT "FIRENZE"
  90. LOCATE 7, 1
  91. PRINT "GENOVA"
  92. LOCATE 9, 1
  93. PRINT "MILANO"
  94. LOCATE 11, 1
  95. PRINT "NAPOLI"
  96. LOCATE 13, 1
  97. PRINT "PALERMO"
  98. LOCATE 15, 1
  99. PRINT "ROMA"
  100. LOCATE 17, 1
  101. PRINT "TORINO"
  102. LOCATE 19, 1
  103. PRINT "VENEZIA"
  104. LOCATE 21, 1
  105. PRINT "NAZIONALE"
  106. LOCATE 23, 1
  107. PRINT "premi q per terminare, + avanti, - indietro"
  108.  
  109. ' indica il termine della SUBroutine MostraRuote
  110. ' e RITORNA alla riga di codice successiva al salto GOSUB
  111.  
  112. 'terzo sottoprogramma o SUBroutine
  113. MostraEstratti:
  114.  
  115. ' le prime 4 cifre sembrano essere in numero della estrazione
  116. LOCATE 1, 40
  117. PRINT "estraz.num "; MID$(a, b, 4)
  118. PRINT #2, "estraz.num "; MID$(a, b, 4)
  119. y = 13 ' prima posizione per il carattere da stampare
  120. FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR e' di 5 perche' ogni ruota ha 5 estrazioni
  121.     A1 = "" ' resetto a1 per il prossimo giro
  122.     FOR V = Bari TO Nazionale ' per tutte le ruote
  123.         COLOR 15, 0
  124.         'posiziona il cursore
  125.         LOCATE (V * 2) - 1, y
  126.         ' scrive il numero estratto
  127.         PRINT VAL(MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); " ";
  128.         A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))
  129.     NEXT V
  130.     GOSUB Mostra30
  131.     y = POS(0)
  132. ' indica il termine della SUBroutine MostraEstratti
  133. ' e RITORNA alla riga di codice successiva al salto GOSUB
  134.  
  135.  
  136. Mostra30:
  137. FOR v1 = Bari TO Venezia ' per tutte le ruote
  138.     FOR v2 = v1 + 1 TO Nazionale
  139.         IF ABS(VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)) - VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))) = 30 THEN
  140.             COLOR 1, 0
  141.             'posiziona                                                                      il cursore
  142.             LOCATE (v1 * 2) - 1, y
  143.             ' scrive il numero estratto
  144.             PRINT VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); " ";
  145.             PRINT #2, (MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))
  146.             'posiziona                                                                      il cursore
  147.             LOCATE (v2 * 2) - 1, y
  148.             ' scrive il numero estratto
  149.             PRINT VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); " ";
  150.             PRINT #2, MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)
  151.         END IF
  152.     NEXT v2
  153. NEXT v1
  154. COLOR 15, 0
  155. ' indica il termine della SUBroutine MostraEstratti
  156. ' e RITORNA alla riga di codice successiva al salto GOSUB
e questo è lo screenshot
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

osservazioni:
-lavorare in RAM è molto più veloce che lavorare su disco
-accedere al file in maniera binaria ti permette di caricare tutto il file in RAM con una unica istruzione
-con MID$ sapendo la struttura della singola estrazione del lotto |numero di 4 cifre|estrazioni di 110cifre 1ruota5estrazioni2ruota5estrazioni...11ruota5estrazioni|acapo CR+LF| puoi navigare attraverso i dati con sicurezza

-una alternativa validissima è l'uso di un array dinamico
Code: QB64: [Select]
  1. REDIM Estrazioni (1 to Max) AS STRING
  2.  

-una altra alternativa validissima è l'uso di una UDT con TYPE---END TYPE con un array dinamico
ad esempio
Code: QB64: [Select]
  1. TYPE Estrazione
  2.    Numestrazione AS STRING * 4
  3.    EstrattiBari AS STRING * 10
  4.    EstrattiCagliari AS STRING * 10
  5.    EstrattiFirenze AS STRING * 10
  6.    ...
  7.    EstrattiNazionale AS STRING * 10
  8.  
  9. REDIM Lotto (1 to Max) AS Estrazione
  10.  

Buona avventura nel mondo della programmazione e non cadere nella trappola dei principianti che cambiano continuamente linguaggio perchè pensano di poter farme meglio con una altro rispetto a quello che stanno imparando... ;)
Title: Re: help my
Post by: Kiara87 on July 11, 2020, 06:48:46 am
grazie @TempodiBasic
anche te sei una macchinetta di programmazione il tuo stile di programmazione e ottimo
solamente che sono io che ancora non riesco a leggere bene il codice essendo ancora alle prime armi
grazie per la tua spiegazione sei molto gentile e grazie per avermi imparato di scrivere il codice in pseudocodice
poi il problema e' quello di convertire in codice sorgente pero' credo che con il tempo imparo anche questo
tutte le tue spiegazioni servono e' cerchero di mettere in atto anche se alcuni punti non riesco a capire anche se sono bene dettagliate
hai ragione il mio primo codice era codice spaghetti inizialmente non sapevo il significato sono andato su internet e ho capito cosa intendi
troppi goto  un codice con troppi nodi che non si riesce a leggere come ho capito anche se esiste istruzione goto meglio evitarla
ho visto codice append che crea un file che poi lo rilegge devo ancora studiare anche questo

la cosa che mi viene molto difficile da capire e' questa parte qui
Code: QB64: [Select]
  1. LOCATE 1, 40
  2. PRINT "estraz.num "; MID$(a, b, 4)
  3. PRINT #2, "estraz.num "; MID$(a, b, 4)
  4. y = 13 ' prima posizione per il carattere da stampare
  5. FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR e' di 5 perche' ogni ruota ha 5 estrazioni
  6.     A1 = "" ' resetto a1 per il prossimo giro
  7.     FOR V = Bari TO Nazionale ' per tutte le ruote
  8.         COLOR 15, 0
  9.         'posiziona il cursore
  10.         LOCATE (V * 2) - 1, y
  11.         ' scrive il numero estratto
  12.         PRINT VAL(MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); " ";
  13.         A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))
  14.     NEXT V
  15.     GOSUB Mostra30
  16.     y = POS(0)
  17.  
come voi programmatori posizionate i numeri con i locate e li distanziate
esempio: mentre io usavo locate 1,10 ecc..
e un altro punto che devo ancora adattarmi  esempio io il file lo leggevo con la variabile a e mid$ ma devo capire la funzione di altri variabili aggiunti -->
PRINT VAL(MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); " ";
        A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))

credo che per capirle cerchero di modificare i valori

una domanda magari banale per saper programmare ci vuole conoscenza di matematica? oppure la conoscenda di matematica ci vuole per questo tipo di programma?
per conoscenza matematica non intendo quella elementare ma superiore alle scuole basi

ancora grazie e' sei stato moltissimo di aiuto a spiegare la tua esperienza e condividerla qui
ovviamente si deve studiare per imparare
io ricordo che le prime volte domandavo sui forum quanto tempo ci vuole per imparare a programmare
adesso forse la risposta e' dipende quante ore studi al giorno
io non ho tanto tempo magari 1 oppure 2 ore al giorno
magari ci impiego di piu'
ma non mollerò


Salve Kiara87
sembra che nonostante le difficoltà non demordi, brava questa è la prima dote di un buon programmatore la tenacia o la costanza se preferisci.

Dal mio codice vedo che non sei riuscita ad andare verso i tuoi obiettivi:
1 per ogni estrazione evidenziare le coppie di  numeri distanti 30 unità
2 salvare questa elaborazione per usarla altrove....

la  tua tenacia mi ha spinto a fornirti il compito risolto.... con tutta una serie di commenti in italiano... ma se vuoi attingere alla vera conoscenza nella programmazione impara un po' di inglese sia perchè le novità le trovi pubblicate in inglese perchè è una lingua universale... sia perchè puoi accedere alle risorse di tutto il mondo della programmazione.

Steve Bplus e _Vince ti hanno dato degli ottimi consigli sotto forma di lezioni che sembrano per principianti, ed in parte lo sono, ma sono sempre valide... sai come quando impari le 4 operazioni alle elementari ma le userai anche quando farai i calcoli di ingegneria o di fisica o di statistica combinatoria (come quella che stai cercando di sviluppare tu qui relativamente al gioco del lotto)

lo stile di programmazione che hai adottato tu con il tuo file Dafinire8.bas è detto spaghetti code perchè l'uso molteplice e continuo del GOTO se fosse evidenziato da un filo che segue il flusso di esecuzione del programma disegnerebbe una matassa di spaghetti ingarbugliati...
può funzionare, ma è molto difficile da correggere e da capire perchè ogni modifica che apporti non sai bene dove e cosa farà. Quindi difficile da costruire in maniera funzionale, difficile da capire quando lo rileggi dopo tempo, difficile da modificare per una espansione o per un adattamento ad un altro compito similare.
 
Lo stile di programmazione usato dai mitici amici Steve Bplus _Vince e tutti gli altri programmatori di questa community è prevalentemente modulare giacchè Qbasic e QB64 sono linguaggi procedurali o modulari... lo schema che ti ho postato come immagine in questo thread ti indica come progettare un programma per scriverlo in maniera efficiente, rapido, che funzioni, facile da capire, facile da modificare, facile da adattare....
è lo stesso suggerimento di Steve di suddividere l'azione che deve compiere il tuo programma in tante piccole azioni sequenziali e limitare ciascuna di queste in un blocco di codice detto procedura o subroutine o funzione (quando ti da indietro un risultato), e poi se possibile suddividere queste in ulteriori procedure più piccole fino a raggiungere un livello accettabile di semplicità. Fatto questo puoi iniziare a tradurre questo procedimento che si chiama ALGORITMO in CODICE SORGENTE ossia codice che usa parole tipiche di un linguaggio di programmazione e qui tu hai scelto il QB64.  Infine con la compilazione il compilatore traduce questo codice ad alto livello in codice binario (una sequenza di 0 e 1 ) che ha significato per la macchina computer e che esegue sempre e solo quello che tu gli hai detto di fare. Mai niente di più. Quindi quando non ottieni il risultato o l'algoritmo è sbagliato o il codice sorgente è sbagliato. In entrambi i casi l' errore è del programmatore. ;-)

e dopo tante chiacchiere ecco il codice sorgente in QB64 del programma cerca coppie di numeri a distanza di 30 unità nella estrazione del lotto leggendo i dati di estrazione da un file di testo in cui ogni riga contiene i dati come una sola cifra. (questa ti sembra una definizione più chiara del programma e di ciò che fa?)
1.
prendi i dati -->
    leggi i dati dal file e memorizzali in RAM (mediante variabili)-->
    apri il file di dati e leggi i dati e copiali in variabile/variabili dopo aver dichiarato le variabili


2.
analizza i dati estraendo i numeri distanti 30 in ogni estrazione lotto --> la singola sequenza della singola estrazione è formata da 4 cifre iniziali di riga che sono il numero estrazione e da 110 cifre che sono i numeri estratti (ogni numero estratto va da 01 a 90 rappresentati da 2 cifre) le ruote di estrazioni sono 11 e ogni estrazione ha 5 cifre estratte quindi 2*5*11 = 110

Accedendo al file in maniera binaria ossia a basso livello dobbiamo considerare che il segno che di andare a capo corrisponde ad altri 2 carattere CR+LF che corrispondono ai numeri ASCII 13 e 10, quindi accedendo in maniera binaria a basso livello ogni riga termina con questa coppia di numeri ASCII e quindi ogni riga è lunga in modalità testo 4+110 = 114 mentre in modalità binaria 4+110+CR+LF = 116 caratteri

3.
stampa e memorizza i dati estratti --> mostra con colore diverso a video e scrivi su file i dati estratti
ho trovato molto più semplice scrivere tutta la griglia di numeri non analizzati con il colore dei numeri NON distanti 30 e riscrivere poi in secondo tempo i numeri con distanza 30 in altro colore. Mentre la griglia di lettura ossia le ruote e il numero di estrazione hanno un colore diverso per meglio distinguerle. Nella stessa procedura di cerca distanza 30 ho messo la memorizzazione su file degli stessi, mentre il numero estrazione viene segnato nel ciclo (loop) principale.

Code: QB64: [Select]
  1. ' Programma lotto di kiara87
  2. ' il programma legge i dati (numeri estratti da un file.dat)
  3. ' e permette di vedere  le estrazioni a video
  4. ' i numeri con distanza 30 sono evidenziati con colore rosso
  5. ' questi numeri vengono memorizzati e stampati
  6.  
  7. ' Nota 1: sono d'accordo con Bplus e' molto piu'
  8. ' rapido lavorare con dati in RAM che con dati su Disco HDD/SSD/USB/CD/DVD
  9.  
  10. ' valori COSTANTI  generali Vero e Falso
  11. CONST True = -1, False = NOT True
  12. ' le 11 ruote del lotto
  13. CONST Bari = 1, Cagliari = 2, Firenze = 3, Genova = 4, Milano = 5
  14. CONST Napoli = 6, Palermo = 7, Roma = 8, Torino = 9, Venezia = 10, Nazionale = 11
  15. CONST Cifra = 2 ' ogni numero estratto e' una cifra di due caratteri (01-90)
  16.  
  17. DIM a AS STRING ' una stringa per leggere i dati dal file
  18.  
  19. ' salta al sottoprogramma LeggiFile delimitato
  20. ' dalla Label LeggiFIle e dal RETURN
  21. GOSUB LeggiFile
  22.  
  23. ' verifica che tutto il file sia letto
  24. 'FOR b = 1 TO LEN(a) - 116 STEP 116
  25. '    PRINT MID$(a, b, 116)
  26. '    '    PRINT INSTR(b, a, CHR$(13))
  27. '    _DELAY .1
  28. 'NEXT b
  29.  
  30.  
  31.  
  32. ' il ciclo DO...LOOP UNTIL condizione e' un modo piu' moderno
  33. ' rispetto a Etichetta: .... IF condizione GOTO Etichetta
  34. b = 1
  35. z$ = " "
  36. OPEN "distanza30.dat" FOR APPEND AS #2
  37.     IF z$ <> "" THEN
  38.         CLS ' questo risolve un glitch di output sullo schermo
  39.         ' in alternativa alla riga sopra CLS nel sottoblocco
  40.         ' MostraEstratti va stampata la stringa estratto e
  41.         ' non il suo valore corrispondente ottenuto con VAL
  42.         GOSUB MostraRuote ' scrive il nome delle ruote del lotto
  43.         GOSUB MostraEstratti
  44.     END IF
  45.     ' prende l'input dell'utente
  46.     z$ = UCASE$(INKEY$) ' Z$ mantiene il maiuscolo di Inkey$
  47.     IF z$ = "+" AND b < (LEN(a) - 116) THEN b = b + 116
  48.     IF z$ = "-" AND b > 116 THEN b = b - 116
  49. LOOP UNTIL z$ = "Q"
  50.  
  51. END ' indica la fine logica del programma
  52.  
  53.  
  54. '-----------------------AREA sottoprogrammi /SUBroutines
  55.  
  56. ' questa etichetta /label indica il punto di inizio
  57. ' del sottoprogramma (SUBroutine) LeggiFile scritto con vecchio stile GOSUB
  58. ' che usa una etichetta/label e un RETURN per riprendere da dove si era interotto
  59. ' nota1: un metodo ancora piu' antico e' il salto con GOTO
  60. '        che richiede una seconda etichetta per ritornare nel MAIN o programma principale
  61. ' nota2: un metodo migliore e' SUB nomeroutine....END SUB
  62. '        perche' permette la localizzazione delle variabili
  63. LeggiFile:
  64. 'se non trova lotto.dat segnala l'errore a video e termina il programma
  65. IF NOT _FILEEXISTS("lotto.dat") THEN PRINT "File non trovato": END
  66. '<--------------------
  67. ' questo metodo e' piu' lento
  68. ' apre il file lotto.dat per leggere in maniera sequenziale i dati
  69. 'OPEN "lotto.dat" FOR INPUT AS #1
  70. 'LINE INPUT #1, a  ' riempe la variabile a con una riga intera di valori
  71. '<--------------------
  72.  
  73. ' apre lotto.dat per leggerlo in maniera binaria
  74. OPEN "lotto.dat" FOR BINARY AS #1
  75. a = SPACE$(LOF(1)) ' riempe la variabile a di spazi fino alla grandezza in byte del file aperto
  76. GET #1, , a ' legge con una unica operazione il file e lo pone nella variabiel a
  77. CLOSE #1 ' chiude il file appena letto
  78. ' indica il termine della SUBroutine LeggiFile
  79. ' e RITORNA alla riga di codice successiva al salto GOSUB
  80.  
  81. 'seconda SUBroutine /sottoprogramma
  82. MostraRuote:
  83. COLOR 7, 6
  84. LOCATE 1, 1
  85. PRINT "BARI"
  86. LOCATE 3, 1
  87. PRINT "CAGLIARI"
  88. LOCATE 5, 1
  89. PRINT "FIRENZE"
  90. LOCATE 7, 1
  91. PRINT "GENOVA"
  92. LOCATE 9, 1
  93. PRINT "MILANO"
  94. LOCATE 11, 1
  95. PRINT "NAPOLI"
  96. LOCATE 13, 1
  97. PRINT "PALERMO"
  98. LOCATE 15, 1
  99. PRINT "ROMA"
  100. LOCATE 17, 1
  101. PRINT "TORINO"
  102. LOCATE 19, 1
  103. PRINT "VENEZIA"
  104. LOCATE 21, 1
  105. PRINT "NAZIONALE"
  106. LOCATE 23, 1
  107. PRINT "premi q per terminare, + avanti, - indietro"
  108.  
  109. ' indica il termine della SUBroutine MostraRuote
  110. ' e RITORNA alla riga di codice successiva al salto GOSUB
  111.  
  112. 'terzo sottoprogramma o SUBroutine
  113. MostraEstratti:
  114.  
  115. ' le prime 4 cifre sembrano essere in numero della estrazione
  116. LOCATE 1, 40
  117. PRINT "estraz.num "; MID$(a, b, 4)
  118. PRINT #2, "estraz.num "; MID$(a, b, 4)
  119. y = 13 ' prima posizione per il carattere da stampare
  120. FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR e' di 5 perche' ogni ruota ha 5 estrazioni
  121.     A1 = "" ' resetto a1 per il prossimo giro
  122.     FOR V = Bari TO Nazionale ' per tutte le ruote
  123.         COLOR 15, 0
  124.         'posiziona il cursore
  125.         LOCATE (V * 2) - 1, y
  126.         ' scrive il numero estratto
  127.         PRINT VAL(MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); " ";
  128.         A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))
  129.     NEXT V
  130.     GOSUB Mostra30
  131.     y = POS(0)
  132. ' indica il termine della SUBroutine MostraEstratti
  133. ' e RITORNA alla riga di codice successiva al salto GOSUB
  134.  
  135.  
  136. Mostra30:
  137. FOR v1 = Bari TO Venezia ' per tutte le ruote
  138.     FOR v2 = v1 + 1 TO Nazionale
  139.         IF ABS(VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)) - VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))) = 30 THEN
  140.             COLOR 1, 0
  141.             'posiziona                                                                      il cursore
  142.             LOCATE (v1 * 2) - 1, y
  143.             ' scrive il numero estratto
  144.             PRINT VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); " ";
  145.             PRINT #2, (MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))
  146.             'posiziona                                                                      il cursore
  147.             LOCATE (v2 * 2) - 1, y
  148.             ' scrive il numero estratto
  149.             PRINT VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); " ";
  150.             PRINT #2, MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)
  151.         END IF
  152.     NEXT v2
  153. NEXT v1
  154. COLOR 15, 0
  155. ' indica il termine della SUBroutine MostraEstratti
  156. ' e RITORNA alla riga di codice successiva al salto GOSUB
e questo è lo screenshot
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

osservazioni:
-lavorare in RAM è molto più veloce che lavorare su disco
-accedere al file in maniera binaria ti permette di caricare tutto il file in RAM con una unica istruzione
-con MID$ sapendo la struttura della singola estrazione del lotto |numero di 4 cifre|estrazioni di 110cifre 1ruota5estrazioni2ruota5estrazioni...11ruota5estrazioni|acapo CR+LF| puoi navigare attraverso i dati con sicurezza

-una alternativa validissima è l'uso di un array dinamico
Code: QB64: [Select]
  1. REDIM Estrazioni (1 to Max) AS STRING
  2.  

-una altra alternativa validissima è l'uso di una UDT con TYPE---END TYPE con un array dinamico
ad esempio
Code: QB64: [Select]
  1. TYPE Estrazione
  2.    Numestrazione AS STRING * 4
  3.    EstrattiBari AS STRING * 10
  4.    EstrattiCagliari AS STRING * 10
  5.    EstrattiFirenze AS STRING * 10
  6.    ...
  7.    EstrattiNazionale AS STRING * 10
  8.  
  9. REDIM Lotto (1 to Max) AS Estrazione
  10.  

Buona avventura nel mondo della programmazione e non cadere nella trappola dei principianti che cambiano continuamente linguaggio perchè pensano di poter farme meglio con una altro rispetto a quello che stanno imparando... ;)
Title: Re: help my
Post by: TempodiBasic on July 11, 2020, 12:19:49 pm
@ kiara87
about
Quote
come voi programmatori posizionate i numeri con i locate e li distanziate
esempio: mentre io usavo locate 1,10 ecc..
PRINT si comporta in maniera differente se stampa un numero o una stringa
nell'elaborare l'output grafico della tabella dei numeri estratti mi sono imbattuto in un glitch perchè appunto la scritta a video viene spostata a seconda che si tratti di una cifra o 2 cifre.

Il problema ha 2 possibili soluzioni 1. ripulire lo schermo prima di riscriverlo come ho fatto io mettendo il CLS nel loop principale del programma (nel main) oppure 2 stampare la stringa invece del numero corrispondente (la differenza è che a video tu vedrai 02 al posto di 2)
una terza via 3. è usare l'struzione PRINT USING (come ti ha suggerito Bplus) per formattare l'output a video (questo è analogo al C  Printf(%d,%f...),a,c,...)

il
Code: QB64: [Select]
  1.    FOR V = Bari TO Nazionale ' per tutte le ruote
  2.         COLOR 15, 0
  3.         'posiziona il cursore
  4.         LOCATE (V * 2) - 1, y
usa la variabile del ciclo FOR per tutte le ruote (da Bari a Nazionale) per posizionare la riga (devi ricordare che SCREEN 0, ossia la modalità di video solo testo è di default in QB se non definisci alcuna modalità video, essa è detta anche modalità console e come default ha 80 colonne e 25 righe, cerca nella wiki per maggiori informazioni) mentre y definisce la colonna da cui partire a stampare il testo... la ; permette di non andare a capo dopo la scrittura

about
Quote
e un altro punto che devo ancora adattarmi  esempio io il file lo leggevo con la variabile a e mid$ ma devo capire la funzione di altri variabili aggiunti -->
PRINT VAL(MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); " ";
qui si dice al PC di stampare a video il valore della parte della stringa a, estratta con MID$ a partire dalla posizione  (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1)  e di lunghezza Cifra (ricorda che Cifra è una costante di valore 2 ossia al posto di Cifra tu leggi di lunghezza 2 caratteri)
quindi NON stai leggendo dal file ora ma stai NAVIGANDO il file contenuto interamente nella variabile a di tipo stringa mentre qui è stato letto il file 
Code: QB64: [Select]
  1. ' apre lotto.dat per leggerlo in maniera binaria
  2. OPEN "lotto.dat" FOR BINARY AS #1
  3. a = SPACE$(LOF(1)) ' riempe la variabile a di spazi fino alla grandezza in byte del file aperto
  4. GET #1, , a ' legge con una unica operazione il file e lo pone nella variabile a
  5. CLOSE #1 ' chiude il file appena letto
Come fai a sapere dove sei nella variabile a e cosa stai leggendo?
questa è la bussola
Quote
analizza i dati estraendo i numeri distanti 30 in ogni estrazione lotto --> la singola sequenza della singola estrazione è formata da 4 cifre iniziali di riga che sono il numero estrazione e da 110 cifre che sono i numeri estratti (ogni numero estratto va da 01 a 90 rappresentati da 2 cifre) le ruote di estrazioni sono 11 e ogni estrazione ha 5 cifre estratte quindi 2*5*11 = 110

Accedendo al file in maniera binaria ossia a basso livello dobbiamo considerare che il segno che di andare a capo corrisponde ad altri 2 carattere CR+LF che corrispondono ai numeri ASCII 13 e 10, quindi accedendo in maniera binaria a basso livello ogni riga termina con questa coppia di numeri ASCII e quindi ogni riga è lunga in modalità testo 4+110 = 114 mentre in modalità binaria 4+110+CR+LF = 116 caratteri
Buon studio e buon lavoro sulla comprensione e memorizzazione della sintassi.
Non preoccuparti se non ricordi bene tutto, la wiki c'è apposta. Ancora oggi mi chiedo spesso se LOCATE vuole riga,colonna o colonna,riga e la wiki risolve spesso! ;)
Title: Re: help my
Post by: Kiara87 on July 12, 2020, 06:59:59 pm
@ kiara87

salve TempodiBasic volevo chiederti riguardo sulla funzione goto i programmatori la evitano a  causa del stile spaghetti
quindi evitano anche GOSUB visto che GOSUB è identica come istruzione giusto?
Title: Re: help my
Post by: bplus on July 13, 2020, 10:46:36 am
@Kiara87

Can you count and list the words in this sentence?

Can you write code to count and list the words in any given sentence?

Can you count the words in reply #85 above? Hope you don't get an overflow error ;-))

Can you count the QB64 CODE words in reply #84?

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Hmm... looks like we will have to do something about punctuation ;-))

Title: Re: help my
Post by: TempodiBasic on July 13, 2020, 01:45:17 pm
@Kiara87
GOTO  e GOSUB sono due bacchette magiche che l'apprendista stregone programmatore deve temere e ammirare. Sono potenti ma senza limiti quindi se non sai quello che stai facendo fai di certo un gran pasticcio, come topolino nell'apprendista stregone https://www.youtube.com/watch?v=U546yRNeNh4 (https://www.youtube.com/watch?v=U546yRNeNh4)

giusto per esercizio e per comprensione  tu poi considerare GOSUB  un GOTO semplificato perchè con RETURN ti permette di ritornare indietro all'istruzione del salto senza usare una ulteriore etichetta
Code: QB64: [Select]
  1. GOTO There
  2. Here:
  3. PRINT "Hi Guys"
  4.  
  5. There:
  6. PRINT "I'm QB64 coder "
  7. GOTO Here
  8.  

is the same that
Code: QB64: [Select]
  1. GOSUB There
  2. PRINT "Hi Guys"
  3.  
  4. There:
  5. PRINT "I'm QB64 coder "
  6.  

ma tu puoi costruire i loop WHILE..WEND, DO WHILE..LOOP, DO UNTIL..LOOP; DO..LOOP UNTIL, DO..LOOP WHILE con i rispettivi EXIT WHILE o EXIT DO usando il GOTO e le etichette, lo stesso per FOR NEXT...
prova come esercizio a creare questi loop con GOTO e li comprenderai meglio.

@bplus
PRINT LEN(88)
:-)
Title: Re: help my
Post by: bplus on July 13, 2020, 06:48:39 pm
Quote
Can you count the QB64 CODE words in reply #84?

Title: Re: help my
Post by: Kiara87 on July 13, 2020, 07:15:21 pm
@Kiara87

Can you count and list the words in this sentence?

Can you write code to count and list the words in any given sentence?

Can you count the words in reply #85 above? Hope you don't get an overflow error ;-))

Can you count the QB64 CODE words in reply #84?

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Hmm... looks like we will have to do something about punctuation ;-))
says the length of the file as in the image?
@Kiara87
GOTO  e GOSUB sono due bacchette magiche che l'apprendista stregone programmatore deve temere e ammirare. Sono potenti ma senza limiti quindi se non sai quello che stai facendo fai di certo un gran pasticcio, come topolino nell'apprendista stregone https://www.youtube.com/watch?v=U546yRNeNh4 (https://www.youtube.com/watch?v=U546yRNeNh4)

giusto per esercizio e per comprensione  tu poi considerare GOSUB  un GOTO semplificato perchè con RETURN ti permette di ritornare indietro all'istruzione del salto senza usare una ulteriore etichetta
Code: QB64: [Select]
  1. GOTO There
  2. Here:
  3. PRINT "Hi Guys"
  4.  
  5. There:
  6. PRINT "I'm QB64 coder "
  7. GOTO Here
  8.  

is the same that
Code: QB64: [Select]
  1. GOSUB There
  2. PRINT "Hi Guys"
  3.  
  4. There:
  5. PRINT "I'm QB64 coder "
  6.  

ma tu puoi costruire i loop WHILE..WEND, DO WHILE..LOOP, DO UNTIL..LOOP; DO..LOOP UNTIL, DO..LOOP WHILE con i rispettivi EXIT WHILE o EXIT DO usando il GOTO e le etichette, lo stesso per FOR NEXT...
prova come esercizio a creare questi loop con GOTO e li comprenderai meglio.

@bplus
PRINT LEN(88)
:-)
@TempodiBasic  si ho visto esempio che il gosub da un ritorno dal codice da dove era partito ritorna 1 volta nella sua postazione
sto seguendo i tuoi consigli che credo siano la soluzione per imparare a programmare scrivendo in pseudo codice
anche come spiega @SMcNeill dicendo di prendere il problema e dividerlo scomponendolo in sotto problemi
fino a qui ho percepito come mi avevi consigliato di scrivere in pseudocodice
è dividendo in sotto problemi risolvendoli uno ad uno
ma il problema poi sta come converto i problemi al  codice?
come cerco tutte le istruzioni su wiki oppure sul help dvo sempre sapere come cercare quelle istruzioni che servono per convertire il pseudo codice in codice QB64
Title: Re: help my
Post by: Kiara87 on July 13, 2020, 07:33:40 pm
thanks to you, you are cunning
by dividing the problem into small problems
and step by step explanation though 'I have to say it with programming code I have to understand how to convert my explanations step by step into programming language
as you did in the example of the peanut sandwich it is easy but the most difficult part is to look for the programming language commands as you said I have to look for the ingredients for the recipe
where do i find them?
on wiki or help
how should i search?
@Kiara87

Can you count and list the words in this sentence?

Can you write code to count and list the words in any given sentence?

Can you count the words in reply #85 above? Hope you don't get an overflow error ;-))

Can you count the QB64 CODE words in reply #84?

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Hmm... looks like we will have to do something about punctuation ;-))



If it helps, Kiara, remember this -- All computer programming breaks down to 3 steps:

1) Step by step commands
2) Decision making
3) Repetition

Take any problem facing you, and you can break its solution down to those 3 steps (including life problems).  Let's say I tell you, "Make me a peanut butter sandwich."   How do you accomplish that task?

Get up.
Go in kitchen.
Get a knife.
Get bread.
Get peanut butter.
Open bread, remove a slice.
Put knife in peanut butter.
Remove knife from peanut butter.
Wipe knife on bread.
Put down knife.
Remove slice of bread from pack.
Place bread on bread.

And there's the biggest problem programmers usually face -- we think "fix a sandwich", and we do it.  The computer has to have that instruction broken down step-by-step, to accomplish the same task...  It's not the complexity of the problem that confound us; it's the simplicity of the computer.

Even with the above set of instructions, it's probably not enough for your pet robot to make that sandwich.  "Get up" implies it was down somewhere.  "Go in kitchen" is vague.  From Where?  How many steps?  How many turns around corners, or up and down steps?  Whose kitchen?

The trick is to break your problem down into smaller stages, and then see if there's a set of computer commands to fulfill those needs.  If not, break those needs down smaller, until there are.

For example let's say I tell you to, "Print the contents of a file for me."

Breaking that order down to its components, we have to:

Choose a file.
Open that file.
Load the contents of that file in memory.
Print that file.
Repeat the last two steps until the whole file is printed.
Close the file.

Now, we have a basic step-by-step road map of how our program will look.

INPUT "Give me the name of the file you want to print ", filename$
OPEN filename$ FOR INPUT AS #1
DO
    LINE INPUT #1, text$
    PRINT text$
LOOP UNTIL EOF(1)
CLOSE #1


Take your complex problem and break it down to its step-by-step components.  If you can do that, you can write your own computer programs.

@bplus  I tried to copy the sentences from the site and save the sentences in txt

I read the file with this
Code: QB64: [Select]
  1. OPEN "leggi.txt" FOR INPUT AS #1
  2. INPUT #1, a$
  3.  

gives me length 86
I had attached image in the previous answer
but I was unable to put the sentences inside
Title: Re: help my
Post by: bplus on July 13, 2020, 09:46:14 pm
Quote
@bplus  I tried to copy the sentences from the site and save the sentences in txt

I read the file with this
Code: QB64: [Select]
OPEN "leggi.txt" FOR INPUT AS #1
INPUT #1, a$
PRINT LEN(a$)
CLOSE
 

gives me length 86
I had attached image in the previous answer
but I was unable to put the sentences inside

OK that is only the length of the first line from the file.


To count words in a sentence (forget about files for moment) you will need these tools:
MID$(aString$, aStartPlace, aLength)
LEN(aString$)

He$ = MID$("Hello World", 1, 2)  ' He$ = "He"
Wor$ = MID$("Hello World", 7, 3) ' Wor$ = "Wor"
d$ = MID$("Hello World", 11, 1)  ' d$ = "d"
PRINT He$+ " " + Wor$ + d$ '  >>>> "He Word"

Code: QB64: [Select]
  1. S$ = "Can you count and list the words in this sentence?"
  2. FOR i = 1 TO LEN(S$)
  3.     letter$ = MID$(S$, i, 1)
  4.     IF letter$ = " " THEN 'the last word$ just ended
  5.         PRINT build$ ' lets show it
  6.         count = count + 1 'let's count it
  7.         build$ = "" 'reset build$ to nothing to build$ another word
  8.     ELSE
  9.         'continue building the word
  10.         build$ = build$ + letter$
  11.     END IF
  12.  
  13. 'now if there is anything left in build$, it is our last word!
  14. IF LEN(build$) THEN
  15.     PRINT build$ ' lets show it
  16.     count = count + 1 'let's count it
  17. PRINT "We had"; count; "words in our sentence."
  18.  

Now you can count and report the number of words in the first line in the file. :)

Title: Re: help my
Post by: bplus on July 14, 2020, 12:22:10 pm
About file access when OPEN a file FOR INPUT:

You have 2 ways to read in data from the file: INPUT #fileNum  or LINE INPUT #fileNum

Use INPUT #fileNum when you have a bunch of items on a line separated by commas or you know for sure there are no commas in data lines (like the Lotto Data), INPUT #fileNum won't read past a comma!

If it is likely you have commas or could have commas in a fileLine$ AND you want to read in whole line from the file then use LINE INPUT #fileNum

So here is the template or pattern of code to use when you OPEN a file FOR INPUT as #fileNum
AND want to read in whole lines that might have commas in them:
Code: QB64: [Select]
  1. fileName$ = "My File.txt" '                 the (pathed) file name of the file you want to open
  2. fileNum = FREEFILE '                        FREEFILE gets the next file # ready to use
  3. IF _FILEEXISTS(fileName$) THEN '            to avoid errors check and see if the file actually exists
  4.     OPEN fileName$ FOR INPUT AS #fileNum '  OPEN file for Sequential access = read line by line start to "end of file" = EOF.
  5.     WHILE EOF(1) = 0 '                      While starts a loop of reading in lines until EOF is reached
  6.         LINE INPUT #1, fileLine$ '          reads whole line (with commas) into variable fileLine$
  7.  
  8.         'process fileLine$
  9.  
  10.     WEND '                                  WEND closes a WHILE Loop Structure
  11.     CLOSE #fileNum '                        close file, we are done with it
  12.     PRINT "Sorry, could not find your file: "; fileName$
  13.  
  14.  

EOF(fileNum) is a flag that is 0 = False until the last line has been read, it is then set to TRUE = NOT False usually -1
Title: Re: help my
Post by: Kiara87 on July 14, 2020, 07:56:49 pm
@bplus thanks bplus everything is useful to learn
I am trying to finish my lotto program
I have to try to figure out how to put the draw date again

in both draws which are now two
it is also how to change the values in the second extraction on the right
in the sense if in the left draw there is a distance 30 in the other draw must mark the numbers to play
Code: QB64: [Select]
  1. ' Programma lotto di kiara87
  2. ' il programma legge i dati (numeri estratti da un file.dat)
  3. ' e permette di vedere  le estrazioni a video
  4. ' i numeri con distanza 30 sono evidenziati con colore rosso
  5. ' questi numeri vengono memorizzati e stampati
  6.  
  7. ' Nota 1: sono d'accordo con Bplus e' molto piu'
  8. ' rapido lavorare con dati in RAM che con dati su Disco HDD/SSD/USB/CD/DVD
  9.  
  10. ' valori COSTANTI  generali Vero e Falso
  11. CONST True = -1, False = NOT True
  12. ' le 11 ruote del lotto
  13. CONST Bari = 1, Cagliari = 2, Firenze = 3, Genova = 4, Milano = 5
  14. CONST Napoli = 6, Palermo = 7, Roma = 8, Torino = 9, Venezia = 10, Nazionale = 11
  15. CONST Cifra = 2 ' ogni numero estratto e' una cifra di due caratteri (01-90)
  16.  
  17. DIM a AS STRING ' una stringa per leggere i dati dal file
  18.  
  19. ' salta al sottoprogramma LeggiFile delimitato
  20. ' dalla Label LeggiFIle e dal RETURN
  21. GOSUB LeggiFile
  22.  
  23. ' verifica che tutto il file sia letto
  24. 'FOR b = 1 TO LEN(a) - 116 STEP 116
  25. '    PRINT MID$(a, b, 116)
  26. '    '    PRINT INSTR(b, a, CHR$(13))
  27. '    _DELAY .1
  28. 'NEXT b
  29.  
  30.  
  31.  
  32. ' il ciclo DO...LOOP UNTIL condizione e' un modo piu' moderno
  33. ' rispetto a Etichetta: .... IF condizione GOTO Etichetta
  34. b = 1
  35. f = 1
  36. z$ = " "
  37. OPEN "distanza30.dat" FOR APPEND AS #2
  38.     IF z$ <> "" THEN
  39.         CLS ' questo risolve un glitch di output sullo schermo
  40.         ' in alternativa alla riga sopra CLS nel sottoblocco
  41.         ' MostraEstratti va stampata la stringa estratto e
  42.         ' non il suo valore corrispondente ottenuto con VAL
  43.         GOSUB MostraRuote ' scrive il nome delle ruote del lotto
  44.         GOSUB MostraEstratti
  45.     END IF
  46.     ' prende l'input dell'utente
  47.     z$ = UCASE$(INKEY$) ' Z$ mantiene il maiuscolo di Inkey$
  48.     IF z$ = CHR$(0) + CHR$(72) AND b < (LEN(a) - 116) THEN b = b + 116
  49.     IF z$ = CHR$(0) + CHR$(80) AND b > 116 THEN b = b - 116
  50.     IF z$ = "+" AND f < (LEN(a) - 116) THEN f = f + 116
  51.     IF z$ = "-" AND f > 116 THEN f = f - 116
  52.  
  53. LOOP UNTIL z$ = "Q"
  54.  
  55. END ' indica la fine logica del programma
  56.  
  57.  
  58. '-----------------------AREA sottoprogrammi /SUBroutines
  59.  
  60. ' questa etichetta /label indica il punto di inizio
  61. ' del sottoprogramma (SUBroutine) LeggiFile scritto con vecchio stile GOSUB
  62. ' che usa una etichetta/label e un RETURN per riprendere da dove si era interotto
  63. ' nota1: un metodo ancora piu' antico e' il salto con GOTO
  64. '        che richiede una seconda etichetta per ritornare nel MAIN o programma principale
  65. ' nota2: un metodo migliore e' SUB nomeroutine....END SUB
  66. '        perche' permette la localizzazione delle variabili
  67. LeggiFile:
  68. 'se non trova lotto.dat segnala l'errore a video e termina il programma
  69. IF NOT _FILEEXISTS("lotto.dat") THEN PRINT "File non trovato": END
  70. '<--------------------
  71. ' questo metodo e' piu' lento
  72. ' apre il file lotto.dat per leggere in maniera sequenziale i dati
  73. 'OPEN "lotto.dat" FOR INPUT AS #1
  74. 'LINE INPUT #1, a  ' riempe la variabile a con una riga intera di valori
  75. '<--------------------
  76.  
  77. ' apre lotto.dat per leggerlo in maniera binaria
  78. OPEN "lotto.dat" FOR BINARY AS #1
  79. a = SPACE$(LOF(1)) ' riempe la variabile a di spazi fino alla grandezza in byte del file aperto
  80. GET #1, , a ' legge con una unica operazione il file e lo pone nella variabiel a
  81. CLOSE #1 ' chiude il file appena letto
  82. ' indica il termine della SUBroutine LeggiFile
  83. ' e RITORNA alla riga di codice successiva al salto GOSUB
  84.  
  85. 'seconda SUBroutine /sottoprogramma
  86. MostraRuote:
  87. LOCATE 1, 1
  88. PRINT "BARI"
  89. LOCATE 3, 1
  90. PRINT "CAGLIARI"
  91. LOCATE 5, 1
  92. PRINT "FIRENZE"
  93. LOCATE 7, 1
  94. PRINT "GENOVA"
  95. LOCATE 9, 1
  96. PRINT "MILANO"
  97. LOCATE 11, 1
  98. PRINT "NAPOLI"
  99. LOCATE 13, 1
  100. PRINT "PALERMO"
  101. LOCATE 15, 1
  102. PRINT "ROMA"
  103. LOCATE 17, 1
  104. PRINT "TORINO"
  105. LOCATE 19, 1
  106. PRINT "VENEZIA"
  107. LOCATE 21, 1
  108. PRINT "NAZIONALE"
  109. LOCATE 1, 50
  110. PRINT "BARI"
  111. LOCATE 3, 50
  112. PRINT "CAGLIARI"
  113. LOCATE 5, 50
  114. PRINT "FIRENZE"
  115. LOCATE 7, 50
  116. PRINT "GENOVA"
  117. LOCATE 9, 50
  118. PRINT "MILANO"
  119. LOCATE 11, 50
  120. PRINT "NAPOLI"
  121. LOCATE 13, 50
  122. PRINT "PALERMO"
  123. LOCATE 15, 50
  124. PRINT "ROMA"
  125. LOCATE 17, 50
  126. PRINT "TORINO"
  127. LOCATE 19, 50
  128. PRINT "VENEZIA"
  129. LOCATE 21, 50
  130. PRINT "NAZIONALE"
  131.  
  132. '------------------------------------
  133. LOCATE 23, 60
  134. PRINT "+ avanti  - indietro"
  135. LOCATE 23, 1
  136. PRINT "su e' giu'"
  137.  
  138. ' indica il termine della SUBroutine MostraRuote
  139. ' e RITORNA alla riga di codice successiva al salto GOSUB
  140.  
  141. 'terzo sottoprogramma o SUBroutine
  142. MostraEstratti:
  143.  
  144. ' le prime 4 cifre sembrano essere in numero della estrazione
  145. LOCATE 1, 32
  146. PRINT "estraz.num "; MID$(a, b, 4)
  147. PRINT #2, "estraz.num "; MID$(a, b, 4)
  148. y = 11 ' prima posizione per il carattere da stampare
  149. FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR e' di 5 perche' ogni ruota ha 5 estrazioni
  150.     A1 = "" ' resetto a1 per il prossimo giro
  151.     FOR V = Bari TO Nazionale ' per tutte le ruote
  152.         COLOR 15, 0
  153.         'posiziona il cursore
  154.         LOCATE (V * 2) - 1, y
  155.         ' scrive il numero estratto
  156.         PRINT VAL(MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); "";
  157.         A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))
  158.     NEXT V
  159.     GOSUB Mostra30
  160.     y = POS(0)
  161. ' indica il termine della SUBroutine MostraEstratti
  162. ' e RITORNA alla riga di codice successiva al salto GOSUB
  163. LOCATE 23, 32
  164. PRINT "estraz.num "; MID$(a, f, 4)
  165. PRINT #2, "estraz.num "; MID$(a, f, 4)
  166.  
  167. y = 58 ' prima posizione per il carattere da stampare
  168. FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR e' di 5 perche' ogni ruota ha 5 estrazioni
  169.     A1 = "" ' resetto a1 per il prossimo giro
  170.     FOR V = Bari TO Nazionale ' per tutte le ruote
  171.         COLOR 15, 0
  172.         'posiziona il cursore
  173.         LOCATE (V * 2) - 1, y
  174.         ' scrive il numero estratto
  175.         PRINT VAL(MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra)); "";
  176.         A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra))
  177.     NEXT V
  178.     GOSUB MostraCondizione
  179.     y = POS(0)
  180. ' indica il termine della SUBroutine MostraEstratti
  181. ' e RITORNA alla riga di codice successiva al salto GOSUB
  182.  
  183.  
  184.  
  185.  
  186. Mostra30:
  187. FOR v1 = Bari TO Venezia ' per tutte le ruote
  188.     FOR v2 = v1 + 1 TO Nazionale
  189.         IF ABS(VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)) - VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))) = 30 THEN
  190.             COLOR 10, 0
  191.             'posiziona                                                                      il cursore
  192.             LOCATE (v1 * 2) - 1, y
  193.             ' scrive il numero estratto
  194.             PRINT VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); "";
  195.             PRINT #2, (MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))
  196.             'posiziona                                                                      il cursore
  197.             LOCATE (v2 * 2) - 1, y
  198.             ' scrive il numero estratto
  199.             PRINT VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); "";
  200.             PRINT #2, MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)
  201.         END IF
  202.     NEXT v2
  203. NEXT v1
  204. COLOR 15, 0
  205. ' indica il termine della SUBroutine MostraEstratti
  206. ' e RITORNA alla riga di codice successiva al salto GOSUB
  207.  
  208. MostraCondizione:
  209. FOR v3 = Bari TO Venezia ' per tutte le ruote
  210.     FOR v4 = v3 + 1 TO Nazionale
  211.         IF ABS(VAL(MID$(a, (v3 - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra)) - VAL(MID$(a, (v4 - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra))) = 30 THEN
  212.             COLOR 4, 0
  213.             'posiziona                                                                      il cursore
  214.             LOCATE (v3 * 2) - 1, y
  215.             ' scrive il numero estratto
  216.             PRINT VAL(MID$(a, (v3 - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra)); "";
  217.             PRINT #2, (MID$(a, (v3 - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra))
  218.             'posiziona                                                                      il cursore
  219.             LOCATE (v4 * 2) - 1, y
  220.             ' scrive il numero estratto
  221.             PRINT VAL(MID$(a, (v4 - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra)); "";
  222.             PRINT #2, MID$(a, (v4 - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra)
  223.         END IF
  224.     NEXT v4
  225. NEXT v3
  226. COLOR 15, 0
  227. ' indica il termine della SUBroutine MostraEstratti
  228. ' e RITORNA alla riga di codice successiva al salto GOSUB
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  

un po difficile da spiegare in inglese
magari @TempodiBasic  puo' capire spiegandolo in italiano hihi

I don't know if I write a mess with this translator and maybe you don't really understand what I mean

However, I must say that I am learning a lot from you
even with the sample program you did for me

and also your advice
I thank all of you who are very good

anche @TempodiBasic  con i suoi commenti e' il suo codice sorgente con tanto di commenti in italiano mi ha fatto capire i comandi
alcuni ancora devo capire abs come funziona facendo le operazioni oppure bisogna conoscere tanta matematica per usarla
@bplus you have been very helpful in creating the program for me and always posting examples
also being very good at programming you are very kind to always help others trying to learn from other people
maybe this is the reason that made you improve so much in programming
he made you grow to learn others and in the meantime you also learned

thank you all



Title: Re: help my
Post by: bplus on July 15, 2020, 11:16:19 am
Quote
I have to try to figure out how to put the draw date again

in both draws which are now two
it is also how to change the values in the second extraction on the right
in the sense if in the left draw there is a distance 30 in the other draw must mark the numbers to play

RE Draw date: Is the draw date the first 4 digits of each row in the data file?

RE dist30 between values: you removed the separate function and embedded it into the display code. In my opinion it was better to have that function isolated, perhaps you are afraid of FUNCTIONs ?

But you use FUNCTIONs all the time LEN(aString$) is a FUNCTION, so is VAL(), and MID$(), EOF(), LOF() these are functions you already use. A FUNCTION is just one you make for yourself and is just as easy to use once it's made.
Oh well you are new and newbies want to avoid Arrays, Subs and Functions...

It looks now that you've made the file data one very long string and use code to chop it down to blocks then rows and columns of data, use that same technique to locate the two numbers in question to test their distance.

I am not certain which 2 numbers you want the 30's difference to be calculated, I would guess in the corresponding row, col of the left side that is on the right side so every time you arrow or +/- you have to recalculate the display.

If so, use the same calculation you use to display a number in a page (right side or left), block (labels), row and column to compare the numbers between left side and the right.

In my opinion it was easier to understand taking data a row at a time and keeping the 30 distance function separate. Maybe this is from TempodiBasic influence? It is clever to swallow the whole file in one gulp but you still have to deal with CR+LF and then deal with a 3rd DIM to the data the dates is it? What are those first 4 digits in each line?

Are you here to gain some superstitious edge on lotto's or to learn coding?

I know, BOTH! ;-))
Title: Re: help my
Post by: bplus on July 15, 2020, 11:34:50 am
Assuming date is first 4 digits of each line in data file:

OK so the length of each line of data is 116 counting the CR+LF that would be still embedded in the whole file string so each date would start at 1 + 0 * 116, 1 + 1 * 116, 1 + 2 * 116...

FUNCTION date$(lineNum)
    date$ = MID$(a, 1 + (lineNum - 1) * 116, 4)  ' a = the SHARED data file string
END FUNCTION


lineNum is same as row number in the data file.

Name Conflict with DATE$ sorry forgot:
Code: QB64: [Select]
  1. FUNCTION LottoDate$ (lineNum)
  2.     Lottodate$ = MID$(a, 1 + (lineNum - 1) * 116, 4)  ' a = the SHARED data file string
  3.  
  4.  
  5.  
Title: Re: help my
Post by: bplus on July 15, 2020, 05:58:55 pm
Test function, load it at bottom of code and top section of code looks like this:

Code: QB64: [Select]
  1. CONST True = -1, False = NOT True
  2. ' le 11 ruote del lotto
  3. CONST Bari = 1, Cagliari = 2, Firenze = 3, Genova = 4, Milano = 5
  4. CONST Napoli = 6, Palermo = 7, Roma = 8, Torino = 9, Venezia = 10, Nazionale = 11
  5. CONST Cifra = 2 ' ogni numero estratto e' una cifra di due caratteri (01-90)
  6.  
  7. DIM SHARED a AS STRING ' una stringa per leggere i dati dal file  <<<<<<<<<<<<<<<<< SHARED
  8.  
  9. ' salta al sottoprogramma LeggiFile delimitato
  10. ' dalla Label LeggiFIle e dal RETURN
  11. GOSUB LeggiFile
  12.  
  13. 'test fuction after load file into a string
  14. PRINT LottoDate$(1)
  15. PRINT LottoDate$(2)
  16. PRINT LottoDate$(3)
  17.  
  18.  

Title: Re: help my
Post by: Kiara87 on July 15, 2020, 06:12:07 pm
Assuming date is first 4 digits of each line in data file:

OK so the length of each line of data is 116 counting the CR+LF that would be still embedded in the whole file string so each date would start at 1 + 0 * 116, 1 + 1 * 116, 1 + 2 * 116...

FUNCTION date$(lineNum)
    date$ = MID$(a, 1 + (lineNum - 1) * 116, 4)  ' a = the SHARED data file string
END FUNCTION


lineNum is same as row number in the data file.

Name Conflict with DATE$ sorry forgot:
Code: QB64: [Select]
  1. FUNCTION LottoDate$ (lineNum)
  2.     Lottodate$ = MID$(a, 1 + (lineNum - 1) * 116, 4)  ' a = the SHARED data file string
  3.  
  4.  
  5.  

the problem is that I still don't know the commands well and how to program them
because I was initially editing your code
but not being able to understand where I got my hands maybe because I didn't understand how the functions work the arrays in your code look for many variables and I didn't know what to change because every single variable makes its path and I didn't know what one of those variables does
after I got the code @TempodiBasic 
there I understood something because he in the written comments how they work is in his code he didn't use many variables but few variables
in its code there is no functions

so I found it easier to edit its code

put an example of what I walked between the two codes
source code @TempodiBasic mod kiara
Code: QB64: [Select]
  1. ' Programma lotto di kiara87
  2. ' il programma legge i dati (numeri estratti da un file.dat)
  3. ' e permette di vedere  le estrazioni a video
  4. ' i numeri con distanza 30 sono evidenziati con colore rosso
  5. ' questi numeri vengono memorizzati e stampati
  6.  
  7. ' Nota 1: sono d'accordo con Bplus e' molto piu'
  8. ' rapido lavorare con dati in RAM che con dati su Disco HDD/SSD/USB/CD/DVD
  9.  
  10. ' valori COSTANTI  generali Vero e Falso
  11. CONST True = -1, False = NOT True
  12. ' le 11 ruote del lotto
  13. CONST Bari = 1, Cagliari = 2, Firenze = 3, Genova = 4, Milano = 5
  14. CONST Napoli = 6, Palermo = 7, Roma = 8, Torino = 9, Venezia = 10, Nazionale = 11
  15. CONST Cifra = 2 ' ogni numero estratto e' una cifra di due caratteri (01-90)
  16.  
  17. DIM a AS STRING ' una stringa per leggere i dati dal file
  18.  
  19. ' salta al sottoprogramma LeggiFile delimitato
  20. ' dalla Label LeggiFIle e dal RETURN
  21. GOSUB LeggiFile
  22.  
  23. ' verifica che tutto il file sia letto
  24. 'FOR b = 1 TO LEN(a) - 116 STEP 116
  25. '    PRINT MID$(a, b, 116)
  26. '    '    PRINT INSTR(b, a, CHR$(13))
  27. '    _DELAY .1
  28. 'NEXT b
  29.  
  30.  
  31.  
  32. ' il ciclo DO...LOOP UNTIL condizione e' un modo piu' moderno
  33. ' rispetto a Etichetta: .... IF condizione GOTO Etichetta
  34. b = 1
  35. f = 1
  36. z$ = " "
  37. OPEN "distanza30.dat" FOR APPEND AS #2
  38.     IF z$ <> "" THEN
  39.         CLS ' questo risolve un glitch di output sullo schermo
  40.         ' in alternativa alla riga sopra CLS nel sottoblocco
  41.         ' MostraEstratti va stampata la stringa estratto e
  42.         ' non il suo valore corrispondente ottenuto con VAL
  43.         GOSUB MostraRuote ' scrive il nome delle ruote del lotto
  44.         GOSUB MostraEstratti
  45.     END IF
  46.     ' prende l'input dell'utente
  47.     z$ = UCASE$(INKEY$) ' Z$ mantiene il maiuscolo di Inkey$
  48.     IF z$ = CHR$(0) + CHR$(72) AND b < (LEN(a) - 116) THEN b = b + 116
  49.     IF z$ = CHR$(0) + CHR$(80) AND b > 116 THEN b = b - 116
  50.     IF z$ = "+" AND f < (LEN(a) - 116) THEN f = f + 116
  51.     IF z$ = "-" AND f > 116 THEN f = f - 116
  52.  
  53. LOOP UNTIL z$ = "Q"
  54.  
  55. END ' indica la fine logica del programma
  56.  
  57.  
  58. '-----------------------AREA sottoprogrammi /SUBroutines
  59.  
  60. ' questa etichetta /label indica il punto di inizio
  61. ' del sottoprogramma (SUBroutine) LeggiFile scritto con vecchio stile GOSUB
  62. ' che usa una etichetta/label e un RETURN per riprendere da dove si era interotto
  63. ' nota1: un metodo ancora piu' antico e' il salto con GOTO
  64. '        che richiede una seconda etichetta per ritornare nel MAIN o programma principale
  65. ' nota2: un metodo migliore e' SUB nomeroutine....END SUB
  66. '        perche' permette la localizzazione delle variabili
  67. LeggiFile:
  68. 'se non trova lotto.dat segnala l'errore a video e termina il programma
  69. IF NOT _FILEEXISTS("lotto.dat") THEN PRINT "File non trovato": END
  70. '<--------------------
  71. ' questo metodo e' piu' lento
  72. ' apre il file lotto.dat per leggere in maniera sequenziale i dati
  73. 'OPEN "lotto.dat" FOR INPUT AS #1
  74. 'LINE INPUT #1, a  ' riempe la variabile a con una riga intera di valori
  75. '<--------------------
  76.  
  77. ' apre lotto.dat per leggerlo in maniera binaria
  78. OPEN "lotto.dat" FOR BINARY AS #1
  79. a = SPACE$(LOF(1)) ' riempe la variabile a di spazi fino alla grandezza in byte del file aperto
  80. GET #1, , a ' legge con una unica operazione il file e lo pone nella variabiel a
  81. CLOSE #1 ' chiude il file appena letto
  82. ' indica il termine della SUBroutine LeggiFile
  83. ' e RITORNA alla riga di codice successiva al salto GOSUB
  84.  
  85. 'seconda SUBroutine /sottoprogramma
  86. MostraRuote:
  87. LOCATE 1, 1
  88. PRINT "BARI"
  89. LOCATE 3, 1
  90. PRINT "CAGLIARI"
  91. LOCATE 5, 1
  92. PRINT "FIRENZE"
  93. LOCATE 7, 1
  94. PRINT "GENOVA"
  95. LOCATE 9, 1
  96. PRINT "MILANO"
  97. LOCATE 11, 1
  98. PRINT "NAPOLI"
  99. LOCATE 13, 1
  100. PRINT "PALERMO"
  101. LOCATE 15, 1
  102. PRINT "ROMA"
  103. LOCATE 17, 1
  104. PRINT "TORINO"
  105. LOCATE 19, 1
  106. PRINT "VENEZIA"
  107. LOCATE 21, 1
  108. PRINT "NAZIONALE"
  109. LOCATE 1, 50
  110. PRINT "BARI"
  111. LOCATE 3, 50
  112. PRINT "CAGLIARI"
  113. LOCATE 5, 50
  114. PRINT "FIRENZE"
  115. LOCATE 7, 50
  116. PRINT "GENOVA"
  117. LOCATE 9, 50
  118. PRINT "MILANO"
  119. LOCATE 11, 50
  120. PRINT "NAPOLI"
  121. LOCATE 13, 50
  122. PRINT "PALERMO"
  123. LOCATE 15, 50
  124. PRINT "ROMA"
  125. LOCATE 17, 50
  126. PRINT "TORINO"
  127. LOCATE 19, 50
  128. PRINT "VENEZIA"
  129. LOCATE 21, 50
  130. PRINT "NAZIONALE"
  131.  
  132. '------------------------------------
  133. LOCATE 23, 60
  134. PRINT "+ avanti  - indietro"
  135. LOCATE 23, 1
  136. PRINT CHR$(24); " avanti   "; CHR$(25); " indietro"
  137.  
  138. ' indica il termine della SUBroutine MostraRuote
  139. ' e RITORNA alla riga di codice successiva al salto GOSUB
  140.  
  141. 'terzo sottoprogramma o SUBroutine
  142. MostraEstratti:
  143.  
  144. ' le prime 4 cifre sembrano essere in numero della estrazione
  145. LOCATE 1, 32
  146. PRINT "estraz.num "; MID$(a, b, 4)
  147. PRINT #2, "estraz.num "; MID$(a, b, 4)
  148. y = 11 ' prima posizione per il carattere da stampare
  149. FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR e' di 5 perche' ogni ruota ha 5 estrazioni
  150.     A1 = "" ' resetto a1 per il prossimo giro
  151.     FOR V = Bari TO Nazionale ' per tutte le ruote
  152.         COLOR 15, 0
  153.         'posiziona il cursore
  154.         LOCATE (V * 2) - 1, y
  155.         ' scrive il numero estratto
  156.         PRINT VAL(MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); "";
  157.         A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))
  158.     NEXT V
  159.     GOSUB Mostra30
  160.     y = POS(0)
  161. ' indica il termine della SUBroutine MostraEstratti
  162. ' e RITORNA alla riga di codice successiva al salto GOSUB
  163. LOCATE 23, 32
  164. PRINT "estraz.num "; MID$(a, f, 4)
  165. PRINT #2, "estraz.num "; MID$(a, f, 4)
  166.  
  167. y = 58 ' prima posizione per il carattere da stampare
  168. FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR e' di 5 perche' ogni ruota ha 5 estrazioni
  169.     A1 = "" ' resetto a1 per il prossimo giro
  170.     FOR V = Bari TO Nazionale ' per tutte le ruote
  171.         COLOR 15, 0
  172.         'posiziona il cursore
  173.         LOCATE (V * 2) - 1, y
  174.         ' scrive il numero estratto
  175.         PRINT VAL(MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra)); "";
  176.         A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra))
  177.     NEXT V
  178.     GOSUB MostraCondizione
  179.     y = POS(0)
  180. ' indica il termine della SUBroutine MostraEstratti
  181. ' e RITORNA alla riga di codice successiva al salto GOSUB
  182.  
  183.  
  184.  
  185.  
  186. Mostra30:
  187. FOR v1 = Bari TO Venezia ' per tutte le ruote
  188.     FOR v2 = v1 + 1 TO Nazionale
  189.         IF ABS(VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)) - VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))) = 30 THEN
  190.             COLOR 10, 0
  191.             'posiziona                                                                      il cursore
  192.             LOCATE (v1 * 2) - 1, y
  193.             ' scrive il numero estratto
  194.             PRINT VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); "";
  195.             PRINT #2, (MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))
  196.             'posiziona                                                                      il cursore
  197.             LOCATE (v2 * 2) - 1, y
  198.             ' scrive il numero estratto
  199.             PRINT VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); "";
  200.             PRINT #2, MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)
  201.         END IF
  202.     NEXT v2
  203. NEXT v1
  204. COLOR 15, 0
  205. ' indica il termine della SUBroutine MostraEstratti
  206. ' e RITORNA alla riga di codice successiva al salto GOSUB
  207.  
  208. MostraCondizione:
  209. FOR v3 = Bari TO Venezia ' per tutte le ruote
  210.     FOR v4 = v3 + 1 TO Nazionale
  211.         IF ABS(VAL(MID$(a, (v3 - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra)) - VAL(MID$(a, (v4 - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra))) = 30 THEN
  212.             COLOR 4, 0
  213.             'posiziona                                                                      il cursore
  214.             LOCATE (v3 * 2) - 1, y
  215.             ' scrive il numero estratto
  216.             PRINT VAL(MID$(a, (v3 - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra)); "";
  217.             PRINT #2, (MID$(a, (v3 - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra))
  218.             'posiziona                                                                      il cursore
  219.             LOCATE (v4 * 2) - 1, y
  220.             ' scrive il numero estratto
  221.             PRINT VAL(MID$(a, (v4 - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra)); "";
  222.             PRINT #2, MID$(a, (v4 - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra)
  223.         END IF
  224.     NEXT v4
  225. NEXT v3
  226. COLOR 15, 0
  227. ' indica il termine della SUBroutine MostraEstratti
  228. ' e RITORNA alla riga di codice successiva al salto GOSUB
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  


source code @bplus  mod 2 kiara
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, count2, i, lineNum, lineNum2 ' for file and array access
  6. DIM Q$ '                             for INKEY$
  7. DIM row, col, aPlace, aPlace2 '               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. DIM shiftRight
  11. DIM shiftRight2
  12. shiftRight2 = 65
  13. shiftRight = 15
  14.  
  15. 'count lines in file
  16. OPEN "lotto.dat" FOR INPUT AS #1
  17.     INPUT #1, a
  18.     '          debug check inputs from file
  19.     'PRINT a
  20.     'INPUT " OK enter "; w$
  21.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  22.  
  23. 'now we now size of file so ready an array to load file Data
  24. DIM fileDAT(1 TO count) AS STRING
  25. OPEN "lotto.dat" FOR INPUT AS #1
  26. FOR i = 1 TO count
  27.     INPUT #1, a
  28.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  29.  
  30. ' NOW all the data if loaded into fileDAT() array, 480 strings of Lottory data
  31.  
  32. GOSUB labelScreen
  33.  
  34. 'set first line and get a data string from the FileDAT array
  35. lineNum = 1
  36. a = fileDAT(lineNum)
  37.  
  38.     Q$ = INKEY$
  39.     IF Q$ = "+" THEN lineNum = lineNum + 1
  40.     IF Q$ = "-" THEN lineNum = lineNum - 1
  41.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum = lineNum + 1
  42.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum = lineNum - 1
  43.  
  44.     IF lineNum > count THEN lineNum = 1
  45.     IF lineNum < 1 THEN lineNum = count
  46.  
  47.     'get new data line
  48.     a = fileDAT(lineNum)
  49.  
  50.  
  51.     'print out the data from the new line
  52.     CLS
  53.     GOSUB labelScreen
  54.     GOSUB screenDataLine
  55.     GOSUB loadLineDAT_Mark30s
  56.     _DISPLAY
  57.     _LIMIT 30
  58.  
  59.  
  60. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  61. rowCnt = 1: y = 1
  62. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  63.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  64.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  65.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  66. COLOR 9 'blue marker  seacrh through columes for  30's
  67. FOR col = 1 TO 5 'for each of the columes of data
  68.     FOR row = 1 TO 10 'for each of the rows of dat
  69.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  70.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  71.                 LOCATE row * 2, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, row));
  72.                 LOCATE rowPlus * 2, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, rowPlus));
  73.                 '--------------------------------------------------------------------------
  74.  
  75.                 LOCATE row * 2, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, row));
  76.                 LOCATE rowPlus * 2, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, rowPlus));
  77.  
  78.             END IF
  79.         NEXT
  80.     NEXT
  81.  
  82.  
  83. screenDataLine:
  84. LOCATE 1, 34
  85. PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum);
  86. aPlace = 5
  87. FOR row = 1 TO 11
  88.     FOR col = 1 TO 5
  89.         LOCATE row * 2, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2);
  90.         aPlace = aPlace + 2
  91.     NEXT
  92. '------------------------------------------------------------------------
  93. LOCATE 1, 34
  94. PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum);
  95. aPlace = 5
  96. FOR row = 1 TO 11
  97.     FOR col = 1 TO 5
  98.         LOCATE row * 2, col * 3 - 2 + shiftRight2: PRINT MID$(a, aPlace, 2);
  99.         aPlace = aPlace + 2
  100.     NEXT
  101.  
  102.  
  103.  
  104. labelScreen:
  105. ' setup screen labels for reporting data
  106. LOCATE 2, 1
  107. PRINT "BARI"
  108. LOCATE 4, 1
  109. PRINT "CAGLIARI"
  110. LOCATE 6, 1
  111. PRINT "FIRENZE"
  112. LOCATE 8, 1
  113. PRINT "GENOVA"
  114. LOCATE 10, 1
  115. PRINT "MILANO"
  116. LOCATE 12, 1
  117. PRINT "NAPOLI"
  118. LOCATE 16, 1
  119. PRINT "PALERMO"
  120. LOCATE 18, 1
  121. PRINT "ROMA"
  122. LOCATE 20, 1
  123. PRINT "TORINO"
  124. LOCATE 22, 1
  125. PRINT "VENEZIA"
  126. LOCATE 24, 1
  127. PRINT "NAZIONALE"
  128. ' setup screen labels for reporting data
  129. LOCATE 2, 50
  130. PRINT "BARI"
  131. LOCATE 4, 50
  132. PRINT "CAGLIARI"
  133. LOCATE 6, 50
  134. PRINT "FIRENZE"
  135. LOCATE 8, 50
  136. PRINT "GENOVA"
  137. LOCATE 10, 50
  138. PRINT "MILANO"
  139. LOCATE 12, 50
  140. PRINT "NAPOLI"
  141. LOCATE 16, 50
  142. PRINT "PALERMO"
  143. LOCATE 18, 50
  144. PRINT "ROMA"
  145. LOCATE 20, 50
  146. PRINT "TORINO"
  147. LOCATE 22, 50
  148. PRINT "VENEZIA"
  149. LOCATE 24, 50
  150. PRINT "NAZIONALE"
  151.  
  152. 'some directions
  153.  
  154. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  155.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  156.  
  157. FUNCTION diff30in90 (a, b) 'default integers a-z
  158.     DIM hi, lo
  159.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  160.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  161.     IF hi - lo = 30 THEN
  162.         diff30in90 = -1
  163.     ELSE
  164.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  165.     END IF
  166.  
  167.  
  168.  
  169.  
  170.  


maybe this is what I edit in the beginning

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, lineNum2 ' for file and array access
  6. DIM Q$ '                             for INKEY$
  7. DIM row, col, aPlace, aPlace2 '               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. DIM shiftRight
  11. DIM shiftRight2
  12. shiftRight2 = 65
  13. shiftRight = 15
  14.  
  15. 'count lines in file
  16. OPEN "lotto.dat" FOR INPUT AS #1
  17.     INPUT #1, a
  18.     '          debug check inputs from file
  19.     'PRINT a
  20.     'INPUT " OK enter "; w$
  21.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  22.  
  23. 'now we now size of file so ready an array to load file Data
  24. DIM fileDAT(1 TO count) AS STRING
  25. OPEN "lotto.dat" FOR INPUT AS #1
  26. FOR i = 1 TO count
  27.     INPUT #1, a
  28.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  29.  
  30. ' NOW all the data if loaded into fileDAT() array, 480 strings of Lottory data
  31.  
  32. GOSUB labelScreen
  33.  
  34. 'set first line and get a data string from the FileDAT array
  35. lineNum = 1
  36. a = fileDAT(lineNum)
  37. lineNum2 = 1
  38. a = fileDAT(lineNum2)
  39.  
  40.     Q$ = INKEY$
  41.     IF Q$ = "+" THEN lineNum = lineNum + 1
  42.     IF Q$ = "-" THEN lineNum = lineNum - 1
  43.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum2 = lineNum2 + 1
  44.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum2 = lineNum2 - 1
  45.     IF lineNum2 > count THEN lineNum2 = 1
  46.     IF lineNum2 < 1 THEN lineNum2 = count
  47.  
  48.     IF lineNum > count THEN lineNum = 1
  49.     IF lineNum < 1 THEN lineNum = count
  50.  
  51.     'get new data line
  52.     a = fileDAT(lineNum)
  53.  
  54.     a = fileDAT(lineNum2)
  55.     'print out the data from the new line
  56.     CLS
  57.     GOSUB labelScreen
  58.     GOSUB screenDataLine
  59.     GOSUB loadLineDAT_Mark30s
  60.     _DISPLAY
  61.     _LIMIT 30
  62.  
  63.  
  64. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  65. rowCnt = 1: y = 1
  66. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  67.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  68.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  69.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  70. COLOR 9 'blue marker  seacrh through columes for  30's
  71. FOR col = 1 TO 5 'for each of the columes of data
  72.     FOR row = 1 TO 10 'for each of the rows of dat
  73.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  74.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  75.                 LOCATE row * 2, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, row));
  76.                 LOCATE rowPlus * 2, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, rowPlus));
  77.                 '--------------------------------------------------------------------------
  78.  
  79.                 LOCATE row * 2, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, row));
  80.                 LOCATE rowPlus * 2, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, rowPlus));
  81.  
  82.             END IF
  83.         NEXT
  84.     NEXT
  85.  
  86.  
  87. screenDataLine:
  88. LOCATE 1, 34
  89. PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum);
  90. aPlace = 5
  91. FOR row = 1 TO 11
  92.     FOR col = 1 TO 5
  93.         LOCATE row * 2, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2);
  94.         aPlace = aPlace + 2
  95.     NEXT
  96. '------------------------------------------------------------------------
  97. LOCATE 1, 34
  98. PRINT "estraz.num "; LEFT$(a, 4); "   lineNum:"; STR$(lineNum2);
  99. aPlace = 5
  100. FOR row = 1 TO 11
  101.     FOR col = 1 TO 5
  102.         LOCATE row * 2, col * 3 - 2 + shiftRight2: PRINT MID$(a, aPlace, 2);
  103.         aPlace = aPlace + 2
  104.     NEXT
  105.  
  106.  
  107.  
  108. labelScreen:
  109. ' setup screen labels for reporting data
  110. LOCATE 2, 1
  111. PRINT "BARI"
  112. LOCATE 4, 1
  113. PRINT "CAGLIARI"
  114. LOCATE 6, 1
  115. PRINT "FIRENZE"
  116. LOCATE 8, 1
  117. PRINT "GENOVA"
  118. LOCATE 10, 1
  119. PRINT "MILANO"
  120. LOCATE 12, 1
  121. PRINT "NAPOLI"
  122. LOCATE 16, 1
  123. PRINT "PALERMO"
  124. LOCATE 18, 1
  125. PRINT "ROMA"
  126. LOCATE 20, 1
  127. PRINT "TORINO"
  128. LOCATE 22, 1
  129. PRINT "VENEZIA"
  130. LOCATE 24, 1
  131. PRINT "NAZIONALE"
  132. 'some directions
  133. LOCATE 24, 1
  134. PRINT " + to move on";
  135. LOCATE 25, 16
  136. PRINT "- to back";
  137.  
  138. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  139.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  140.  
  141. FUNCTION diff30in90 (a, b) 'default integers a-z
  142.     DIM hi, lo
  143.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  144.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  145.     IF hi - lo = 30 THEN
  146.         diff30in90 = -1
  147.     ELSE
  148.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  149.     END IF
  150.  
  151.  
  152.  
  153.  
  154.  

yes i want to combine my two passions the qb64 and lottery

I want to learn programming well
Title: Re: help my
Post by: bplus on July 15, 2020, 08:18:25 pm
Here is start of problems in Kiara mod of b+ code:
Code: QB64: [Select]
  1.     'get new data line
  2.     a = fileDAT(lineNum)
  3.  
  4.     a = fileDAT(lineNum2)  ' <<<  use a2 for a separate line of data for the right hand set
  5.  

So setup a2 as string and wherever you see "a" distinguish with a2 for the right set of data.

Title: Re: help my
Post by: bplus on July 15, 2020, 11:11:29 pm
Here is b+ mod of Kiara mod of b+, two independent screen or page views of lotto data AND a mouse click up or down to shift the data day for each page:
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, aPlace2 '               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. DIM shiftRight
  11. DIM shiftRight2
  12. DIM mb, mx, my, oldmouse ' oldmouse is trick Steve McNeill showed us to get ONE mouse click!
  13. shiftRight2 = 46
  14. shiftRight = 19
  15.  
  16.  
  17. 'count lines in file
  18. OPEN "lotto.dat" FOR INPUT AS #1
  19.     INPUT #1, a
  20.     '          debug check inputs from file
  21.     'PRINT a
  22.     'INPUT " OK enter "; w$
  23.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  24.  
  25. 'now we now size of file so ready an array to load file Data
  26. DIM fileDAT(1 TO count) AS STRING
  27. OPEN "lotto.dat" FOR INPUT AS #1
  28. FOR i = 1 TO count
  29.     INPUT #1, a
  30.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  31.  
  32. ' NOW all the data if loaded into fileDAT() array, 480 strings of Lottory data
  33.  
  34. GOSUB labelScreen
  35.  
  36. 'set first line and get a data string from the FileDAT array
  37. lineNum = 1
  38. a = fileDAT(lineNum)
  39. lineNum2 = 1
  40. a2 = fileDAT(lineNum2)
  41.  
  42.     CLS
  43.     Q$ = INKEY$
  44.     IF Q$ = "+" THEN lineNum = lineNum + 1
  45.     IF Q$ = "-" THEN lineNum = lineNum - 1
  46.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum2 = lineNum2 + 1
  47.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum2 = lineNum2 - 1
  48.  
  49.     mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  50.     'LOCATE 3, 1: PRINT mx, my
  51.     IF mb AND oldmouse = 0 AND my > 24 THEN ' <<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  52.         '_DELAY .25 '        just one click please!
  53.         IF 17 <= mx AND mx <= 25 THEN lineNum = lineNum + 1
  54.         IF 28 <= mx AND mx <= 37 THEN lineNum = lineNum - 1
  55.         IF 44 <= mx AND mx <= 52 THEN lineNum2 = lineNum2 + 1
  56.         IF 55 <= mx AND mx <= 64 THEN lineNum2 = lineNum2 - 1
  57.     END IF
  58.     oldmouse = _MOUSEBUTTON(1) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  59.     IF lineNum2 > count THEN lineNum2 = 1
  60.     IF lineNum2 < 1 THEN lineNum2 = count
  61.  
  62.     IF lineNum > count THEN lineNum = 1
  63.     IF lineNum < 1 THEN lineNum = count
  64.  
  65.     'get new data line
  66.     a = fileDAT(lineNum)
  67.  
  68.     a2 = fileDAT(lineNum2)
  69.     'print out the data from the new line
  70.  
  71.     GOSUB labelScreen
  72.     GOSUB screenDataLine
  73.     GOSUB loadLineDAT_Mark30s
  74.     _DISPLAY
  75.     _LIMIT 30
  76.  
  77. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  78. rowCnt = 1: y = 1
  79. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  80.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  81.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  82.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  83. COLOR 9 'blue marker  seacrh through columes for  30's
  84. FOR col = 1 TO 5 'for each of the columes of data
  85.     FOR row = 1 TO 10 'for each of the rows of dat
  86.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  87.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  88.                 LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, row));
  89.                 LOCATE rowPlus * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, rowPlus));
  90.             END IF
  91.         NEXT
  92.     NEXT
  93. '---------------------------------------------------- right side  a2 data line
  94. rowCnt = 1: y = 1
  95. FOR i = 5 TO LEN(a2) STEP 2 ' is marking off the start of each data 2 digit integer
  96.     lineDAT(rowCnt, y) = VAL(MID$(a2, i, 2)) 'convert data item to integer
  97.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  98.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  99. COLOR 9 'blue marker  seacrh through columes for  30's
  100. FOR col = 1 TO 5 'for each of the columes of data
  101.     FOR row = 1 TO 10 'for each of the rows of dat
  102.         FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  103.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN
  104.                 LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, row));
  105.                 LOCATE rowPlus * 2 + 1, col * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(col, rowPlus));
  106.             END IF
  107.         NEXT
  108.     NEXT
  109.  
  110.  
  111. screenDataLine:
  112. LOCATE 1, 16
  113. PRINT "estraz: "; LEFT$(a, 4); "  line:"; STR$(lineNum);
  114. aPlace = 5
  115. FOR row = 1 TO 11
  116.     FOR col = 1 TO 5
  117.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2);
  118.         aPlace = aPlace + 2
  119.     NEXT
  120. '-------------------------------------------------- Right side
  121. LOCATE 1, 15 + 43
  122. PRINT "estraz "; LEFT$(a2, 4); "   line:"; STR$(lineNum2); '<<<<<<<<<<<<<<< a2 now
  123. aPlace = 5
  124. FOR row = 1 TO 11
  125.     FOR col = 1 TO 5
  126.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT MID$(a2, aPlace, 2); '<<<<<<<<<<<<<<< a2 now
  127.         aPlace = aPlace + 2
  128.     NEXT
  129.  
  130. labelScreen:
  131. DIM labels(11) AS STRING ' setup screen labels for reporting data
  132. labels(1) = "BARI"
  133. labels(2) = "CAGLIARI"
  134. labels(3) = "FIRENZE"
  135. labels(4) = "GENOVA"
  136. labels(5) = "MILANO"
  137. labels(6) = "NAPOLI"
  138. labels(7) = "PALERMO"
  139. labels(8) = "ROMA"
  140. labels(9) = "TORINO"
  141. labels(10) = "VENEZIA"
  142. labels(11) = "NAZIONALE"
  143. FOR i = 1 TO 11
  144.     LOCATE i * 2 + 1, 36: PRINT labels(i)
  145. LOCATE 25, 1
  146. PRINT " Fare clic su:  Fino / Up  Giu / Down      Fino / Up  Giu / Down";
  147. '      12345678901234567890123456789012345678901234567890123456789012345678901234567890
  148. '               1         2         3         4         5         6         7         8
  149.  
  150. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  151.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  152.  
  153. FUNCTION diff30in90 (a, b) 'default integers a-z
  154.     DIM hi, lo
  155.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  156.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  157.     IF hi - lo = 30 THEN
  158.         diff30in90 = -1
  159.     ELSE
  160.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  161.     END IF
  162.  
  163.  

@Kiara87  Still working on the date thing but we are closer to that model you showed in link.

EDIT: replaced hack _DELAY .25 with Steve McNeill oldmouse trick for getting just one click response.
Title: Re: help my
Post by: Kiara87 on July 16, 2020, 04:31:43 am
the date must be as in the image  --> https://imgur.com/JU9nILf

the draws are 3 times a week

the days are Tuesday Thursday and Saturday
estr. 1465 = Tuesday 6 June 2017
estr. 1466 = Thursday 8 June 2017
estr. 1467 = Saturday 10 June 2017
Title: Re: help my
Post by: bplus on July 16, 2020, 11:34:41 am
That date conversion thing is a thinker! I have to consult my calendar functions, this is like work ;(
Title: Re: help my
Post by: Kiara87 on July 16, 2020, 12:18:12 pm
That date conversion thing is a thinker! I have to consult my calendar functions, this is like work ;(

if you want help you can also ask

😅 :D
Title: Re: help my
Post by: bplus on July 16, 2020, 12:38:40 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
...

🤷‍♂️
Title: Re: help my
Post by: SMcNeill 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.
Title: Re: help my
Post by: Kiara87 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
Title: Re: help my
Post by: bplus 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!
Title: Re: help my
Post by: Kiara87 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
Title: Re: help my
Post by: bplus 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.  
Title: Re: help my
Post by: Kiara87 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
Title: Re: help my
Post by: bplus 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.
Title: Re: help my
Post by: Kiara87 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
Title: Re: help my
Post by: bplus 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.
Title: Re: help my
Post by: Kiara87 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
Title: Re: help my
Post by: bplus 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.
Title: Re: help my
Post by: bplus 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.  
Title: Re: help my
Post by: Kiara87 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
Title: Re: help my
Post by: bplus on July 17, 2020, 04:37:43 pm
Quote
you can see that it works dates go back and forth

👍
YES! 
Title: Re: help my
Post by: bplus 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?
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Correct?
Title: Re: help my
Post by: Kiara87 on July 17, 2020, 05:38:28 pm
Looking for 67 and 4 in a line on the right side for this pair of 30's on left side?
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Correct?

EXACT 

JUST SO
Title: Re: help my
Post by: bplus on July 18, 2020, 12:54:50 am
Here it is (I think).
Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!  b+ mod of kiara mod of b+ 2020-07-15
  2. _TITLE "Lotto Data"
  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. ' 2020-07-18 change GOSUB loadLineDAT_Mark30s:
  7. '           to mark Blue only line with triple pairs. Can only do one pair at time for right screen check.
  8. '           Make function missingTriple, so we know what number to search for on right screen.
  9. '           OK modified loadLineDAT_Mark30s: GOSUB some more to catch the missing triple pair
  10. '           marked in Red on right screen.
  11.  
  12. DEFINT A-Z ' everything is integer unless DIM or suffix
  13. CONST nRows = 11 '                          rows of 5 data points in each line of fileDat
  14.  
  15. DIM count '                                 for number of lines in the data file
  16.  
  17. DIM lineNum, lineNum2 '                     for tracking array access this is actual file line of data we are screening
  18. DIM a AS STRING, a2 AS STRING '             extraction lines of data
  19. DIM lottoNum, lottoNum2 '                   for extractions
  20. DIM lottoDate$, lottoDate2$ '               for the dates of lottos
  21.  
  22. ' user inputs
  23. DIM Q$ '                                    for INKEY$
  24. DIM mb, mx, my, oldmouse '                  Mouse stuff oldmouse is trick Steve McNeill showed us to get ONE mouse click!
  25.  
  26. ' these would normally go in SUBs or FUNCTIONs but we are using GOSUBs here
  27. DIM shiftRight, shiftRight2 '               screening data left and right, normally these would be CONSTANTs
  28. shiftRight = 11 '                           according to screen fit
  29. shiftRight2 = 65 '                          according to screen fit
  30.  
  31. DIM row, col, aPlace '                      for screening Data from a string
  32. DIM rowCnt, y, rowPlus '                    for loading lineDAT() from a file string
  33. DIM lineDAT(1 TO 5, 1 TO nRows) AS INTEGER 'an  array to load from each line from DAT
  34. DIM third1, third2 '                        the missing part of triplet
  35. DIM hit1st, hit2nd '                        find 3rd triple pair on right screen
  36.  
  37. DIM i '                                     common use for indexing
  38.  
  39. DIM SHARED msNomeMesi(1 TO 12) AS STRING ' matrice di stringhe
  40. msNomeMesi(1) = "Gennaio"
  41. msNomeMesi(2) = "Febbraio"
  42. msNomeMesi(3) = "Marzo"
  43. msNomeMesi(4) = "Aprile"
  44. msNomeMesi(5) = "Maggio"
  45. msNomeMesi(6) = "Giugno"
  46. msNomeMesi(7) = "Luglio"
  47. msNomeMesi(8) = "Agosto"
  48. msNomeMesi(9) = "Settembre"
  49. msNomeMesi(10) = "Ottobre"
  50. msNomeMesi(11) = "Novembre"
  51. msNomeMesi(12) = "Dicembre"
  52.  
  53. DIM labels(1 TO 11) AS STRING ' setup screen labels for reporting data
  54. labels(1) = "BARI"
  55. labels(2) = "CAGLIARI"
  56. labels(3) = "FIRENZE"
  57. labels(4) = "GENOVA"
  58. labels(5) = "MILANO"
  59. labels(6) = "NAPOLI"
  60. labels(7) = "PALERMO"
  61. labels(8) = "ROMA"
  62. labels(9) = "TORINO"
  63. labels(10) = "VENEZIA"
  64. labels(11) = "NAZIONALE"
  65.  
  66. '-------------------------------- start Main setup get file data loaded into array
  67.  
  68. 'count lines in file
  69. OPEN "lotto.dat" FOR INPUT AS #1
  70.     INPUT #1, a
  71.     '          debug check inputs from file
  72.     'PRINT a
  73.     'INPUT " OK enter "; w$
  74.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  75.  
  76. 'now we now size of file so ready an array to load file Data
  77. DIM fileDAT(1 TO count) AS STRING
  78. OPEN "lotto.dat" FOR INPUT AS #1
  79. FOR i = 1 TO count
  80.     INPUT #1, a
  81.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  82.  
  83. 'get/set first line and get a data string from the FileDAT array  (left set on screen)
  84. lineNum = 1
  85. a = fileDAT(lineNum)
  86. lottoNum = VAL(LEFT$(a, 4))
  87. lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  88.  
  89. 'get/set right side start variables
  90. lineNum2 = 1
  91. a2 = fileDAT(lineNum2)
  92. lottoNum2 = VAL(LEFT$(a2, 4))
  93. lottoDate2$ = ConvertLottoNumToDate$(lottoNum2)
  94.  
  95. DO '------------------------------------------------ Main Loop User selects data to compare
  96.     CLS
  97.     Q$ = INKEY$
  98.     IF Q$ = "+" THEN lineNum = lineNum + 1
  99.     IF Q$ = "-" THEN lineNum = lineNum - 1
  100.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum2 = lineNum2 + 1
  101.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum2 = lineNum2 - 1
  102.  
  103.     mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  104.     'LOCATE 3, 1: PRINT mx, my
  105.     IF mb AND oldmouse = 0 AND my > 24 THEN ' <<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  106.         '_DELAY .25 '        just one click please!
  107.         IF 3 <= mx AND mx <= 11 THEN lineNum = lineNum + 1
  108.         IF 14 <= mx AND mx <= 23 THEN lineNum = lineNum - 1
  109.         IF 56 <= mx AND mx <= 64 THEN lineNum2 = lineNum2 + 1
  110.         IF 67 <= mx AND mx <= 76 THEN lineNum2 = lineNum2 - 1
  111.     END IF
  112.     oldmouse = _MOUSEBUTTON(1) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  113.     IF lineNum > count THEN lineNum = 1
  114.     IF lineNum < 1 THEN lineNum = count
  115.     IF lineNum2 > count THEN lineNum2 = 1
  116.     IF lineNum2 < 1 THEN lineNum2 = count
  117.  
  118.     'get new data line
  119.     a = fileDAT(lineNum) 'left side data
  120.     lottoNum = VAL(LEFT$(a, 4))
  121.     lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  122.  
  123.     a2 = fileDAT(lineNum2) 'right side data
  124.     lottoNum2 = VAL(LEFT$(a2, 4))
  125.     lottoDate2$ = ConvertLottoNumToDate$(lottoNum2)
  126.  
  127.     'print out the data from the new line
  128.     GOSUB labelScreen
  129.     GOSUB screenDataLine
  130.     GOSUB loadLineDAT_Mark30s
  131.     _DISPLAY
  132.     _LIMIT 30
  133.  
  134. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  135. rowCnt = 1: y = 1
  136. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  137.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  138.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  139.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  140. COLOR 9 'blue marker  seacrh through columes for  30's
  141. FOR row = 1 TO 10 'for each of the rows of dat
  142.     FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  143.         REDIM hits(1 TO 5, 0 TO 1), nHits
  144.         nHits = 0: third1 = 0: third2 = 0
  145.         FOR col = 1 TO 5 'for each of the columes of data
  146.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN 'need a pair of hits
  147.                 hits(col, 0) = lineDAT(col, row): hits(col, 1) = lineDAT(col, rowPlus): nHits = nHits + 1
  148.                 IF third1 <> 0 THEN
  149.                     third2 = missingTriple(hits(col, 0), hits(col, 1))
  150.                     EXIT FOR
  151.                 ELSE
  152.                     third1 = missingTriple(hits(col, 0), hits(col, 1))
  153.                 END IF
  154.             END IF
  155.         NEXT
  156.         IF nHits >= 2 THEN 'mark them
  157.             LOCATE 10, 30: PRINT labels(row) + " & " + labels(rowPlus)
  158.             LOCATE 12, 36: PRINT third1; third2
  159.             FOR col = 1 TO 5
  160.                 IF hits(col, 0) THEN
  161.                     LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, row));
  162.                     LOCATE rowPlus * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, rowPlus));
  163.                 END IF
  164.             NEXT
  165.  
  166.             'OK now search the right screen for a line containing the 3rd triple pair
  167.             COLOR 12 '           mark them red
  168.             rowCnt = 1: y = 1
  169.             FOR i = 5 TO LEN(a2) STEP 2 ' is marking off the start of each data 2 digit integer
  170.                 lineDAT(rowCnt, y) = VAL(MID$(a2, i, 2)) 'convert data item to integer
  171.                 rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  172.                 IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  173.             NEXT
  174.             FOR row = 1 TO 11 'for each of the rows of dat
  175.                 hit1st = 0: hit2nd = 0
  176.                 FOR col = 1 TO 5 'for each of the columes of data
  177.                     IF lineDAT(col, row) = third1 THEN hit1st = col
  178.                     IF lineDAT(col, row) = third2 THEN hit2nd = col
  179.                     IF hit1st AND hit2nd THEN
  180.                         LOCATE row * 2 + 1, 55: PRINT labels(row)
  181.                         LOCATE row * 2 + 1, hit1st * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(hit1st, row));
  182.                         LOCATE row * 2 + 1, hit2nd * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(hit2nd, row));
  183.                         EXIT FOR
  184.                     END IF
  185.                 NEXT
  186.             NEXT
  187.             RETURN ' sorry we can do only one triple pair
  188.         END IF
  189.     NEXT
  190.  
  191.  
  192. screenDataLine:
  193. LOCATE 1, 1
  194. PRINT lottoNum; lottoDate$;
  195. LOCATE 1, 48
  196. PRINT lottoNum2; lottoDate2$;
  197. aPlace = 5
  198. FOR row = 1 TO 11
  199.     FOR col = 1 TO 5
  200.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2); ' Left side
  201.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT MID$(a2, aPlace, 2); '<< a2 now Right Side
  202.         aPlace = aPlace + 2
  203.     NEXT
  204.  
  205. labelScreen:
  206. FOR i = 1 TO 11
  207.     LOCATE i * 2 + 1, 1: PRINT labels(i)
  208.     LOCATE i * 2 + 1, 55: PRINT labels(i)
  209. LOCATE 25, 1
  210. PRINT "  Fino / Up  Giu / Down        : Fare clic su :        Fino / Up  Giu / Down";
  211. '      12345678901234567890123456789012345678901234567890123456789012345678901234567890
  212. '               1         2         3         4         5         6         7         8
  213.  
  214. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  215.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  216.  
  217. FUNCTION diff30in90 (a, b) 'default integers a-z
  218.     DIM hi, lo
  219.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  220.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  221.     IF hi - lo = 30 THEN
  222.         diff30in90 = -1
  223.     ELSE
  224.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  225.     END IF
  226.  
  227. FUNCTION missingTriple (t1, t2)
  228.     DIM first, second, third
  229.     IF t1 < 31 THEN
  230.         first = t1
  231.     ELSEIF t1 < 61 THEN
  232.         second = t1
  233.     ELSE
  234.         third = t1
  235.     END IF
  236.     IF t2 < 31 THEN
  237.         first = t2
  238.     ELSEIF t2 < 61 THEN
  239.         second = t2
  240.     ELSE
  241.         third = t2
  242.     END IF
  243.     IF first = 0 THEN
  244.         missingTriple = second - 30
  245.     ELSEIF second = 0 THEN
  246.         missingTriple = third - 30
  247.     ELSE
  248.         missingTriple = second + 30
  249.     END IF
  250.  
  251. ' -----------------------------------------------------  Convert Lotto Num to Date Function and helpers
  252. FUNCTION ConvertLottoNumToDate$ (lottoNumX)
  253.     DIM numberOfDays1463, yr, mo
  254.     numberOfDays1463 = INT(lottoNumX - 1463) / 3 * 7
  255.     yr = 2017
  256.     mo = 6
  257.     WHILE numberOfDays1463 > daysInMonth%(mo, yr) - 1
  258.         numberOfDays1463 = numberOfDays1463 - daysInMonth%(mo, yr)
  259.         mo = mo + 1
  260.         IF mo = 13 THEN mo = 1: yr = yr + 1
  261.     WEND
  262.     ' date shound be day name date/month/year for Italians
  263.     ConvertLottoNumToDate$ = lottoday$(lottoNumX) + _TRIM$(STR$(numberOfDays1463 + 1)) + "/" + msNomeMesi(mo) + "/" + _TRIM$(STR$(yr))
  264.  
  265. FUNCTION lottoday$ (lottoNum)
  266.     IF lottoNum MOD 3 = 1 THEN lottoday$ = "Martedi, "
  267.     IF lottoNum MOD 3 = 2 THEN lottoday$ = "Giovedi, "
  268.     IF lottoNum MOD 3 = 0 THEN lottoday$ = "Sabato, "
  269.  
  270. FUNCTION daysInMonth% (mNum, yearNum)
  271.     DIM copyM, copyY
  272.     copyM = mNum
  273.     IF mNum = 13 THEN copyM = 1: copyY = yearNum + 1 ELSE copyY = yearNum
  274.     SELECT CASE copyM
  275.         CASE 1, 3, 5, 7, 8, 10, 12: daysInMonth% = 31
  276.         CASE 4, 6, 9, 11: daysInMonth% = 30
  277.         CASE 2: daysInMonth% = daysInFeb%(copyY)
  278.     END SELECT
  279.  
  280. FUNCTION daysInFeb% (yr) 'from Pete's calendar this is a very clear calc
  281.     DIM days AS INTEGER
  282.     IF yr MOD 4 = 0 THEN
  283.         IF yr MOD 100 = 0 THEN
  284.             IF yr MOD 400 = 0 THEN days = 29
  285.         ELSE
  286.             days = 29
  287.         END IF
  288.     END IF
  289.     IF days THEN daysInFeb% = days ELSE daysInFeb% = 28
  290.  
 
EDIT: Decided to mark the label Red too. So far 1465 has triples finished in 1590, 1676, 1701...

Oops, time to get to bed that was 1823 not 1873. 1928 is last one for 1465.
Title: Re: help my
Post by: Kiara87 on July 18, 2020, 03:17:41 am
Here it is (I think).
Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's   yep lineMun blah!  b+ mod of kiara mod of b+ 2020-07-15
  2. _TITLE "Lotto Data"
  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. ' 2020-07-18 change GOSUB loadLineDAT_Mark30s:
  7. '           to mark Blue only line with triple pairs. Can only do one pair at time for right screen check.
  8. '           Make function missingTriple, so we know what number to search for on right screen.
  9. '           OK modified loadLineDAT_Mark30s: GOSUB some more to catch the missing triple pair
  10. '           marked in Red on right screen.
  11.  
  12. DEFINT A-Z ' everything is integer unless DIM or suffix
  13. CONST nRows = 11 '                          rows of 5 data points in each line of fileDat
  14.  
  15. DIM count '                                 for number of lines in the data file
  16.  
  17. DIM lineNum, lineNum2 '                     for tracking array access this is actual file line of data we are screening
  18. DIM a AS STRING, a2 AS STRING '             extraction lines of data
  19. DIM lottoNum, lottoNum2 '                   for extractions
  20. DIM lottoDate$, lottoDate2$ '               for the dates of lottos
  21.  
  22. ' user inputs
  23. DIM Q$ '                                    for INKEY$
  24. DIM mb, mx, my, oldmouse '                  Mouse stuff oldmouse is trick Steve McNeill showed us to get ONE mouse click!
  25.  
  26. ' these would normally go in SUBs or FUNCTIONs but we are using GOSUBs here
  27. DIM shiftRight, shiftRight2 '               screening data left and right, normally these would be CONSTANTs
  28. shiftRight = 11 '                           according to screen fit
  29. shiftRight2 = 65 '                          according to screen fit
  30.  
  31. DIM row, col, aPlace '                      for screening Data from a string
  32. DIM rowCnt, y, rowPlus '                    for loading lineDAT() from a file string
  33. DIM lineDAT(1 TO 5, 1 TO nRows) AS INTEGER 'an  array to load from each line from DAT
  34. DIM third1, third2 '                        the missing part of triplet
  35. DIM hit1st, hit2nd '                        find 3rd triple pair on right screen
  36.  
  37. DIM i '                                     common use for indexing
  38.  
  39. DIM SHARED msNomeMesi(1 TO 12) AS STRING ' matrice di stringhe
  40. msNomeMesi(1) = "Gennaio"
  41. msNomeMesi(2) = "Febbraio"
  42. msNomeMesi(3) = "Marzo"
  43. msNomeMesi(4) = "Aprile"
  44. msNomeMesi(5) = "Maggio"
  45. msNomeMesi(6) = "Giugno"
  46. msNomeMesi(7) = "Luglio"
  47. msNomeMesi(8) = "Agosto"
  48. msNomeMesi(9) = "Settembre"
  49. msNomeMesi(10) = "Ottobre"
  50. msNomeMesi(11) = "Novembre"
  51. msNomeMesi(12) = "Dicembre"
  52.  
  53. DIM labels(1 TO 11) AS STRING ' setup screen labels for reporting data
  54. labels(1) = "BARI"
  55. labels(2) = "CAGLIARI"
  56. labels(3) = "FIRENZE"
  57. labels(4) = "GENOVA"
  58. labels(5) = "MILANO"
  59. labels(6) = "NAPOLI"
  60. labels(7) = "PALERMO"
  61. labels(8) = "ROMA"
  62. labels(9) = "TORINO"
  63. labels(10) = "VENEZIA"
  64. labels(11) = "NAZIONALE"
  65.  
  66. '-------------------------------- start Main setup get file data loaded into array
  67.  
  68. 'count lines in file
  69. OPEN "lotto.dat" FOR INPUT AS #1
  70.     INPUT #1, a
  71.     '          debug check inputs from file
  72.     'PRINT a
  73.     'INPUT " OK enter "; w$
  74.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  75.  
  76. 'now we now size of file so ready an array to load file Data
  77. DIM fileDAT(1 TO count) AS STRING
  78. OPEN "lotto.dat" FOR INPUT AS #1
  79. FOR i = 1 TO count
  80.     INPUT #1, a
  81.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  82.  
  83. 'get/set first line and get a data string from the FileDAT array  (left set on screen)
  84. lineNum = 1
  85. a = fileDAT(lineNum)
  86. lottoNum = VAL(LEFT$(a, 4))
  87. lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  88.  
  89. 'get/set right side start variables
  90. lineNum2 = 1
  91. a2 = fileDAT(lineNum2)
  92. lottoNum2 = VAL(LEFT$(a2, 4))
  93. lottoDate2$ = ConvertLottoNumToDate$(lottoNum2)
  94.  
  95. DO '------------------------------------------------ Main Loop User selects data to compare
  96.     CLS
  97.     Q$ = INKEY$
  98.     IF Q$ = "+" THEN lineNum = lineNum + 1
  99.     IF Q$ = "-" THEN lineNum = lineNum - 1
  100.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum2 = lineNum2 + 1
  101.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum2 = lineNum2 - 1
  102.  
  103.     mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  104.     'LOCATE 3, 1: PRINT mx, my
  105.     IF mb AND oldmouse = 0 AND my > 24 THEN ' <<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  106.         '_DELAY .25 '        just one click please!
  107.         IF 3 <= mx AND mx <= 11 THEN lineNum = lineNum + 1
  108.         IF 14 <= mx AND mx <= 23 THEN lineNum = lineNum - 1
  109.         IF 56 <= mx AND mx <= 64 THEN lineNum2 = lineNum2 + 1
  110.         IF 67 <= mx AND mx <= 76 THEN lineNum2 = lineNum2 - 1
  111.     END IF
  112.     oldmouse = _MOUSEBUTTON(1) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  113.     IF lineNum > count THEN lineNum = 1
  114.     IF lineNum < 1 THEN lineNum = count
  115.     IF lineNum2 > count THEN lineNum2 = 1
  116.     IF lineNum2 < 1 THEN lineNum2 = count
  117.  
  118.     'get new data line
  119.     a = fileDAT(lineNum) 'left side data
  120.     lottoNum = VAL(LEFT$(a, 4))
  121.     lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  122.  
  123.     a2 = fileDAT(lineNum2) 'right side data
  124.     lottoNum2 = VAL(LEFT$(a2, 4))
  125.     lottoDate2$ = ConvertLottoNumToDate$(lottoNum2)
  126.  
  127.     'print out the data from the new line
  128.     GOSUB labelScreen
  129.     GOSUB screenDataLine
  130.     GOSUB loadLineDAT_Mark30s
  131.     _DISPLAY
  132.     _LIMIT 30
  133.  
  134. loadLineDAT_Mark30s: 'this  loads the lineDAT array, so we can sweep through the columes and mark 30's
  135. rowCnt = 1: y = 1
  136. FOR i = 5 TO LEN(a) STEP 2 ' is marking off the start of each data 2 digit integer
  137.     lineDAT(rowCnt, y) = VAL(MID$(a, i, 2)) 'convert data item to integer
  138.     rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  139.     IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  140. COLOR 9 'blue marker  seacrh through columes for  30's
  141. FOR row = 1 TO 10 'for each of the rows of dat
  142.     FOR rowPlus = row + 1 TO 11 'compare the next rows for diff 30 with current col, row
  143.         REDIM hits(1 TO 5, 0 TO 1), nHits
  144.         nHits = 0: third1 = 0: third2 = 0
  145.         FOR col = 1 TO 5 'for each of the columes of data
  146.             IF diff30in90(lineDAT(col, row), lineDAT(col, rowPlus)) THEN 'need a pair of hits
  147.                 hits(col, 0) = lineDAT(col, row): hits(col, 1) = lineDAT(col, rowPlus): nHits = nHits + 1
  148.                 IF third1 <> 0 THEN
  149.                     third2 = missingTriple(hits(col, 0), hits(col, 1))
  150.                     EXIT FOR
  151.                 ELSE
  152.                     third1 = missingTriple(hits(col, 0), hits(col, 1))
  153.                 END IF
  154.             END IF
  155.         NEXT
  156.         IF nHits >= 2 THEN 'mark them
  157.             LOCATE 10, 30: PRINT labels(row) + " & " + labels(rowPlus)
  158.             LOCATE 12, 36: PRINT third1; third2
  159.             FOR col = 1 TO 5
  160.                 IF hits(col, 0) THEN
  161.                     LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, row));
  162.                     LOCATE rowPlus * 2 + 1, col * 3 - 2 + shiftRight: PRINT DD$(lineDAT(col, rowPlus));
  163.                 END IF
  164.             NEXT
  165.  
  166.             'OK now search the right screen for a line containing the 3rd triple pair
  167.             COLOR 12 '           mark them red
  168.             rowCnt = 1: y = 1
  169.             FOR i = 5 TO LEN(a2) STEP 2 ' is marking off the start of each data 2 digit integer
  170.                 lineDAT(rowCnt, y) = VAL(MID$(a2, i, 2)) 'convert data item to integer
  171.                 rowCnt = rowCnt + 1 ' increase column if at 6 start new row
  172.                 IF rowCnt = 6 THEN y = y + 1: rowCnt = 1
  173.             NEXT
  174.             FOR row = 1 TO 11 'for each of the rows of dat
  175.                 hit1st = 0: hit2nd = 0
  176.                 FOR col = 1 TO 5 'for each of the columes of data
  177.                     IF lineDAT(col, row) = third1 THEN hit1st = col
  178.                     IF lineDAT(col, row) = third2 THEN hit2nd = col
  179.                     IF hit1st AND hit2nd THEN
  180.                         LOCATE row * 2 + 1, 55: PRINT labels(row)
  181.                         LOCATE row * 2 + 1, hit1st * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(hit1st, row));
  182.                         LOCATE row * 2 + 1, hit2nd * 3 - 2 + shiftRight2: PRINT DD$(lineDAT(hit2nd, row));
  183.                         EXIT FOR
  184.                     END IF
  185.                 NEXT
  186.             NEXT
  187.             RETURN ' sorry we can do only one triple pair
  188.         END IF
  189.     NEXT
  190.  
  191.  
  192. screenDataLine:
  193. LOCATE 1, 1
  194. PRINT lottoNum; lottoDate$;
  195. LOCATE 1, 48
  196. PRINT lottoNum2; lottoDate2$;
  197. aPlace = 5
  198. FOR row = 1 TO 11
  199.     FOR col = 1 TO 5
  200.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT MID$(a, aPlace, 2); ' Left side
  201.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT MID$(a2, aPlace, 2); '<< a2 now Right Side
  202.         aPlace = aPlace + 2
  203.     NEXT
  204.  
  205. labelScreen:
  206. FOR i = 1 TO 11
  207.     LOCATE i * 2 + 1, 1: PRINT labels(i)
  208.     LOCATE i * 2 + 1, 55: PRINT labels(i)
  209. LOCATE 25, 1
  210. PRINT "  Fino / Up  Giu / Down        : Fare clic su :        Fino / Up  Giu / Down";
  211. '      12345678901234567890123456789012345678901234567890123456789012345678901234567890
  212. '               1         2         3         4         5         6         7         8
  213.  
  214. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  215.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  216.  
  217. FUNCTION diff30in90 (a, b) 'default integers a-z
  218.     DIM hi, lo
  219.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  220.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  221.     IF hi - lo = 30 THEN
  222.         diff30in90 = -1
  223.     ELSE
  224.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  225.     END IF
  226.  
  227. FUNCTION missingTriple (t1, t2)
  228.     DIM first, second, third
  229.     IF t1 < 31 THEN
  230.         first = t1
  231.     ELSEIF t1 < 61 THEN
  232.         second = t1
  233.     ELSE
  234.         third = t1
  235.     END IF
  236.     IF t2 < 31 THEN
  237.         first = t2
  238.     ELSEIF t2 < 61 THEN
  239.         second = t2
  240.     ELSE
  241.         third = t2
  242.     END IF
  243.     IF first = 0 THEN
  244.         missingTriple = second - 30
  245.     ELSEIF second = 0 THEN
  246.         missingTriple = third - 30
  247.     ELSE
  248.         missingTriple = second + 30
  249.     END IF
  250.  
  251. ' -----------------------------------------------------  Convert Lotto Num to Date Function and helpers
  252. FUNCTION ConvertLottoNumToDate$ (lottoNumX)
  253.     DIM numberOfDays1463, yr, mo
  254.     numberOfDays1463 = INT(lottoNumX - 1463) / 3 * 7
  255.     yr = 2017
  256.     mo = 6
  257.     WHILE numberOfDays1463 > daysInMonth%(mo, yr) - 1
  258.         numberOfDays1463 = numberOfDays1463 - daysInMonth%(mo, yr)
  259.         mo = mo + 1
  260.         IF mo = 13 THEN mo = 1: yr = yr + 1
  261.     WEND
  262.     ' date shound be day name date/month/year for Italians
  263.     ConvertLottoNumToDate$ = lottoday$(lottoNumX) + _TRIM$(STR$(numberOfDays1463 + 1)) + "/" + msNomeMesi(mo) + "/" + _TRIM$(STR$(yr))
  264.  
  265. FUNCTION lottoday$ (lottoNum)
  266.     IF lottoNum MOD 3 = 1 THEN lottoday$ = "Martedi, "
  267.     IF lottoNum MOD 3 = 2 THEN lottoday$ = "Giovedi, "
  268.     IF lottoNum MOD 3 = 0 THEN lottoday$ = "Sabato, "
  269.  
  270. FUNCTION daysInMonth% (mNum, yearNum)
  271.     DIM copyM, copyY
  272.     copyM = mNum
  273.     IF mNum = 13 THEN copyM = 1: copyY = yearNum + 1 ELSE copyY = yearNum
  274.     SELECT CASE copyM
  275.         CASE 1, 3, 5, 7, 8, 10, 12: daysInMonth% = 31
  276.         CASE 4, 6, 9, 11: daysInMonth% = 30
  277.         CASE 2: daysInMonth% = daysInFeb%(copyY)
  278.     END SELECT
  279.  
  280. FUNCTION daysInFeb% (yr) 'from Pete's calendar this is a very clear calc
  281.     DIM days AS INTEGER
  282.     IF yr MOD 4 = 0 THEN
  283.         IF yr MOD 100 = 0 THEN
  284.             IF yr MOD 400 = 0 THEN days = 29
  285.         ELSE
  286.             days = 29
  287.         END IF
  288.     END IF
  289.     IF days THEN daysInFeb% = days ELSE daysInFeb% = 28
  290.  
 
EDIT: Decided to mark the label Red too. So far 1465 has triples finished in 1590, 1676, 1701...

Oops, time to get to bed that was 1823 not 1873. 1928 is last one for 1465.

1) it works however it does not capture single numbers
as in the photo there is a single number on another wheel but it has not been colored
as in the image --> https://imgur.com/2v3N3u7

2) find only one condition
should find more than one

all the numbers forming a square distance 30
even if they are vertical vertical it is enough that they form a square
as in the image
image1  ---->  https://imgur.com/eOtnorM
image 2 ---->  https://imgur.com/Zb1jJUH

in image two we see that the single numbers have not been colored 36 in NAPOLI  AND TORINO 23

AND SHOULD REPORT 3 CONDITIONS TO PLAY
Title: Re: help my
Post by: bplus on July 18, 2020, 01:33:47 pm
Well good luck with all those numbers!
Title: Re: help my
Post by: Kiara87 on July 18, 2020, 01:50:40 pm
Well good luck with all those numbers!

what do i have to change to do that?

an advice?
Title: Re: help my
Post by: bplus on July 18, 2020, 03:10:41 pm
It's very confusing locating all the different triple completions you describe, I recommend color coding each triple completion. For multiple pairs, displayed in middle, you will have to track location rows for printing labels and the different missing triple with it's own associated color when there is more than one pair.

I think I did the hardest one finding a pair of triple completions in on a row! It might have been way easier had I known any triple completion gets marked. Oh well fun challenge don't see the sense of all this and seems like work/nonsensical to get everything on screen at once.

I think you lost me when saying the columns don't even have to match up. Pretty much changes the algorithm needed to search for triples.
Title: Re: help my
Post by: Kiara87 on July 18, 2020, 03:31:28 pm
It's very confusing locating all the different triple completions you describe, I recommend color coding each triple completion. For multiple pairs, displayed in middle, you will have to track location rows for printing labels and the different missing triple with it's own associated color when there is more than one pair.

I think I did the hardest one finding a pair of triple completions in on a row! It might have been way easier had I known any triple completion gets marked. Oh well fun challenge don't see the sense of all this and seems like work/nonsensical to get everything on screen at once.

I think you lost me when saying the columns don't even have to match up. Pretty much changes the algorithm needed to search for triples.

OK thank you very much you have been really good
now it's up to me to change things in the program
I just need to learn well to program
and complete the job to my needs

thanks for everything friend
Title: Re: help my
Post by: bplus on July 18, 2020, 03:44:54 pm
Thanks, I look forward to seeing you get what you want from the lotto data. :)


Title: Re: help my
Post by: TempodiBasic on July 18, 2020, 08:14:25 pm

Hi guys
how do you find this undefinied project about lotto?
I haven't follow more the thread and so now after a speed read
1. I have not understood how you have pulled out the date from the number of extraction ....
 2. it seems that the goal of program lotto has been changed because from images posted by Kiara87 it seems that now it is not more important to find the number with distance of 30 but some triples....

Please Kiara87 show us the whole plan of program... it is too hard spending time to accomplish a task that is partial and unuseful...be clear and complete!

Italian Google version....
Ciao ragazzi
come trovi questo progetto indefinito sul lotto?
Non ho seguito più il thread e quindi ora dopo una lettura veloce
1. Non ho capito come hai estratto la data dal numero di estrazione ....
  2. sembra che l'obiettivo del programma lotto sia stato modificato perché dalle immagini pubblicate da Kiara87 sembra che ora non sia più importante trovare il numero con una distanza di 30 ma alcune triple ...

Per favore, Kiara87 ci mostra l'intero piano del programma ... è troppo difficile passare del tempo per compiere un compito che è parziale e inutile ... sii chiaro e completo!
Title: Re: help my
Post by: TempodiBasic on July 18, 2020, 08:18:54 pm
Here my MOD of Kiara87 MOD of my example program about finding numbers with 30 between them....

(It is a demonstration about how with flexibility it is possible to get different similar effects using variables as flag and loop FOR)

Code: QB64: [Select]
  1. ' Programma lotto di kiara87
  2. ' il programma legge i dati (numeri estratti da un file.dat)
  3. ' e permette di vedere  le estrazioni a video
  4. ' i numeri con distanza 30 sono evidenziati con colore rosso
  5. ' questi numeri vengono memorizzati e stampati
  6.  
  7. ' Nota 1: sono d'accordo con Bplus e' molto piu'
  8. ' rapido lavorare con dati in RAM che con dati su Disco HDD/SSD/USB/CD/DVD
  9.  
  10. ' valori COSTANTI  generali Vero e Falso
  11. CONST True = -1, False = NOT True
  12. ' le 11 ruote del lotto
  13. CONST Bari = 1, Cagliari = 2, Firenze = 3, Genova = 4, Milano = 5
  14. CONST Napoli = 6, Palermo = 7, Roma = 8, Torino = 9, Venezia = 10, Nazionale = 11
  15. CONST Cifra = 2 ' ogni numero estratto e' una cifra di due caratteri (01-90)
  16.  
  17. DIM a AS STRING ' una stringa per leggere i dati dal file
  18.  
  19. ' salta al sottoprogramma LeggiFile delimitato
  20. ' dalla Label LeggiFIle e dal RETURN
  21. GOSUB LeggiFile
  22.  
  23. ' verifica che tutto il file sia letto
  24. 'FOR b = 1 TO LEN(a) - 116 STEP 116
  25. '    PRINT MID$(a, b, 116)
  26. '    '    PRINT INSTR(b, a, CHR$(13))
  27. '    _DELAY .1
  28. 'NEXT b
  29.  
  30.  
  31.  
  32. ' il ciclo DO...LOOP UNTIL condizione e' un modo piu' moderno
  33. ' rispetto a Etichetta: .... IF condizione GOTO Etichetta
  34. b = 1 ' flag che conta la posizione di lettura nel file  per il riquadro sinistro
  35. f = 1 ' flag che conta la posizione di lettura nel file  per il riquadro destro
  36. z$ = " " ' flag per l'output a schermo del programma
  37. OPEN "distanza30.dat" FOR APPEND AS #2 ' apertura del file dei risultati
  38.     IF z$ <> "" THEN ' se non c'e' input non viene eseguito
  39.         CLS ' questo risolve un glitch di output sullo schermo
  40.         ' in alternativa alla riga sopra CLS nel sottoblocco
  41.         ' MostraEstratti va stampata la stringa estratto e
  42.         ' non il suo valore corrispondente ottenuto con VAL
  43.         GOSUB MostraRuote ' scrive il nome delle ruote del lotto
  44.         GOSUB MostraEstratti ' scrive le estrazioni ed evidenzia quelli distanti 30
  45.     END IF
  46.     ' prende l'input dell'utente
  47.     z$ = UCASE$(INKEY$) ' Z$ mantiene il maiuscolo di Inkey$
  48.     IF z$ = CHR$(0) + CHR$(72) AND b < (LEN(a) - 116) THEN b = b + 116
  49.     IF z$ = CHR$(0) + CHR$(80) AND b > 116 THEN b = b - 116
  50.     IF z$ = "+" AND f < (LEN(a) - 116) THEN f = f + 116
  51.     IF z$ = "-" AND f > 116 THEN f = f - 116
  52.  
  53. LOOP UNTIL z$ = "Q" ' esegue questo ciclo fino a che si preme q per quit
  54. CLOSE #2 ' chiude il file che memorizza i distanti 30 per ogni estrazione esaminata a video
  55.  
  56. END ' indica la fine logica del programma
  57.  
  58.  
  59. '-----------------------AREA sottoprogrammi /SUBroutines
  60.  
  61. ' questa etichetta /label indica il punto di inizio
  62. ' del sottoprogramma (SUBroutine) LeggiFile scritto con vecchio stile GOSUB
  63. ' che usa una etichetta/label e un RETURN per riprendere da dove si era interotto
  64. ' nota1: un metodo ancora piu' antico e' il salto con GOTO
  65. '        che richiede una seconda etichetta per ritornare nel MAIN o programma principale
  66. ' nota2: un metodo migliore e' SUB nomeroutine....END SUB
  67. '        perche' permette la localizzazione delle variabili
  68. LeggiFile:
  69. 'se non trova lotto.dat segnala l'errore a video e termina il programma
  70. IF NOT _FILEEXISTS("lotto.dat") THEN PRINT "File non trovato": END
  71. '<--------------------
  72. ' questo metodo e' piu' lento
  73. ' apre il file lotto.dat per leggere in maniera sequenziale i dati
  74. 'OPEN "lotto.dat" FOR INPUT AS #1
  75. 'LINE INPUT #1, a  ' riempe la variabile a con una riga intera di valori
  76. '<--------------------
  77.  
  78. ' apre lotto.dat per leggerlo in maniera binaria
  79. OPEN "lotto.dat" FOR BINARY AS #1
  80. a = SPACE$(LOF(1)) ' riempe la variabile a di spazi fino alla grandezza in byte del file aperto
  81. GET #1, , a ' legge con una unica operazione il file e lo pone nella variabiel a
  82. CLOSE #1 ' chiude il file appena letto
  83. ' indica il termine della SUBroutine LeggiFile
  84. ' e RITORNA alla riga di codice successiva al salto GOSUB
  85.  
  86. 'seconda SUBroutine /sottoprogramma
  87. MostraRuote:
  88. FOR xx = 1 TO 2 STEP 1 'mentre xx va da 1 a 2 con passo +1
  89.     'ripeti quello che c'e' tra FOR e NEXT
  90.     IF xx = 1 THEN yy = 0 ELSE IF xx = 2 THEN yy = 48
  91.  
  92.     COLOR 15
  93.     LOCATE 1, xx + yy
  94.     PRINT "BARI"
  95.     LOCATE 3, xx + yy
  96.     PRINT "CAGLIARI"
  97.     LOCATE 5, xx + yy
  98.     PRINT "FIRENZE"
  99.     LOCATE 7, xx + yy
  100.     PRINT "GENOVA"
  101.     LOCATE 9, xx + yy
  102.     PRINT "MILANO"
  103.     LOCATE 11, xx + yy
  104.     PRINT "NAPOLI"
  105.     LOCATE 13, xx + yy
  106.     PRINT "PALERMO"
  107.     LOCATE 15, xx + yy
  108.     PRINT "ROMA"
  109.     LOCATE 17, xx + yy
  110.     PRINT "TORINO"
  111.     LOCATE 19, xx + yy
  112.     PRINT "VENEZIA"
  113.     LOCATE 21, xx + yy
  114.     PRINT "NAZIONALE"
  115.  
  116.     '------------------------------------
  117.     IF xx = 1 THEN
  118.         LOCATE 23, xx + 59
  119.         PRINT "+ avanti  - indietro"
  120.     ELSEIF xx = 2 THEN
  121.         LOCATE 23, xx - 1
  122.         PRINT CHR$(24); " avanti   "; CHR$(25); " indietro"
  123.     END IF
  124. NEXT xx ' altro ciclo FOR con nuovo valore di xx
  125.  
  126. ' indica il termine della SUBroutine MostraRuote
  127. ' e RITORNA alla riga di codice successiva al salto GOSUB
  128.  
  129. 'terzo sottoprogramma o SUBroutine
  130. MostraEstratti:
  131.  
  132. ' le prime 4 cifre sembrano essere in numero della estrazione
  133. DIM aaa AS INTEGER, bbb AS INTEGER, ccc AS INTEGER, ddd AS INTEGER
  134.  
  135. FOR aaa = 1 TO 2 STEP 1 ' mentre aaa va da 1 a 2 con passo +1
  136.     ' ripeti quello che sta tra FOR e NEXT
  137.     IF aaa = 1 THEN
  138.         y = 11 ' prima posizione per il carattere da stampare
  139.         bbb = b
  140.         ccc = 1
  141.         ddd = 10
  142.     ELSEIF aaa = 2 THEN
  143.         y = 58
  144.         bbb = f
  145.         ccc = 21
  146.         ddd = 4
  147.     END IF
  148.  
  149.     COLOR ddd, 0
  150.     LOCATE ccc, 32
  151.     PRINT "estraz.num "; MID$(a, bbb, 4)
  152.     COLOR 15, 0
  153.     PRINT #2, "estraz.num "; MID$(a, bbb, 4)
  154.  
  155.     FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR e' di 5 perche' ogni ruota ha 5 estrazioni
  156.         A1 = "" ' resetto a1 per il prossimo giro
  157.         FOR V = Bari TO Nazionale ' per tutte le ruote
  158.             COLOR 15, 0
  159.             'posiziona il cursore
  160.             LOCATE (V * 2) - 1, y
  161.             ' scrive il numero estratto
  162.             PRINT VAL(MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (bbb - 1), Cifra)); "";
  163.             A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (bbb - 1), Cifra))
  164.         NEXT V
  165.         GOSUB Mostra30
  166.         y = POS(0)
  167.     NEXT x
  168. NEXT aaa
  169.  
  170. ' indica il termine della SUBroutine MostraEstratti
  171. ' e RITORNA alla riga di codice successiva al salto GOSUB
  172.  
  173.  
  174.  
  175.  
  176. Mostra30:
  177. FOR v1 = Bari TO Venezia ' per tutte le ruote
  178.     FOR v2 = v1 + 1 TO Nazionale
  179.         IF ABS(VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (bbb - 1), Cifra)) - VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (bbb - 1), Cifra))) = 30 THEN
  180.             COLOR ddd, 0
  181.             'posiziona                                                                      il cursore
  182.             LOCATE (v1 * 2) - 1, y
  183.             ' scrive il numero estratto
  184.             PRINT VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (bbb - 1), Cifra)); "";
  185.             PRINT #2, (MID$(a, (v1 - 1) * 10 + 5 + ((x - 1) * 2) + (bbb - 1), Cifra))
  186.             'posiziona                                                                      il cursore
  187.             LOCATE (v2 * 2) - 1, y
  188.             ' scrive il numero estratto
  189.             PRINT VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (bbb - 1), Cifra)); "";
  190.             PRINT #2, MID$(a, (v2 - 1) * 10 + 5 + ((x - 1) * 2) + (bbb - 1), Cifra)
  191.         END IF
  192.     NEXT v2
  193. NEXT v1
  194. COLOR 15, 0
  195. ' indica il termine della SUBroutine MostraEstratti
  196. ' e RITORNA alla riga di codice successiva al salto GOSUB
  197.  
Title: Re: help my
Post by: Kiara87 on July 19, 2020, 05:46:36 pm
Hi guys
how do you find this undefinied project about lotto?
I haven't follow more the thread and so now after a speed read
1. I have not understood how you have pulled out the date from the number of extraction ....
 2. it seems that the goal of program lotto has been changed because from images posted by Kiara87 it seems that now it is not more important to find the number with distance of 30 but some triples....

Please Kiara87 show us the whole plan of program... it is too hard spending time to accomplish a task that is partial and unuseful...be clear and complete!

Italian Google version....
Ciao ragazzi
come trovi questo progetto indefinito sul lotto?
Non ho seguito più il thread e quindi ora dopo una lettura veloce
1. Non ho capito come hai estratto la data dal numero di estrazione ....
  2. sembra che l'obiettivo del programma lotto sia stato modificato perché dalle immagini pubblicate da Kiara87 sembra che ora non sia più importante trovare il numero con una distanza di 30 ma alcune triple ...

Per favore, Kiara87 ci mostra l'intero piano del programma ... è troppo difficile passare del tempo per compiere un compito che è parziale e inutile ... sii chiaro e completo!

ciao @TempodiBasic

il problema della data la risolto @bplus che ha creato una funzione che va alla grande
la data calcola 1465 con la data di martedi 6 giugno 2017 e quello e stato risoldo spiegando a @bplus creando qualche funzione

io le estrazioni li prendo da questo programma che fa scaricare il file dat  http://www.mediafire.com/file/j82rukten353one/ARCHIVIO2.exe/file
e un programma di igor che usa vb6

cmq ho fatto una specie di pseudo codice spero che si capisca 

PSEUDO CODICE
APRI IL FILE
LEGGI IL FILE
I PRIMI 4 NUMERI SONO LE ESTRAZIONI ESTR. 1465 E = MARTEDI 6 GIUGNO
SE ESTRAZIONE SONO 3:7 E GIOCANO MARTEDI GIOVEDI SABATO
IL RESTO DELLA PRIMA RIGA SONO I NUMERI ESTRATTI
LEGGIMI IL RESTO DELLA LA PRIMA RIGA DEL FILE E METTILA 5 NUMERI PER RUOTA X 11 RUOTA
QUANDO CLICCO IL TASTO + LA PRIMA ESTRAZIONE SCORRE E VA NELLA SECONDA RIGA LEGGENDOMI LA SECONDA RIGA DEL FILE
METTI LA SECONDA RIGA I PRIMI 4 NUMERI SONO ESTRAZIONI
RIMANENZA DEI NUMERI SONO I 5 ESTRATTI PER OGNI RUOTA X 11
SE IN QUALSIASI ESTRAZ SI TROVA UNA COPPIA DI NUMERI SU DUE RUOTE DISTANZA 30 STESSA POSIZIONE ESTRAZIONALE CHE FORMA UN QUADRATO ALLORA COLORALI DI VERDE
STAMPAMI NEL MEZZO DELLE DUE ESTRAZIONI LE DUE DISTANZE 30 MANCANTI E LE RUOTE DOVE SI TROVA LA CONDIZIONE
CERCA I NUMERI NELLA SECONDA ESTRAZIONE COLORANDOLI IN ROSSO SU TUTTE LE RUOTE SOLAMENTE I DUE NUMERI MANCANTI DELLA DISTANZA 30

ESEMPI
si ricercano su  due ruote diverse,

42-58-72-88   i due numeri distanza 30 sono dal 42-72  manca il 12 mentre dal 58-88 manca il 28
quindi il programma stampa nel mezzo delle due estrazioni i due numeri mancanti della terzina il 12-28 è le ruote dove è uscita la condizione
poi li cerca nella seconda estrazione  colorandoli di rosso anche se esce su altre ruote dovrebbe colorare anche un singolo numero dei due oppure tutti e due

i numeri che formano il quadrato possono essere  sia verticali che orizzontali oppure diagonali importante che formano un quadrato nella stessa posizione ad esempio su bari esce 14 in prima posizione e in seconda 74 su cagliari prima e seconda posizione 33-63
anche se sono diagonali verticali orizzontali vabbene
e tutte le condizioni che trova li mette in mezzo alle due estrazioni le ruote da giocare con gli elementi mancanti delle terzine

credo che il mio pseudo codice non sia chiaro cerchero' di rifarlo provando è riprovando
poi devo capire come funziona il for to annidato
e tante funzioni che usate voi programmatori per cambiare il mio codice

bplus nel ultimo codice ha realizzato il programma perfetto però  io non ho dato maggior informazioni
nel senso che non avevo detto che il programma doveva catturare qualsiasi condizione si trovava sia in orizzontale in verticale o diagonale
quindi ha creato il programma che rileva solo 1 sola condizione
il motivo e solo perche non sono stata chiara con i dettagli e fornendo dettagli ben precisi




Title: Re: help my
Post by: TempodiBasic on July 19, 2020, 07:44:09 pm
@Kiara87
per la funzione della data andrò a guardare il codice di Bplus così da capire quale algoritmo di codifica è stato usato visto che il numero di estrazione è vario di anno in anno e non supera il valore 150 come si può evincere guardando un po' gli archivi qui
https://www.estrazionedellotto.it/risultati/archivio-lotto-2017 (https://www.estrazionedellotto.it/risultati/archivio-lotto-2017)
riguardo al tuo scopo finale sembra che sia trovare il numero assente della tripletta con distanza 30 in orizzontale e in verticale.... aspettando maggiori informazioni riguardo la direzione diagonale da usare.
usa l'immagine che posto qui per spiegarmi la diagonale di cui parli.

for function of data I'll take a look at Bplus' code so to understand what algorythm to codify it has been used seeing that the number of extraction is different each year and it cannot be more tha 150 as value as you can understand looking just a little into archives here
https://www.estrazionedellotto.it/risultati/archivio-lotto-2017 (https://www.estrazionedellotto.it/risultati/archivio-lotto-2017)

about your goal it seems to get the absent number of a triplet with distance of 30 both in vertical both horizontal....
waiting more informations about diagonal direction to use.
Use the image that I post here to explain me the  diagonal direction of which you talk.
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: help my
Post by: Kiara87 on July 20, 2020, 04:06:07 am
@Kiara87
per la funzione della data andrò a guardare il codice di Bplus così da capire quale algoritmo di codifica è stato usato visto che il numero di estrazione è vario di anno in anno e non supera il valore 150 come si può evincere guardando un po' gli archivi qui
https://www.estrazionedellotto.it/risultati/archivio-lotto-2017 (https://www.estrazionedellotto.it/risultati/archivio-lotto-2017)
riguardo al tuo scopo finale sembra che sia trovare il numero assente della tripletta con distanza 30 in orizzontale e in verticale.... aspettando maggiori informazioni riguardo la direzione diagonale da usare.
usa l'immagine che posto qui per spiegarmi la diagonale di cui parli.

for function of data I'll take a look at Bplus' code so to understand what algorythm to codify it has been used seeing that the number of extraction is different each year and it cannot be more tha 150 as value as you can understand looking just a little into archives here
https://www.estrazionedellotto.it/risultati/archivio-lotto-2017 (https://www.estrazionedellotto.it/risultati/archivio-lotto-2017)

about your goal it seems to get the absent number of a triplet with distance of 30 both in vertical both horizontal....
waiting more informations about diagonal direction to use.
Use the image that I post here to explain me the  diagonal direction of which you talk.
  [ This attachment cannot be displayed inline in 'Print Page' view ]


06/06/2017  NA 72-84  (2°-4°)  Dist.Diag.30
06/06/2017  VE 24-12  (2°-4°)
Ambi ISOTOPI
-------------------------------------------
ecco una panoramica nella tua immagine su napoli venezia in seconda e 4 posizione  a napoli 2posizione il 72 e 4posizione 84
mentre venezia 2posizione 24 in 4 posizione il 12
quindi occupano tutte due coppie seconda e quarta posizione
il 12 e in diagonale con il 72 mentre il 84 è indiagonale con il 24
le due terzine mancanti delle due coppie sono 42-54
perche dal 12+30=42    dal 72+30=102-90 =12 perche i numeri arrivano a 90 42+30=72
24+30=54    54+30=84      84+30=114-90=24

nel gioco del lotto essendo che i numeri arrivano a 90 la distanza arriva a 45
45 e il massimo della distanza
quindi tra il 12 e 72 non si può dire che è distanza 60 perche la distanza il suo limite è 45
esempio 12+45=57  questa e la distanza 45  nel lotto per vedere la distanza prendo in considerazione il 12

se faccio 12-30=72 perchè nel gioco del lotto quando si esegue il meno è il numero arriva al numero 1 poi ancora meno saranno 90-89-88 fino ad arrivare a 72
esempio dal 12-30  togliendo 11 sarà il numero 1 se faccio meno 12 sarà il numero 90 dal 90 tolgo 18 quindi il numero sarà 72
nel lotto se supera il numero 90 si eseque il numero 90 mentre se devi fare la distanza e vai il calcolo con il - quando arrivi al numero 1 poi cè il 90
spero che il concetto si capisce

Title: Re: help my
Post by: TempodiBasic on July 20, 2020, 07:24:54 am
Ambi ISOTOPI.... questa Aritmologia e Cabala da lotto mi manda in corto circuito i neuroni :-)

cmq sembra che qui ci sia un programma che ti potrebbe aiutare già fatto da qualcun altro....http://www.pc-facile.com/forum/viewtopic.php?t=110012 (http://www.pc-facile.com/forum/viewtopic.php?t=110012)  guarda in fondo al thread c'è il link per il programma.

Solo a vedere questi ragionamenti cabalistici mi viene l'orticaria :-) https://www.lottogazzetta.it/metodo-dellambo-ripetuto-isotopo-i-parte/ (https://www.lottogazzetta.it/metodo-dellambo-ripetuto-isotopo-i-parte/) forse è per questo che mi riesce difficile capire quello che ti serve una mia naturale allergia al campo del lotto.
Title: Re: help my
Post by: Kiara87 on July 20, 2020, 07:46:33 am
Ambi ISOTOPI.... questa Aritmologia e Cabala da lotto mi manda in corto circuito i neuroni :-)

cmq sembra che qui ci sia un programma che ti potrebbe aiutare già fatto da qualcun altro....http://www.pc-facile.com/forum/viewtopic.php?t=110012 (http://www.pc-facile.com/forum/viewtopic.php?t=110012)  guarda in fondo al thread c'è il link per il programma.

Solo a vedere questi ragionamenti cabalistici mi viene l'orticaria :-) https://www.lottogazzetta.it/metodo-dellambo-ripetuto-isotopo-i-parte/ (https://www.lottogazzetta.it/metodo-dellambo-ripetuto-isotopo-i-parte/) forse è per questo che mi riesce difficile capire quello che ti serve una mia naturale allergia al campo del lotto.
si ho visto il tuo link ma io volevo farlo con QB64 PER imparare come fare un programma del lotto e anche imparare il QB64
per programmi su internet riguardante al lotto ne ho scaricati una marea ma volevo imparare a crearne uno tutto mio
magari vedndo come si creava qualche algoritmo

nel codice di bplus  parlo del ultimo codi ha fatto un algoritmo valido che stampa le due terzine mancanti

pero' io non riesco a leggere il suo codice perche' sono inesperto

adesempio volevo adesso capire come cercare la distanza 30 invece che verticale cercarla in orizzontale nelle ruota
cmq certamente se non si conosce bene il lotto non e facile creare un programma per il lotto come io non conoscendo la programmazione ma conoscendo solo il lotto non riesco a creare un programma

il fatto che cerco di usare i vostri consigli ma non mi e chiaro dai vostri codici a modificare spero che un giorno riusciro
e magari creare anche programmi diversi dal lotto programmi di ogni tipo
Title: Re: help my
Post by: TempodiBasic on July 20, 2020, 05:59:20 pm
Ciao Kiara87

riguardo al lotto ho fatto tempo fa in Excel un programmino che calcolava la somma a compenso.
Ossia calcoliamo quanto capitale devi investire per ottenere una vincita sicura.
Il caso più semplice è di giocare 2 numeri su singola ruota puntando 1 euro sulla ambata e 1 euro sull'ambo. Ora sviluppando le statistiche di probabilità di uscita sono 1 caso /90 * 89  ossia 1/8010 eventi. Ogni volta che non vinci ripeti la giocata aumentando la posta in modo da compensare con la vincita i soldi già spesi per giocare. Ebbene secondo lo schema di vincite del lotto https://www.estrazionedellotto.it/prontuario-vincite-lotto (https://www.estrazionedellotto.it/prontuario-vincite-lotto) con ciascun ambata guadagni 5 euro e con l'ambo 250 euro. La giocata è realizzata quando fai ambo e quindi di conseguenza anche 2 ambate quindi la vincita sarebbe 260 euro circa puntando 1 euro su ambata e 1 euro su ambo e giocando 2 numeri su una sola ruota di estrazione. Essendo la probailità dell'evento 1 su 8010 considerando anche la peggiore sfortuna devi arrivare a giocare 8010 volte quei 2 numeri per vincere sicuri. La prima volta punti 2 euro e così continui fino a 260 euro (ossia le prime 130 puntate) poi devi iniziare a incrementare la puntata per recuperare i soldi spesi nelle precedenti puntate. Se lo trovo te lo posto, permette di avere una prospettiva chiara delle somme necessarie per vincere sicuri al lotto.
Un mio amico amava molto giocare al lotto, quindi ne parlava spesso e vista la mia propensione alla programmazione mi chiese di provare a fare un programma che gli permettesse di fare i calcoli per scegliere le giocate vincenti. Aritmologia pura. Sai bene che in Aritmologia i numeri sono circolari come fai tu con il lotto 1- 90 = 1 in Aritmologia a base 90 mentre in Aritmetica 1-90 = -89 a base decimale, 24 +70 = 4 in Aritmologia a base 90 mentre in aritmetica 24+70 = 94 a base decimale.
Una volta definito il problema lo puoi riprodurre e gestire con il codice programma.
Nell'esempio dell'AMBO ISOTOPI che mi hai fatto per spiegarmi la distanza diagonale la differenza tra 72 e 84 in Aritmetica è -12 mentre in Aritmologia 72-84=78. Allo stesso modo la distanza tra 24 e 84 ossia 24-84= 30  in Aritmologia mentre in Aritmetica 24-84 = -60!
Questo piccolo concetto spero che tu lo abbia passato a Bplus ossia che i calcoli vanno fatti secondo l'Aritmologia e non la matematica.
Hai ritenuto molti concetti come se fossero noti a tutti ma sono specifici degli appassionati del lotto.


English version by Google
Hi Kiara87

regarding the lot, I made a program in Excel some time ago that calculated the sum in compensation.
That is, we calculate how much capital you have to invest to get a safe win.
The simplest case is to play 2 numbers on a single wheel by betting 1 euro on the ambata and 1 euro on the both. Now developing the exit probability statistics are 1 case / 90 * 89 or 1/8010 events. Every time you don't win, repeat the game by increasing the stakes in order to compensate with the winnings the money already spent to play. Well according to the winnings scheme of the lot [url] https://www.estrazionedellotto.it/prontuario-vincite-lotto [/ url] with each ambate you earn 5 euros and with the both 250 euros. The bet is made when you do both and consequently also 2 ambates so the win would be around 260 euros by betting 1 euro on ambata and 1 euro on both and playing 2 numbers on a single extraction wheel. Being the probability of event 1 out of 8010 considering even the worst of bad luck you have to get to play 8010 times those 2 numbers to win safely. The first time you bet 2 euros and so you continue up to 260 euros (i.e. the first 130 bets) then you have to start increasing the bet to recover the money spent in the previous bets. If I find it, I place it, it allows you to have a clear perspective of the sums necessary to win the lot safely.
A friend of mine loved playing lotto, so he often talked about it and given my propensity for programming he asked me to try to make a program that would allow him to do the calculations to choose the winning games. Pure arrhythmology. You know well that in Arithmology the numbers are circular as you do with the lot 1- 90 = 1 in Arithmology with base 90 while in Arithmetic 1-90 = -89 with decimal basis, 24 +70 = 4 in Arithmology with base 90 while in arithmetic 24 + 70 = 94 with a decimal base.
Once the problem is defined you can reproduce it and manage it with the program code.
In the example of the AMBO ISOTOPES you made to explain the diagonal distance the difference between 72 and 84 in Arithmetic is -12 while in Arithmology 72-84 = 78. In the same way the distance between 24 and 84 or 24-84 = 30 in Arithmology while in Arithmetic 24-84 = -60!
I hope that you have passed this small concept to Bplus, that is, that the calculations must be made according to Arithmology and not mathematics.
You have thought many ideas as known by all but these concepts are specific for those loves lotto game.
Title: Re: help my
Post by: bplus on July 20, 2020, 06:17:09 pm
"Arithmology" 

Code: QB64: [Select]
  1. FUNCTION missingTriple (t1, t2)
  2.     DIM first, second, third
  3.     IF t1 < 31 THEN
  4.         first = t1
  5.     ELSEIF t1 < 61 THEN
  6.         second = t1
  7.     ELSE
  8.         third = t1
  9.     END IF
  10.     IF t2 < 31 THEN
  11.         first = t2
  12.     ELSEIF t2 < 61 THEN
  13.         second = t2
  14.     ELSE
  15.         third = t2
  16.     END IF
  17.     IF first = 0 THEN
  18.         missingTriple = second - 30
  19.     ELSEIF second = 0 THEN
  20.         missingTriple = third - 30
  21.     ELSE
  22.         missingTriple = second + 30
  23.     END IF
  24.  


True or False is the pair part of a triple?
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.  
Title: Re: help my
Post by: TempodiBasic on July 21, 2020, 01:49:51 pm
Yes Arithmology https://it.wikipedia.org/wiki/Aritmologia#:~:text=L%27aritmologia%20(dal%20greco%20ἀριθμός,%2C%20dualità%2C%20ovvero%20nozioni%20astratte. (https://it.wikipedia.org/wiki/Aritmologia#:~:text=L%27aritmologia%20(dal%20greco%20ἀριθμός,%2C%20dualità%2C%20ovvero%20nozioni%20astratte.) 
Good Stuff Bplus!
Title: Re: help my
Post by: bplus on July 23, 2020, 04:37:47 pm
@Kiara87

Here it is, I couldn't leave it alone. I knew there wasn't enough room to print all the pairs of Triples in the middle screen with labels so I did an short version.

Complete make over almost!
Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's      b+ 2020-07-23 makeover old kiara help code
  2. _TITLE "Lotto Data Triples" '     new title it's all about the triples!
  3. SCREEN _NEWIMAGE(640, 400, 32) '  need graphics screen for all the new colors!
  4. _DELAY .25 'while screen loads
  5.  
  6. '2020-07-17 remove weekday names, move labels into there, fix bottom line up/down click
  7. '           fix function convertLottoNum2Date$ spelling
  8. '           clean out some redundant code loops
  9. ' 2020-07-18 change GOSUB loadLineDAT_Mark30s:
  10. '           to mark Blue only line with triple pairs. Can only do one pair at time for right screen check.
  11. '           Make function missingTriple, so we know what number to search for on right screen.
  12. '           OK modified loadLineDAT_Mark30s: GOSUB some more to catch the missing triple pair
  13. '           marked in Red on right screen.
  14. '
  15. '                               * * * A whole different approach! * * *
  16. ' 2020-07-23 OK look for triple pairs in left screen to complete in the right screen.
  17. '                        ALL NUMBERS ARE COLOR CODED IN LEFT SCREEN
  18. '           The most triples possible is 30, in fact lets keep an array to track which triple
  19. '           each data item on left screen is a member of. The we will analyze the 30 triples for
  20. '           Singles, Pairs and Complete Triples.
  21. '           We will feed a sub 2 data strings from the file and it will match up the missing triples in right screen.
  22. '            create showLottoLines - takes 2 lotto lines and creates array with all triples sorted into locations,
  23. '                                    and display screens while we data in hand.
  24. '            create whichTriple - takes a lotto number in string form and assigns a base30 number and level 1 to 3
  25. '            create makePal - makes a palette of 30 distinct colors I hope
  26. '            convert labelscreen to sub.
  27. '            Looks marvelous to me!
  28.  
  29. DEFINT A-Z ' everything is integer unless DIM or suffix
  30. CONST nRows = 11 '                          rows of 5 data points in each line of fileDat
  31. DIM SHARED shiftRight, shiftRight2 '        screening data left and right, normally these would be CONSTANTs
  32. shiftRight = 11 '                           according to screen fit
  33. shiftRight2 = 65 '                          according to screen fit
  34.  
  35. DIM count '                                 for number of lines in the data file
  36.  
  37. DIM lineNum, lineNum2 '                     for tracking array access this is actual file line of data we are screening
  38. DIM a AS STRING '                           file line of data
  39.  
  40. ' user inputs
  41. DIM Q$ '                                    for INKEY$
  42. DIM mb, mx, my, oldmouse '                  Mouse stuff oldmouse is trick Steve McNeill showed us to get ONE mouse click!
  43.  
  44. DIM i '                                     common use for indexing
  45.  
  46. DIM SHARED msNomeMesi(1 TO 12) AS STRING ' matrice di stringhe
  47. msNomeMesi(1) = "Gennaio"
  48. msNomeMesi(2) = "Febbraio"
  49. msNomeMesi(3) = "Marzo"
  50. msNomeMesi(4) = "Aprile"
  51. msNomeMesi(5) = "Maggio"
  52. msNomeMesi(6) = "Giugno"
  53. msNomeMesi(7) = "Luglio"
  54. msNomeMesi(8) = "Agosto"
  55. msNomeMesi(9) = "Settembre"
  56. msNomeMesi(10) = "Ottobre"
  57. msNomeMesi(11) = "Novembre"
  58. msNomeMesi(12) = "Dicembre"
  59.  
  60. DIM SHARED labels(1 TO 11) AS STRING ' setup screen labels for reporting data
  61. labels(1) = "BARI"
  62. labels(2) = "CAGLIARI"
  63. labels(3) = "FIRENZE"
  64. labels(4) = "GENOVA"
  65. labels(5) = "MILANO"
  66. labels(6) = "NAPOLI"
  67. labels(7) = "PALERMO"
  68. labels(8) = "ROMA"
  69. labels(9) = "TORINO"
  70. labels(10) = "VENEZIA"
  71. labels(11) = "NAZIONALE"
  72.  
  73. '-------------------------------- start Main setup get file data loaded into array
  74.  
  75. DIM SHARED pal(1 TO 30) AS _UNSIGNED LONG ' colors  for the 30 different triples
  76. makePal 'load up palette
  77.  
  78. 'count lines in file
  79. OPEN "lotto.dat" FOR INPUT AS #1
  80.     INPUT #1, a
  81.     '          debug check inputs from file
  82.     'PRINT a
  83.     'INPUT " OK enter "; w$
  84.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  85.  
  86. 'now we know size of file so ready an array to load file Data
  87. DIM fileDAT(1 TO count) AS STRING
  88. OPEN "lotto.dat" FOR INPUT AS #1
  89. FOR i = 1 TO count
  90.     INPUT #1, a
  91.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  92.  
  93. 'get/set first line and get a data string from the FileDAT array  (left set on screen)
  94. lineNum = 1 'left screen data line
  95. lineNum2 = 1 'right screen data line
  96.  
  97. DO '------------------------------------------------ Main Loop User selects data to compare
  98.     CLS
  99.     Q$ = INKEY$
  100.     IF Q$ = "+" THEN lineNum = lineNum + 1
  101.     IF Q$ = "-" THEN lineNum = lineNum - 1
  102.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum2 = lineNum2 + 1
  103.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum2 = lineNum2 - 1
  104.  
  105.     mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  106.     IF mb AND oldmouse = 0 AND my > 24 THEN ' <<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  107.         IF 3 * 8 <= mx AND mx <= 11 * 8 THEN lineNum = lineNum + 1
  108.         IF 14 * 8 <= mx AND mx <= 23 * 8 THEN lineNum = lineNum - 1
  109.         IF 56 * 8 <= mx AND mx <= 64 * 8 THEN lineNum2 = lineNum2 + 1
  110.         IF 67 * 8 <= mx AND mx <= 76 * 8 THEN lineNum2 = lineNum2 - 1
  111.     END IF
  112.     oldmouse = _MOUSEBUTTON(1) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  113.     IF lineNum > count THEN lineNum = 1
  114.     IF lineNum < 1 THEN lineNum = count
  115.     IF lineNum2 > count THEN lineNum2 = 1
  116.     IF lineNum2 < 1 THEN lineNum2 = count
  117.     labelScreen
  118.     showLottoLines fileDAT(lineNum), fileDAT(lineNum2) 'print out the data from the new line
  119.     _DISPLAY
  120.     _LIMIT 30
  121.  
  122. SUB labelScreen
  123.     DIM i
  124.     COLOR &HFFFFFFFF
  125.     FOR i = 1 TO 11
  126.         LOCATE i * 2 + 1, 1: PRINT labels(i)
  127.         LOCATE i * 2 + 1, 55: PRINT labels(i)
  128.     NEXT
  129.     LOCATE 25, 1
  130.     PRINT "  Fino / Up  Giu / Down        : Fare clic su :        Fino / Up  Giu / Down";
  131.     '      12345678901234567890123456789012345678901234567890123456789012345678901234567890
  132.     '               1         2         3         4         5         6         7         8
  133.  
  134. SUB makePal 'make 30 distinctive colors I hope
  135.     DIM i, m, q
  136.     q = 40
  137.     FOR i = 1 TO 30
  138.         m = INT(i / 7) + 1
  139.         SELECT CASE i MOD 7
  140.             CASE 0: pal(i) = _RGB32(m * q + 55, 50, 50)
  141.             CASE 1: pal(i) = _RGB32(50, m * q + 55, 50)
  142.             CASE 2: pal(i) = _RGB32(50, 0, m * q + 55)
  143.             CASE 3: pal(i) = _RGB32(m * q + 55, m * q + 55, 50)
  144.             CASE 4: pal(i) = _RGB32(m * q + 55, 50, m * q + 55)
  145.             CASE 5: pal(i) = _RGB32(50, m * q + 55, m * q + 55)
  146.             CASE 6: pal(i) = _RGB32(m * q + 55, .5 * m * q + 55, .25 * m * q + 55)
  147.         END SELECT
  148.     NEXT
  149.  
  150. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  151.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  152.  
  153. SUB showLottoLines (LottoLine$, LottoLine2$)
  154.     DIM sortedData(1 TO 30, 1 TO 3) AS STRING 'each data line c
  155.     DIM i, d$, b, l, lottoNum, lottoDate$, row, col, count, j, printline, s$, missingT, aplace
  156.  
  157.     COLOR &HFFFFFFFF ' start with white and print dates
  158.     lottoNum = VAL(LEFT$(LottoLine$, 4))
  159.     lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  160.     LOCATE 1, 1: PRINT lottoDate$;
  161.     lottoNum = VAL(LEFT$(LottoLine2$, 4))
  162.     lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  163.     LOCATE 1, 48: PRINT lottoDate$;
  164.  
  165.     FOR i = 1 TO 55 'print right screen = lottoLine2$
  166.         row = INT((i - 1) / 5) + 1
  167.         col = (i - 1) MOD 5 + 1
  168.         d$ = MID$(LottoLine2$, i * 2 + 3, 2)
  169.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT d$; ' Left side
  170.     NEXT
  171.  
  172.     FOR i = 1 TO 55 'print left screen  all the 11 X 5 double digit data and collect data locations of triples
  173.         row = INT((i - 1) / 5) + 1
  174.         col = (i - 1) MOD 5 + 1
  175.         d$ = MID$(LottoLine$, i * 2 + 3, 2)
  176.         whichTriple d$, b, l
  177.         sortedData(b, l) = sortedData(b, l) + DD$(i) 'creating a string of Double Digit (DD$) data locations
  178.         COLOR pal(b)
  179.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT d$; ' Left side
  180.     NEXT
  181.  
  182.     printline = 3 ' to 24
  183.     COLOR &HFFFFFFFF
  184.     FOR i = 1 TO 30 ' going through all the base triples numbers <=30
  185.         COLOR pal(i)
  186.         count = 0
  187.         FOR j = 1 TO 3
  188.             IF sortedData(i, j) <> "" THEN count = count + 1
  189.         NEXT
  190.         IF count = 2 THEN ' found a pair missing a triple
  191.             s$ = ""
  192.             FOR j = 1 TO 3
  193.                 d$ = sortedData(i, j)
  194.                 IF d$ = "" THEN ' look for the missing triple in the right side of screen
  195.                     d$ = "XX"
  196.                     missingT = i + (j - 1) * (30)
  197.                     'scan the right data for missingT
  198.                     aplace = 5
  199.                     FOR row = 1 TO 11 'mark the missing triples with triple color
  200.                         FOR col = 1 TO 5
  201.                             IF VAL(MID$(LottoLine2$, aplace, 2)) = missingT THEN
  202.                                 LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT MID$(LottoLine2$, aplace, 2); '<< a2 now Right Side
  203.                             END IF
  204.                             aplace = aplace + 2
  205.                         NEXT
  206.                     NEXT
  207.                 END IF
  208.                 s$ = s$ + " " + _TRIM$(STR$(i + (j - 1) * 30)) + ":" + d$
  209.             NEXT
  210.             LOCATE printline, 28: PRINT s$
  211.             printline = printline + 1
  212.             IF printline = 25 THEN LOCATE printline, 28: PRINT "out of room!";: EXIT FOR
  213.         END IF
  214.     NEXT
  215.  
  216. SUB whichTriple (number1To90$, base30, level30) 'return a number 1 to 30 and a level 1 to 3  for 2 digit loot number
  217.     DIM n AS INTEGER
  218.     n = VAL(number1To90$)
  219.     IF n > 90 OR n < 1 THEN base30 = 0: level30 = 0: BEEP: EXIT SUB 'alert we have bad number
  220.     IF n <= 30 THEN
  221.         base30 = n: level30 = 1
  222.     ELSEIF n <= 60 THEN
  223.         base30 = n - 30: level30 = 2
  224.     ELSEIF n <= 90 THEN
  225.         base30 = n - 60: level30 = 3
  226.     END IF
  227.  
  228. ' -----------------------------------------------------  Convert Lotto Num to Date Function and helpers
  229. FUNCTION ConvertLottoNumToDate$ (lottoNumX)
  230.     DIM numberOfDays1463, yr, mo
  231.     numberOfDays1463 = INT(lottoNumX - 1463) / 3 * 7
  232.     yr = 2017
  233.     mo = 6
  234.     WHILE numberOfDays1463 > daysInMonth%(mo, yr) - 1
  235.         numberOfDays1463 = numberOfDays1463 - daysInMonth%(mo, yr)
  236.         mo = mo + 1
  237.         IF mo = 13 THEN mo = 1: yr = yr + 1
  238.     WEND
  239.     ' date shound be day name date/month/year for Italians
  240.     ConvertLottoNumToDate$ = lottoday$(lottoNumX) + _TRIM$(STR$(numberOfDays1463 + 1)) + "/" + msNomeMesi(mo) + "/" + _TRIM$(STR$(yr))
  241.  
  242. FUNCTION lottoday$ (lottoNum)
  243.     IF lottoNum MOD 3 = 1 THEN lottoday$ = "Martedi, "
  244.     IF lottoNum MOD 3 = 2 THEN lottoday$ = "Giovedi, "
  245.     IF lottoNum MOD 3 = 0 THEN lottoday$ = "Sabato, "
  246.  
  247. FUNCTION daysInMonth% (mNum, yearNum)
  248.     DIM copyM, copyY
  249.     copyM = mNum
  250.     IF mNum = 13 THEN copyM = 1: copyY = yearNum + 1 ELSE copyY = yearNum
  251.     SELECT CASE copyM
  252.         CASE 1, 3, 5, 7, 8, 10, 12: daysInMonth% = 31
  253.         CASE 4, 6, 9, 11: daysInMonth% = 30
  254.         CASE 2: daysInMonth% = daysInFeb%(copyY)
  255.     END SELECT
  256.  
  257. FUNCTION daysInFeb% (yr) 'from Pete's calendar this is a very clear calc
  258.     DIM days AS INTEGER
  259.     IF yr MOD 4 = 0 THEN
  260.         IF yr MOD 100 = 0 THEN
  261.             IF yr MOD 400 = 0 THEN days = 29
  262.         ELSE
  263.             days = 29
  264.         END IF
  265.     END IF
  266.     IF days THEN daysInFeb% = days ELSE daysInFeb% = 28
  267.  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

You can see the completed triple stand out 19, 49, 79 on the first screen.
Title: Re: help my
Post by: Kiara87 on July 24, 2020, 02:43:23 am
@Kiara87

Here it is, I couldn't leave it alone. I knew there wasn't enough room to print all the pairs of Triples in the middle screen with labels so I did an short version.

Complete make over almost!
Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's      b+ 2020-07-23 makeover old kiara help code
  2. _TITLE "Lotto Data Triples" '     new title it's all about the triples!
  3. SCREEN _NEWIMAGE(640, 400, 32) '  need graphics screen for all the new colors!
  4. _DELAY .25 'while screen loads
  5.  
  6. '2020-07-17 remove weekday names, move labels into there, fix bottom line up/down click
  7. '           fix function convertLottoNum2Date$ spelling
  8. '           clean out some redundant code loops
  9. ' 2020-07-18 change GOSUB loadLineDAT_Mark30s:
  10. '           to mark Blue only line with triple pairs. Can only do one pair at time for right screen check.
  11. '           Make function missingTriple, so we know what number to search for on right screen.
  12. '           OK modified loadLineDAT_Mark30s: GOSUB some more to catch the missing triple pair
  13. '           marked in Red on right screen.
  14. '
  15. '                               * * * A whole different approach! * * *
  16. ' 2020-07-23 OK look for triple pairs in left screen to complete in the right screen.
  17. '                        ALL NUMBERS ARE COLOR CODED IN LEFT SCREEN
  18. '           The most triples possible is 30, in fact lets keep an array to track which triple
  19. '           each data item on left screen is a member of. The we will analyze the 30 triples for
  20. '           Singles, Pairs and Complete Triples.
  21. '           We will feed a sub 2 data strings from the file and it will match up the missing triples in right screen.
  22. '            create showLottoLines - takes 2 lotto lines and creates array with all triples sorted into locations,
  23. '                                    and display screens while we data in hand.
  24. '            create whichTriple - takes a lotto number in string form and assigns a base30 number and level 1 to 3
  25. '            create makePal - makes a palette of 30 distinct colors I hope
  26. '            convert labelscreen to sub.
  27. '            Looks marvelous to me!
  28.  
  29. DEFINT A-Z ' everything is integer unless DIM or suffix
  30. CONST nRows = 11 '                          rows of 5 data points in each line of fileDat
  31. DIM SHARED shiftRight, shiftRight2 '        screening data left and right, normally these would be CONSTANTs
  32. shiftRight = 11 '                           according to screen fit
  33. shiftRight2 = 65 '                          according to screen fit
  34.  
  35. DIM count '                                 for number of lines in the data file
  36.  
  37. DIM lineNum, lineNum2 '                     for tracking array access this is actual file line of data we are screening
  38. DIM a AS STRING '                           file line of data
  39.  
  40. ' user inputs
  41. DIM Q$ '                                    for INKEY$
  42. DIM mb, mx, my, oldmouse '                  Mouse stuff oldmouse is trick Steve McNeill showed us to get ONE mouse click!
  43.  
  44. DIM i '                                     common use for indexing
  45.  
  46. DIM SHARED msNomeMesi(1 TO 12) AS STRING ' matrice di stringhe
  47. msNomeMesi(1) = "Gennaio"
  48. msNomeMesi(2) = "Febbraio"
  49. msNomeMesi(3) = "Marzo"
  50. msNomeMesi(4) = "Aprile"
  51. msNomeMesi(5) = "Maggio"
  52. msNomeMesi(6) = "Giugno"
  53. msNomeMesi(7) = "Luglio"
  54. msNomeMesi(8) = "Agosto"
  55. msNomeMesi(9) = "Settembre"
  56. msNomeMesi(10) = "Ottobre"
  57. msNomeMesi(11) = "Novembre"
  58. msNomeMesi(12) = "Dicembre"
  59.  
  60. DIM SHARED labels(1 TO 11) AS STRING ' setup screen labels for reporting data
  61. labels(1) = "BARI"
  62. labels(2) = "CAGLIARI"
  63. labels(3) = "FIRENZE"
  64. labels(4) = "GENOVA"
  65. labels(5) = "MILANO"
  66. labels(6) = "NAPOLI"
  67. labels(7) = "PALERMO"
  68. labels(8) = "ROMA"
  69. labels(9) = "TORINO"
  70. labels(10) = "VENEZIA"
  71. labels(11) = "NAZIONALE"
  72.  
  73. '-------------------------------- start Main setup get file data loaded into array
  74.  
  75. DIM SHARED pal(1 TO 30) AS _UNSIGNED LONG ' colors  for the 30 different triples
  76. makePal 'load up palette
  77.  
  78. 'count lines in file
  79. OPEN "lotto.dat" FOR INPUT AS #1
  80.     INPUT #1, a
  81.     '          debug check inputs from file
  82.     'PRINT a
  83.     'INPUT " OK enter "; w$
  84.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  85.  
  86. 'now we know size of file so ready an array to load file Data
  87. DIM fileDAT(1 TO count) AS STRING
  88. OPEN "lotto.dat" FOR INPUT AS #1
  89. FOR i = 1 TO count
  90.     INPUT #1, a
  91.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  92.  
  93. 'get/set first line and get a data string from the FileDAT array  (left set on screen)
  94. lineNum = 1 'left screen data line
  95. lineNum2 = 1 'right screen data line
  96.  
  97. DO '------------------------------------------------ Main Loop User selects data to compare
  98.     CLS
  99.     Q$ = INKEY$
  100.     IF Q$ = "+" THEN lineNum = lineNum + 1
  101.     IF Q$ = "-" THEN lineNum = lineNum - 1
  102.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum2 = lineNum2 + 1
  103.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum2 = lineNum2 - 1
  104.  
  105.     mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  106.     IF mb AND oldmouse = 0 AND my > 24 THEN ' <<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  107.         IF 3 * 8 <= mx AND mx <= 11 * 8 THEN lineNum = lineNum + 1
  108.         IF 14 * 8 <= mx AND mx <= 23 * 8 THEN lineNum = lineNum - 1
  109.         IF 56 * 8 <= mx AND mx <= 64 * 8 THEN lineNum2 = lineNum2 + 1
  110.         IF 67 * 8 <= mx AND mx <= 76 * 8 THEN lineNum2 = lineNum2 - 1
  111.     END IF
  112.     oldmouse = _MOUSEBUTTON(1) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  113.     IF lineNum > count THEN lineNum = 1
  114.     IF lineNum < 1 THEN lineNum = count
  115.     IF lineNum2 > count THEN lineNum2 = 1
  116.     IF lineNum2 < 1 THEN lineNum2 = count
  117.     labelScreen
  118.     showLottoLines fileDAT(lineNum), fileDAT(lineNum2) 'print out the data from the new line
  119.     _DISPLAY
  120.     _LIMIT 30
  121.  
  122. SUB labelScreen
  123.     DIM i
  124.     COLOR &HFFFFFFFF
  125.     FOR i = 1 TO 11
  126.         LOCATE i * 2 + 1, 1: PRINT labels(i)
  127.         LOCATE i * 2 + 1, 55: PRINT labels(i)
  128.     NEXT
  129.     LOCATE 25, 1
  130.     PRINT "  Fino / Up  Giu / Down        : Fare clic su :        Fino / Up  Giu / Down";
  131.     '      12345678901234567890123456789012345678901234567890123456789012345678901234567890
  132.     '               1         2         3         4         5         6         7         8
  133.  
  134. SUB makePal 'make 30 distinctive colors I hope
  135.     DIM i, m, q
  136.     q = 40
  137.     FOR i = 1 TO 30
  138.         m = INT(i / 7) + 1
  139.         SELECT CASE i MOD 7
  140.             CASE 0: pal(i) = _RGB32(m * q + 55, 50, 50)
  141.             CASE 1: pal(i) = _RGB32(50, m * q + 55, 50)
  142.             CASE 2: pal(i) = _RGB32(50, 0, m * q + 55)
  143.             CASE 3: pal(i) = _RGB32(m * q + 55, m * q + 55, 50)
  144.             CASE 4: pal(i) = _RGB32(m * q + 55, 50, m * q + 55)
  145.             CASE 5: pal(i) = _RGB32(50, m * q + 55, m * q + 55)
  146.             CASE 6: pal(i) = _RGB32(m * q + 55, .5 * m * q + 55, .25 * m * q + 55)
  147.         END SELECT
  148.     NEXT
  149.  
  150. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  151.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  152.  
  153. SUB showLottoLines (LottoLine$, LottoLine2$)
  154.     DIM sortedData(1 TO 30, 1 TO 3) AS STRING 'each data line c
  155.     DIM i, d$, b, l, lottoNum, lottoDate$, row, col, count, j, printline, s$, missingT, aplace
  156.  
  157.     COLOR &HFFFFFFFF ' start with white and print dates
  158.     lottoNum = VAL(LEFT$(LottoLine$, 4))
  159.     lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  160.     LOCATE 1, 1: PRINT lottoDate$;
  161.     lottoNum = VAL(LEFT$(LottoLine2$, 4))
  162.     lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  163.     LOCATE 1, 48: PRINT lottoDate$;
  164.  
  165.     FOR i = 1 TO 55 'print right screen = lottoLine2$
  166.         row = INT((i - 1) / 5) + 1
  167.         col = (i - 1) MOD 5 + 1
  168.         d$ = MID$(LottoLine2$, i * 2 + 3, 2)
  169.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT d$; ' Left side
  170.     NEXT
  171.  
  172.     FOR i = 1 TO 55 'print left screen  all the 11 X 5 double digit data and collect data locations of triples
  173.         row = INT((i - 1) / 5) + 1
  174.         col = (i - 1) MOD 5 + 1
  175.         d$ = MID$(LottoLine$, i * 2 + 3, 2)
  176.         whichTriple d$, b, l
  177.         sortedData(b, l) = sortedData(b, l) + DD$(i) 'creating a string of Double Digit (DD$) data locations
  178.         COLOR pal(b)
  179.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT d$; ' Left side
  180.     NEXT
  181.  
  182.     printline = 3 ' to 24
  183.     COLOR &HFFFFFFFF
  184.     FOR i = 1 TO 30 ' going through all the base triples numbers <=30
  185.         COLOR pal(i)
  186.         count = 0
  187.         FOR j = 1 TO 3
  188.             IF sortedData(i, j) <> "" THEN count = count + 1
  189.         NEXT
  190.         IF count = 2 THEN ' found a pair missing a triple
  191.             s$ = ""
  192.             FOR j = 1 TO 3
  193.                 d$ = sortedData(i, j)
  194.                 IF d$ = "" THEN ' look for the missing triple in the right side of screen
  195.                     d$ = "XX"
  196.                     missingT = i + (j - 1) * (30)
  197.                     'scan the right data for missingT
  198.                     aplace = 5
  199.                     FOR row = 1 TO 11 'mark the missing triples with triple color
  200.                         FOR col = 1 TO 5
  201.                             IF VAL(MID$(LottoLine2$, aplace, 2)) = missingT THEN
  202.                                 LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT MID$(LottoLine2$, aplace, 2); '<< a2 now Right Side
  203.                             END IF
  204.                             aplace = aplace + 2
  205.                         NEXT
  206.                     NEXT
  207.                 END IF
  208.                 s$ = s$ + " " + _TRIM$(STR$(i + (j - 1) * 30)) + ":" + d$
  209.             NEXT
  210.             LOCATE printline, 28: PRINT s$
  211.             printline = printline + 1
  212.             IF printline = 25 THEN LOCATE printline, 28: PRINT "out of room!";: EXIT FOR
  213.         END IF
  214.     NEXT
  215.  
  216. SUB whichTriple (number1To90$, base30, level30) 'return a number 1 to 30 and a level 1 to 3  for 2 digit loot number
  217.     DIM n AS INTEGER
  218.     n = VAL(number1To90$)
  219.     IF n > 90 OR n < 1 THEN base30 = 0: level30 = 0: BEEP: EXIT SUB 'alert we have bad number
  220.     IF n <= 30 THEN
  221.         base30 = n: level30 = 1
  222.     ELSEIF n <= 60 THEN
  223.         base30 = n - 30: level30 = 2
  224.     ELSEIF n <= 90 THEN
  225.         base30 = n - 60: level30 = 3
  226.     END IF
  227.  
  228. ' -----------------------------------------------------  Convert Lotto Num to Date Function and helpers
  229. FUNCTION ConvertLottoNumToDate$ (lottoNumX)
  230.     DIM numberOfDays1463, yr, mo
  231.     numberOfDays1463 = INT(lottoNumX - 1463) / 3 * 7
  232.     yr = 2017
  233.     mo = 6
  234.     WHILE numberOfDays1463 > daysInMonth%(mo, yr) - 1
  235.         numberOfDays1463 = numberOfDays1463 - daysInMonth%(mo, yr)
  236.         mo = mo + 1
  237.         IF mo = 13 THEN mo = 1: yr = yr + 1
  238.     WEND
  239.     ' date shound be day name date/month/year for Italians
  240.     ConvertLottoNumToDate$ = lottoday$(lottoNumX) + _TRIM$(STR$(numberOfDays1463 + 1)) + "/" + msNomeMesi(mo) + "/" + _TRIM$(STR$(yr))
  241.  
  242. FUNCTION lottoday$ (lottoNum)
  243.     IF lottoNum MOD 3 = 1 THEN lottoday$ = "Martedi, "
  244.     IF lottoNum MOD 3 = 2 THEN lottoday$ = "Giovedi, "
  245.     IF lottoNum MOD 3 = 0 THEN lottoday$ = "Sabato, "
  246.  
  247. FUNCTION daysInMonth% (mNum, yearNum)
  248.     DIM copyM, copyY
  249.     copyM = mNum
  250.     IF mNum = 13 THEN copyM = 1: copyY = yearNum + 1 ELSE copyY = yearNum
  251.     SELECT CASE copyM
  252.         CASE 1, 3, 5, 7, 8, 10, 12: daysInMonth% = 31
  253.         CASE 4, 6, 9, 11: daysInMonth% = 30
  254.         CASE 2: daysInMonth% = daysInFeb%(copyY)
  255.     END SELECT
  256.  
  257. FUNCTION daysInFeb% (yr) 'from Pete's calendar this is a very clear calc
  258.     DIM days AS INTEGER
  259.     IF yr MOD 4 = 0 THEN
  260.         IF yr MOD 100 = 0 THEN
  261.             IF yr MOD 400 = 0 THEN days = 29
  262.         ELSE
  263.             days = 29
  264.         END IF
  265.     END IF
  266.     IF days THEN daysInFeb% = days ELSE daysInFeb% = 28
  267.  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

You can see the completed triple stand out 19, 49, 79 on the first screen.

thanks bplus
but this not only finds the distance 30 but finds all numbers
but a great job you are very good at programming
this will be useful when I learn
so I can edit it
Title: Re: help my
Post by: bplus on July 24, 2020, 11:48:04 am
Quote from: qb64
thanks bplus
but this not only finds the distance 30 but finds all numbers
but a great job you are very good at programming
this will be useful when I learn
so I can edit it

Listed in the middle are all the triple PAIRS missing the 3rd triple in the Left screen, the found 3rd triple is color coded on the right.

Isn't that what you wanted? (except the color coding, but that makes more clear which triple it is from.)

Oh also I listed the data location 1 to 55 instead of the Italian Label names for the rows (1 to 11) so you can locate exactly where the triple came from. Like I said there is NOT enough room to list all the Italian label names for the pairs. Could convert to row numbers with a conversion function.
Title: Re: help my
Post by: Kiara87 on July 24, 2020, 04:22:38 pm
Listed in the middle are all the triple PAIRS missing the 3rd triple in the Left screen, the found 3rd triple is color coded on the right.

Isn't that what you wanted? (except the color coding, but that makes more clear which triple it is from.)

Oh also I listed the data location 1 to 55 instead of the Italian Label names for the rows (1 to 11) so you can locate exactly where the triple came from. Like I said there is NOT enough room to list all the Italian label names for the pairs. Could convert to row numbers with a conversion function.

thanks for your interest but I didn't mean this
what I meant not from too many numbers
for example in the extraction of 6 June 2017
from only two conditions

that are these

06/06/2017  CAGLIARI 37-34  (1°-2°)  Dist.Vert.30
06/06/2017  MILANO   07-64  (1°-2°)
Ambi ISOTOPI
-------------------------------------------
06/06/2017  NAPOLI   72-84  (2°-4°)  Dist.Diag.30
06/06/2017  VENEZIA 24-12  (2°-4°)
Ambi ISOTOPI
-------------------------------------------
in the other extractions it can give a maximum of 4 or 5 conditions not many conditions
but many times one or two conditions occur
Title: Re: help my
Post by: TempodiBasic on July 25, 2020, 01:25:35 pm
@Kiara87
riguardo a
Quote
for example in the extraction of 6 June 2017
from only two conditions

that are these

06/06/2017  CAGLIARI 37-34  (1°-2°)  Dist.Vert.30
06/06/2017  MILANO   07-64  (1°-2°)
Ambi ISOTOPI
-------------------------------------------
06/06/2017  NAPOLI   72-84  (2°-4°)  Dist.Diag.30
06/06/2017  VENEZIA 24-12  (2°-4°)
Ambi ISOTOPI

rilevati i 2 ambi isotopi con distanza 30  seguendo le regole aritmologiche 24-84= -60 +90 =30 distanza 30 diagonale, 12 - 72  = -60 +90 = 30 cosa altro deve fare il programma del lotto?
Title: Re: help my
Post by: Kiara87 on July 25, 2020, 05:27:49 pm
@Kiara87
riguardo a
rilevati i 2 ambi isotopi con distanza 30  seguendo le regole aritmologiche 24-84= -60 +90 =30 distanza 30 diagonale, 12 - 72  = -60 +90 = 30 cosa altro deve fare il programma del lotto?
aritmologiche  ma nel lotto si chiamano terzine simmetriche
il programma dalle condizioni che trova deve segnare nel mezzo delle due estrazioni
le condizioni che sono uscite con le terzine simmetriche mancanti come ha fatto bplus nel programma precedente
quello che rilevava solamente una sola condizione rilevava solo la condizione isotopa
io volevo aggiungere che mi rilevava anche le condizioni si isotope ma anche in verticale è orizzontali

il programma dovrebbe fare diamo esempio nella estrazione che ha messo bplus

06/06/2017  CAGLIARI 37-34  (1°-2°)  Dist.Vert.30
06/06/2017  MILANO   07-64  (1°-2°)
Ambi ISOTOPI
-------------------------------------------
06/06/2017  NAPOLI   72-84  (2°-4°)  Dist.Diag.30
06/06/2017  VENEZIA 24-12  (2°-4°)
Ambi ISOTOPI

su cagliari e milano manca la terzina simmetrica che e in prima posizione  ce il 7 e il 37  la terzina mancante è il 67
mentre in 2posizione ce 34 è 64 manca il 4 terzina simmetrica di 4-34-64
quindi nel mezzo delle due estrazioni mi stampa la condizione da giocare con le ruote cosi
cagliari milano 4-67
stessa cosa deve fare alle condizioni trovate come napoli venezia
sotto a cagliari milano mette la condizione di napoli venezia con le due terzine mancanti 42-54
e se trova altre condizioni li mette sotto
ma di solito non ne trova molte al massimo 2 o tre dovrebbe trovarne dipende
e poi nella estrazioni di destra cercare i numeri che stampa in mezzo delle estrazioni segnandoli di rosso
Title: Re: help my
Post by: TempodiBasic on August 06, 2020, 07:52:34 pm
Hi kiara87
please give a look at this program, it may be a good start to get your goal....you must add the date code like that made by Bplus and you have completed the program about AMBO ISOTOPI
https://www.qb64.org/forum/index.php?topic=2891.msg121537#msg121537 (https://www.qb64.org/forum/index.php?topic=2891.msg121537#msg121537)
------------------------
Ciao kiara87
potresti dare uno sguardo a questo programma, esso potrebbe essere un buon inizio per il tuo obiettivo.... tu devi aggiungere il codice per ottenere la data di estrazione come quello fatto da Bplus e così dovresti aver completato il programma su AMBO ISOTOPI.  https://www.qb64.org/forum/index.php?topic=2891.msg121537#msg121537 (https://www.qb64.org/forum/index.php?topic=2891.msg121537#msg121537)

Title: Re: help my
Post by: Kiara87 on August 07, 2020, 03:07:26 am
grazie @TempodiBasic


Hi kiara87
please give a look at this program, it may be a good start to get your goal....you must add the date code like that made by Bplus and you have completed the program about AMBO ISOTOPI
https://www.qb64.org/forum/index.php?topic=2891.msg121537#msg121537 (https://www.qb64.org/forum/index.php?topic=2891.msg121537#msg121537)
------------------------
Ciao kiara87
potresti dare uno sguardo a questo programma, esso potrebbe essere un buon inizio per il tuo obiettivo.... tu devi aggiungere il codice per ottenere la data di estrazione come quello fatto da Bplus e così dovresti aver completato il programma su AMBO ISOTOPI.  https://www.qb64.org/forum/index.php?topic=2891.msg121537#msg121537 (https://www.qb64.org/forum/index.php?topic=2891.msg121537#msg121537)

si questo e proprio quello che cercavo hai trovato il giusto argoritmo
nel mio caso non riuscivo anche perche non sono esperto ancora cerco di imparare
guardando i vostri progetti
come risposto nel tuo thear
devo finire questo progetto aggiungendo la data e cercando i numeri nella estrazione di destra
e dove trova la condizione stampa anche le rote
questo e un programma complesso però credo anche si cresce nella programmazione una volta riuscito a creare qualcosa del genere
bhe credo che cè sempre da imparare cose nuove
forse per creare quello che ho cercato di fare io ci vogliono tanti anni di esperienza
ecco il perchè ho chiesto qui nel forum
comunque devo farti veramente i complimenti ad aver trovato l'algoritmo giusto
adesso devo trovare per finirlo cercherò di studiarlo come faccio ogni giorno
marari riuscirò
Title: Re: help my
Post by: TempodiBasic on August 08, 2020, 03:02:14 pm
Hi kiara87
fine to see that the uncomplete code posted does what you are trying to get... but for me it has been very difficult to understand some concepts that are behind your request and are not visible until, time after time, they came out from your words...

about
Quote
devo finire questo progetto aggiungendo la data e cercando i numeri nella estrazione di destra
e dove trova la condizione stampa anche le rote
questo e un programma complesso però credo anche si cresce nella programmazione una volta riuscito a creare qualcosa del genere
bhe credo che cè sempre da imparare cose nuove

these more features are well in the range of your coding ability! But remember first design plan of the actions  then translate this last in QB64!
And I agree only writing programs you can grow...

Good continuing programming
--------------------
bene vedo che il codice incompleto pubblicato fa quello che stai cercando di ottenere ... ma per me è stato molto difficile capire alcuni concetti che stanno dietro la tua richiesta e non sono visibili finché, di volta in volta, non sono usciti dalla tua parole...
riguardo a
Quote
devo finire questo progetto aggiungendo la data e cercando i numeri nella estrazione di destra
e dove trova la condizione stampa anche le rote
questo e un programma complesso però credo anche si cresce nella programmazione una volta riuscito a creare qualcosa del genere
beh credo che cè sempre da imparare cose nuove
queste altre funzionalità rientrano nella gamma delle tue capacità di codifica! Ma ricorda prima il piano di progettazione delle azioni, quindi traduci quest'ultimo in QB64!
E sono d'accordo che solo scrivendo programmi puoi crescere ...

Buona continuazione della programmazione
Title: Re: help my
Post by: Kiara87 on September 07, 2020, 05:46:19 pm
Hi kiara87

--------------------
bene vedo che il codice incompleto pubblicato fa quello che stai cercando di ottenere ... ma per me è stato molto difficile capire alcuni concetti che stanno dietro la tua richiesta e non sono visibili finché, di volta in volta, non sono usciti dalla tua parole...
riguardo a queste altre funzionalità rientrano nella gamma delle tue capacità di codifica! Ma ricorda prima il piano di progettazione delle azioni, quindi traduci quest'ultimo in QB64!
E sono d'accordo che solo scrivendo programmi puoi crescere ...

Buona continuazione della programmazione

bhe ho provato ad inserire le funzioni che ho citato fino ad oggi non riesco
eppure ho studiato le istruzioni del basic pero' per far questo genere di programma si deve essere veramente esperti
credo che tempodibasic puo aiutarmi se legge il messaggio
@TempodiBasic  se m leggi
help my

Code: QB64: [Select]
  1. ' Programma lotto di kiara87
  2. ' il programma legge i dati (numeri estratti da un file.dat)
  3. ' e permette di vedere  le estrazioni a video
  4. ' i numeri con distanza 30 sono evidenziati con colore rosso
  5. ' questi numeri vengono memorizzati e stampati
  6.  
  7. ' Nota 1: sono d'accordo con Bplus e' molto piu'
  8. ' rapido lavorare con dati in RAM che con dati su Disco HDD/SSD/USB/CD/DVD
  9.  
  10. 'nota 2: si e' scoperto che la distanza 30 e' aritmologica ossia
  11. ' in un sistema ciclico 1-90 per cui se si va oltre il limite si ritorna nel range 1-90
  12. ' invece di pensare i numeri su di una linea retta bisogna pensarli su una
  13. ' linea a cerchio per cui sottrarre o aggiungere equivale a spostarsi indietro
  14. ' o in avanti di un numero specificato di posizioni
  15.  
  16. 'nota 3: lo scopo della ricerca delle coppie di numeri distanti 30 unita'
  17. ' e' quello di individuare la terzina simmetrica con passo 30 che e' interessata
  18. ' (ossia che con 2 numeri forma un ambo) per cercare gli AMBI ISOTOPI
  19. ' (ossia due coppie di numeri che nella griglia delle estrazioni mostrano
  20. ' la stessa posizione formando un quadrilatero)
  21.  
  22. 'nota 4: la coppia di numeri di una terzina simmetrica puo' essere
  23. ' in orizzontale  ( i numeri sono nella stessa ruota di estrazione)
  24. ' in verticale ( i numeri sono nella ' stessa posizione di estrazione tipo 1 estratto,
  25. ' 2 estratto...5 estratto)
  26. ' in diagonale (i numeri appartengono a ruota estrattiva e colonna estrattiva diverse)
  27. '
  28.  
  29. ' valori COSTANTI  generali Vero e Falso
  30. CONST True = -1, False = NOT True
  31. ' le 11 ruote del lotto
  32. CONST Bari = 1, Cagliari = 2, Firenze = 3, Genova = 4, Milano = 5
  33. CONST Napoli = 6, Palermo = 7, Roma = 8, Torino = 9, Venezia = 10, Nazionale = 11
  34. CONST Cifra = 2 ' ogni numero estratto e' una cifra di due caratteri (01-90)
  35.  
  36. DIM a AS STRING ' una stringa per leggere i dati dal file
  37.  
  38. ' salta al sottoprogramma LeggiFile delimitato
  39. ' dalla Label LeggiFIle e dal RETURN
  40. GOSUB LeggiFile
  41.  
  42. ' verifica che tutto il file sia letto
  43. 'FOR b = 1 TO LEN(a) - 116 STEP 116
  44. '    PRINT MID$(a, b, 116)
  45. '    '    PRINT INSTR(b, a, CHR$(13))
  46. '    _DELAY .1
  47. 'NEXT b
  48.  
  49.  
  50.  
  51. ' il ciclo DO...LOOP UNTIL condizione e' un modo piu' moderno
  52. ' rispetto a Etichetta: .... IF condizione GOTO Etichetta
  53. b = 1 ' flag che conta la posizione di lettura nel file  per il riquadro sinistro
  54. f = 1 ' flag che conta la posizione di lettura nel file  per il riquadro destro
  55. z$ = " " ' flag per l'output a schermo del programma
  56. OPEN "distanza30.dat" FOR APPEND AS #2 ' apertura del file dei risultati
  57.     IF z$ <> "" THEN ' se non c'e' input non viene eseguito
  58.         CLS ' questo risolve un glitch di output sullo schermo
  59.         ' in alternativa alla riga sopra CLS nel sottoblocco
  60.         ' MostraEstratti va stampata la stringa estratto e
  61.         ' non il suo valore corrispondente ottenuto con VAL
  62.         GOSUB MostraRuote ' scrive il nome delle ruote del lotto
  63.         GOSUB MostraEstratti ' scrive le estrazioni
  64.         GOSUB cerca30 ' evidenzia gli ambi isotopi nella estrazione di sinistra
  65.         ' e se la terzina simmetrica e' incompleta  segnala il numero mancante
  66.     END IF
  67.     ' prende l'input dell'utente
  68.     z$ = UCASE$(INKEY$) ' Z$ mantiene il maiuscolo di Inkey$
  69.     IF z$ = CHR$(0) + CHR$(72) AND b < (LEN(a) - 116) THEN b = b + 116
  70.     IF z$ = CHR$(0) + CHR$(80) AND b > 116 THEN b = b - 116
  71.     IF z$ = "+" AND f < (LEN(a) - 116) THEN f = f + 116
  72.     IF z$ = "-" AND f > 116 THEN f = f - 116
  73.     IF z$ <> "" THEN riga = 0
  74. LOOP UNTIL z$ = "Q" ' esegue questo ciclo fino a che si preme q per quit
  75. CLOSE #2 ' chiude il file che memorizza i distanti 30 per ogni estrazione esaminata a video
  76.  
  77. END ' indica la fine logica del programma
  78.  
  79.  
  80. '-----------------------AREA sottoprogrammi /SUBroutines
  81.  
  82. ' questa etichetta /label indica il punto di inizio
  83. ' del sottoprogramma (SUBroutine) LeggiFile scritto con vecchio stile GOSUB
  84. ' che usa una etichetta/label e un RETURN per riprendere da dove si era interotto
  85. ' nota1: un metodo ancora piu' antico e' il salto con GOTO
  86. '        che richiede una seconda etichetta per ritornare nel MAIN o programma principale
  87. ' nota2: un metodo migliore e' SUB nomeroutine....END SUB
  88. '        perche' permette la localizzazione delle variabili
  89. LeggiFile:
  90. 'se non trova lotto.dat segnala l'errore a video e termina il programma
  91. IF NOT _FILEEXISTS("lotto.dat") THEN PRINT "File non trovato": END
  92. '<--------------------
  93. ' questo metodo e' piu' lento
  94. ' apre il file lotto.dat per leggere in maniera sequenziale i dati
  95. 'OPEN "lotto.dat" FOR INPUT AS #1
  96. 'LINE INPUT #1, a  ' riempe la variabile a con una riga intera di valori
  97. '<--------------------
  98.  
  99. ' apre lotto.dat per leggerlo in maniera binaria
  100. OPEN "lotto.dat" FOR BINARY AS #1
  101. a = SPACE$(LOF(1)) ' riempe la variabile a di spazi fino alla grandezza in byte del file aperto
  102. GET #1, , a ' legge con una unica operazione il file e lo pone nella variabile a
  103. CLOSE #1 ' chiude il file appena letto
  104. ' indica il termine della SUBroutine LeggiFile
  105. ' e RITORNA alla riga di codice successiva al salto GOSUB
  106.  
  107. 'seconda SUBroutine /sottoprogramma
  108. MostraRuote:
  109. LOCATE 1, 1
  110. PRINT "DATA ESTRAZIONALE"
  111. LOCATE 2, 1
  112. PRINT "BARI"
  113. LOCATE 4, 1
  114. PRINT "CAGLIARI"
  115. LOCATE 6, 1
  116. PRINT "FIRENZE"
  117. LOCATE 8, 1
  118. PRINT "GENOVA"
  119. LOCATE 10, 1
  120. PRINT "MILANO"
  121. LOCATE 12, 1
  122. PRINT "NAPOLI"
  123. LOCATE 14, 1
  124. PRINT "PALERMO"
  125. LOCATE 16, 1
  126. PRINT "ROMA"
  127. LOCATE 18, 1
  128. PRINT "TORINO"
  129. LOCATE 20, 1
  130. PRINT "VENEZIA"
  131. LOCATE 22, 1
  132. PRINT "NAZIONALE"
  133. LOCATE 1, 49
  134. PRINT "DATA ESTRAZIONALE"
  135. LOCATE 2, 49
  136. PRINT "BARI"
  137. LOCATE 4, 49
  138. PRINT "CAGLIARI"
  139. LOCATE 6, 49
  140. PRINT "FIRENZE"
  141. LOCATE 8, 49
  142. PRINT "GENOVA"
  143. LOCATE 10, 49
  144. PRINT "MILANO"
  145. LOCATE 12, 49
  146. PRINT "NAPOLI"
  147. LOCATE 14, 49
  148. PRINT "PALERMO"
  149. LOCATE 16, 49
  150. PRINT "ROMA"
  151. LOCATE 18, 49
  152. PRINT "TORINO"
  153. LOCATE 20, 49
  154. PRINT "VENEZIA"
  155. LOCATE 22, 49
  156. PRINT "NAZIONALE"
  157.  
  158. LOCATE 23, 50
  159. PRINT "+ avanti  - indietro"
  160. LOCATE 23, 1
  161. PRINT CHR$(24); " avanti   "; CHR$(25); " indietro"
  162.  
  163. ' indica il termine della SUBroutine MostraRuote
  164. ' e RITORNA alla riga di codice successiva al salto GOSUB
  165.  
  166. 'terzo sottoprogramma o SUBroutine
  167. MostraEstratti:
  168. ' le prime 4 cifre sembrano essere il numero della estrazione
  169. LOCATE 1, 32
  170. PRINT "estraz.num "; MID$(a, b, 4)
  171. PRINT #2, "estraz.num "; MID$(a, b, 4)
  172. y = 12 ' prima posizione per il carattere da stampare
  173. FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR e' di 5 perche' ogni ruota ha 5 estrazioni
  174.     A1 = "" ' resetto a1 per il prossimo giro
  175.     FOR V = Bari TO Nazionale ' per tutte le ruote
  176.         COLOR 15, 0
  177.         'posiziona il cursore
  178.         LOCATE (V * 2 + 1) - 1, y ' prima estrazione scoperta by MCN
  179.         ' scrive il numero estratto
  180.         PRINT (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); " ";
  181.         A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))
  182.     NEXT V
  183.     y = POS(0)
  184. ' indica il termine della SUBroutine MostraEstratti
  185. ' e RITORNA alla riga di codice successiva al salto GOSUB
  186. LOCATE 23, 32
  187. PRINT "estraz.num "; MID$(a, f, 4)
  188. PRINT #2, "estraz.num "; MID$(a, f, 4)
  189.  
  190. y = 60 ' prima posizione per il carattere da stampare
  191. FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR e' di 5 perche' ogni ruota ha 5 estrazioni
  192.     A1 = "" ' resetto a1 per il prossimo giro
  193.     FOR V = Bari TO Nazionale ' per tutte le ruote
  194.         COLOR 15, 0
  195.         'posiziona il cursore
  196.         LOCATE (V * 2 + 1) - 1, y ' seconda estrazione scoperta by mcn
  197.         ' scrive il numero estratto
  198.         PRINT (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra)); " ";
  199.         A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra))
  200.     NEXT V
  201.     y = POS(0)
  202. ' indica il termine della SUBroutine MostraEstratti
  203. ' e RITORNA alla riga di codice successiva al salto GOSUB
  204.  
  205.  
  206. ' essendo la distanza30 orizzontale e la distanza30 verticale due condizioni
  207. ' particolari della distanza 30 diagonale allora bastera' calcolare questa ultima
  208. ' per calcolare anche le altre...questo trasforma la ricerca da 1 vs 1 con una
  209. ' specifica condizione (stessa riga o stessa colonna) in 1 vs 1 in cui il secondo
  210. ' appartiene al sottoinsieme ruota in esame (v) to nazionale e 1 to 5 estratti (x)
  211. ' quindi dopo aver mostrato le estrazioni va chiamata la subroutine per cercare
  212. ' un ambo con 2 numeri della terzina simmetrica con passo 30
  213. cerca30:
  214. FOR x1 = 1 TO 5 STEP 1
  215.     FOR v1 = Bari TO Venezia STEP 1
  216.         ' estraggo  il numero dall'elenco
  217.         num = VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x1 - 1) * 2) + (b - 1), Cifra))
  218.         ' calcolo il numero precedente e successivo al numero estratto
  219.         IF num < 30 THEN prev = num - 30 + 90 ELSE prev = num - 30
  220.         IF num > 60 THEN succ = num + 30 - 90 ELSE succ = num + 30
  221.         FOR x2 = x1 TO 5
  222.             FOR v2 = v1 TO Nazionale 'per le restanti ruote
  223.                 num2 = VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x2 - 1) * 2) + (b - 1), Cifra))
  224.                 IF num2 = prev OR num2 = succ THEN GOSUB AmboIsotopi
  225.             NEXT v2
  226.         NEXT x2
  227.     NEXT v1
  228. NEXT x1
  229.  
  230.  
  231. AmboIsotopi:
  232. 'cerca nell'intervallo della coppia trovata
  233.  
  234. IF x1 <> x2 THEN
  235.     ' i 2 numeri sono su 2 colonne diverse
  236.     IF v1 <> v2 THEN
  237.         ' i 2 numeri sono su due righe diverse
  238.         ' quindi i 2 numeri sono in diagonale
  239.         num3 = VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x2 - 1) * 2) + (b - 1), Cifra))
  240.         num4 = VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x1 - 1) * 2) + (b - 1), Cifra))
  241.         IF num3 < 30 THEN prev1 = num3 - 30 + 90 ELSE prev1 = num3 - 30
  242.         IF num3 > 60 THEN succ1 = num3 + 30 - 90 ELSE succ1 = num3 + 30
  243.         'se hanno distanza 30 abbiamo trovato un   Ambo Isotopo
  244.         IF num4 = prev1 OR num4 = succ1 THEN GOSUB AmboOk
  245.     ELSE
  246.         ' v1 = v2  i 2 numeri sono sulla stessa riga
  247.         FOR v3 = v1 + 1 TO v2 STEP 1
  248.             num3 = VAL(MID$(a, (v3 - 1) * 10 + 5 + ((x1 - 1) * 2) + (b - 1), Cifra))
  249.             num4 = VAL(MID$(a, (v3 - 1) * 10 + 5 + ((x2 - 1) * 2) + (b - 1), Cifra))
  250.             IF num3 < 30 THEN prev1 = num3 - 30 + 90 ELSE prev1 = num3 - 30
  251.             IF num3 > 60 THEN succ1 = num3 + 30 - 90 ELSE succ1 = num3 + 30
  252.             'se hanno distanza 30 abbiamo trovato un   Ambo Isotopo
  253.             IF num4 = prev1 OR num4 = succ1 THEN GOSUB AmboOk
  254.         NEXT v3
  255.         v3 = 0
  256.     END IF
  257.     ' x1 = x2    i 2 numeri sono sulla stessa colonna
  258.     IF v1 <> v2 THEN
  259.         ' i 2 numeri sono su diverse righe
  260.         FOR x3 = x1 + 1 TO x2 STEP 1
  261.             num3 = VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x3 - 1) * 2) + (b - 1), Cifra))
  262.             num4 = VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x3 - 1) * 2) + (b - 1), Cifra))
  263.             IF num3 < 30 THEN prev1 = num3 - 30 + 90 ELSE prev1 = num3 - 30
  264.             IF num3 > 60 THEN succ1 = num3 + 30 - 90 ELSE succ1 = num3 + 30
  265.             'se hanno distanza 30 abbiamo trovato un   Ambo Isotopo
  266.             IF num4 = prev1 OR num4 = succ1 THEN GOSUB AmboOk
  267.         NEXT x3
  268.         x3 = 0
  269.     ELSE
  270.         ' i 2 numeri sono sulla stessa riga
  271.         ' v1 = v2
  272.         ' e' il caso impossibile perche' i due numeri coincidono con uno solo
  273.     END IF
  274.  
  275.  
  276. AmboOk:
  277. ' evidenzia sulla tabella estrattiva di sinistra i numeri trovati e
  278. ' scrive al centro i numeri mancanti della terzina simmetrica
  279. IF riga < 4 THEN riga = 4 ELSE riga = riga + 2
  280. k = 11
  281. 'posiziona il cursore
  282. LOCATE (v1 * 2 + 1) - 1, k + (x1 * 3) - 2 'IL PRIMO NUMERO TROVATO COLORATO LO POSIZIONA GIUSTO BY MCN
  283. ' scrive il numero estratto
  284. PRINT (MID$(a, (v1 - 1) * 10 + 5 + ((x1 - 1) * 2) + (b - 1), Cifra));
  285. 'posiziona il cursore
  286. LOCATE (v2 * 2 + 1) - 1, k + (x2 * 3) - 2 'IL SECONDO NUMERO TROVATO LO POSIZIONA GIUSTO E LO COLORA BY MCN
  287. ' scrive il numero estratto
  288. PRINT (MID$(a, (v2 - 1) * 10 + 5 + ((x2 - 1) * 2) + (b - 1), Cifra));
  289. IF x1 <> x2 THEN
  290.     IF v1 <> v2 THEN
  291.         'posiziona il cursore
  292.         LOCATE (v1 * 2 + 1) - 1, (x2 * 3) + k - 2 'IL TERZO NUMERO TROVATO LO POSIZIONA E COLORA BY MCN
  293.         ' scrive il numero estratto
  294.         PRINT (MID$(a, (v1 - 1) * 10 + 5 + ((x2 - 1) * 2) + (b - 1), Cifra));
  295.  
  296.         'posiziona il cursore
  297.         LOCATE (v2 * 2 + 1) - 1, (x1 * 3) - 2 + k 'QUARTO NUMERO ESTRATTO TROVATO E POSIZIONA NELL CURSORE DEL NUMERO E LO COLORA BY MCN
  298.         ' scrive il numero estratto
  299.         PRINT (MID$(a, (v2 - 1) * 10 + 5 + ((x1 - 1) * 2) + (b - 1), Cifra));
  300.     ELSE
  301.         'v1 = v2
  302.         'posiziona il cursore
  303.         LOCATE (v3 * 2) - 1, (x1 * 3) - 2 + k
  304.         ' scrive il numero estratto
  305.         PRINT (MID$(a, (v3 - 1) * 10 + 5 + ((x1 - 1) * 2) + (b - 1), Cifra));
  306.  
  307.         'posiziona il cursore
  308.         LOCATE (v3 * 2) - 1, (x2 * 3) - 2 + k
  309.         ' scrive il numero estratto
  310.         PRINT (MID$(a, (v3 - 1) * 10 + 5 + ((x2 - 1) * 2) + (b - 1), Cifra));
  311.     END IF
  312.     ' x1 = x2
  313.  
  314.     IF v1 <> v2 THEN
  315.         'posiziona il cursore
  316.         LOCATE (v3 * 2) - 1, ((x1 - 1) * 3) - 2 + k
  317.         ' scrive il numero estratto
  318.         PRINT (MID$(a, (v1 - 1) * 10 + 5 + ((x3 - 1) * 2) + (b - 1), Cifra));
  319.  
  320.         'posiziona il cursore
  321.         LOCATE (v3 * 2) - 1, ((x2 - 1) * 3) - 2 + k
  322.         ' scrive il numero estratto
  323.         PRINT (MID$(a, (v2 - 1) * 10 + 5 + ((x3 - 1) * 2) + (b - 1), Cifra));
  324.     ELSE
  325.         ' v1 = v2 e' il caso impossibile
  326.     END IF
  327. LOCATE riga, 35:
  328. IF num2 = prev THEN PRINT succ; ELSE PRINT prev;
  329. PRINT "--";
  330. IF num4 = prev1 THEN PRINT succ1; ELSE PRINT prev1;
  331.  
  332. COLOR 15, 0
  333.  
  334.  
  335.  
  336.  
Title: Re: help my
Post by: TempodiBasic on September 07, 2020, 06:57:38 pm
Hi Kiara87

1. for the first step  follow this link
https://translate.google.it/?hl=it#view=home&op=translate&sl=it&tl=en&text=aiutami (https://translate.google.it/?hl=it#view=home&op=translate&sl=it&tl=en&text=aiutami) and so you can gain the right way to say aiutami

2.
your project is
Quote
devo finire questo progetto aggiungendo la data e cercando i numeri nella estrazione di destra
e dove trova la condizione stampa anche le rote
questo e un programma complesso però credo anche si cresce nella programmazione una volta riuscito a creare qualcosa del genere
beh credo che cè sempre da imparare cose nuove
-add the date in the middle of two extractions
 - search the suggested number into the  extraction on the right
 - print on the screen the wheels of that numbers

as soon as I have some time I'll post something for you.
Title: Re: help my
Post by: Kiara87 on September 07, 2020, 07:30:56 pm
Hi Kiara87

1. for the first step  follow this link
https://translate.google.it/?hl=it#view=home&op=translate&sl=it&tl=en&text=aiutami (https://translate.google.it/?hl=it#view=home&op=translate&sl=it&tl=en&text=aiutami) and so you can gain the right way to say aiutami

2.
your project is -add the date in the middle of two extractions
 - search the suggested number into the  extraction on the right
 - print on the screen the wheels of that numbers

as soon as I have some time I'll post something for you.

thanks @TempodiBasic
you are really kind