Hi
I have a list in textedit which looks like this:
john smith 3, 9, 31, 37, 40, 42
john doe 2, 5, 6, 8, 35, 38
jane smith 3, 8, 15, 35, 36, 40
bob jones 5, 7, 10, 22, 38, 40
it goes on and on for about 40 lines, there lottery numbers and the names of the people who have
picked them.
i’ve started a script which goes thru this list and checks the numbers against some numbers input into a dialog,
its working about 95% i reckon and i’m not sure where to go, i maybe need to leave it for a day and come back but thought i might post
to see if someone can point me in the right direction.
Heres my script so far
set j to {}
--set t to choose file without invisibles
set lotto_numbers to text returned of (display dialog "Enter this weeks winning lotto numbers!" & return & "Put a comma (,) inbetween each number" default answer "3,9,31,37,40,42")
tell application "TextEdit"
launch
--open t
tell document 1
set u to count every paragraph
repeat with i from 1 to u
--display dialog paragraph i as string
set w to word 1 of paragraph i
set z to word 2 of paragraph i
my checklotto(paragraph i, lotto_numbers, j, w, z)
set j to {}
end repeat
end tell
end tell
to checklotto(x, lotto_numbers, j, w, z)
set thenumbers to words 3 thru 8 of x as list
set astid to (AppleScript's text item delimiters)
set (AppleScript's text item delimiters) to {", "}
set ti_list to text items of thenumbers
set (AppleScript's text item delimiters) to astid
set employee_list to {}
repeat with i in ti_list
try
set i to i as integer
end try
set end of employee_list to (contents of i)
end repeat
--return employee_list-- as a list of numbers
repeat with f in employee_list
if f is in lotto_numbers then
copy f to end of j
end if
end repeat
set s to count j
activate me
display dialog w & space & z & " matched " & s & space & "out of 6 numbers" as string
end checklotto
Has far as i can tell its checking the numbers quite well i’ve matched up my numbers input with the first line in the textedit doc and it gives me 6 out of 6, however when it repeats thru to the next line its giving me 1 out of 6, as far as i’m concerned theres no numbers in the second line that match so i think its picking up the 3 in the 35 or 38 although i could be wrong! (brain fizzing)
any help or guidance with this would be extremely appreciated.
In honesty its only a bit of a fun/practice script really so not massively important but if you can help thanks!!