- Aug
- 2,078
- 85
Here's a script that I use to check lottery numbers. Unless you play Lottario, it won't be of much use to you, but it does have some techniques that might be useful else where.
This is not a finished script, as it could still use more error checking, but it works as is for me.
No, I do not play the numbers in the script.
Joe
This is not a finished script, as it could still use more error checking, but it works as is for me.
No, I do not play the numbers in the script.
Joe
Code:
:: Check Lottario Numbers
::
:: TCC 20.10.32 x64 Windows 7 [Version 6.1.7601]
:: TCC Build 32 Windows 7 Build 7601 Service Pack 1
@setlocal
@echo off
::
:: Get the date of the draw we want to check our ticket against.
::
Gosub GetDrawDate
::
:: Store the generated files in a special location.
::
echo Changing location to c:\users\jlc\Documents\Lottario
cdd c:\users\jlc\Documents\Lottario
::
:: The generated files contain Multiple commands, conditional commands, and piping (affects the command separator, ||, &&, |, and |&)
:: Disable this, or there will be problems.
::
setdos /X-5
::
:: Check my tickets
::
Gosub CheckNumbers 1 3 5 7 9 11
Gosub CheckNumbers 13 15 17 19 21 23
Gosub CheckNumbers 25 27 29 31 33 35
Gosub CheckNumbers 37 39 41 43 44 45
Gosub CheckNumbers 2 4 6 8 10 12
Gosub CheckNumbers 14 16 18 20 22 24
Gosub CheckNumbers 26 28 30 32 34 36
Gosub CheckNumbers 12 38 40 42 44 45
::
:: Re-enable Multiple commands, conditional commands, and piping (affects the command separator, ||, &&, |, and |&)
::
setdos /X0
endlocal
::
:: All done.
::
quit
::
:: Get the date of the draw we want to check our ticket against.
::
:GetDrawDate
::
:: Display a GUI calendar for date selection.
::
set getDate=%@getdate[]
iff %@dowi[%getDate] eq 7 then
::
:: Which month is in the date?
::
set MonthFromDate=%@month[%getDate]
::
:: Is the month number greater than zero?
::
iff %MonthFromDate gt 0 then
::
:: Is the month number less than thirteen?
::
iff %MonthFromDate lt 13 then
::
:: Get the three-letter name for the month
::
set MonthName=%@word[%MonthFromDate,x Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec]
else
::
:: I should never end up here
::
set MonthName=Unknown
quit
endiff
endiff
::
:: Convert date to a format like Sat Jan 2, 2016
::
set DrawDate=%@dow[%getDate] %MonthName %@day[%getDate], %@year[%getDate]
else
::
:: Draws are only on a Saturday.
::
echo %getDate is not a Saturday.
quit
endiff
return
::
:: Check the numbers on my ticket.
::
:CheckNumbers [num1 num2 num3 num4 num5 num6]
::
:: The name of the file will be the numbers on my ticket, followed by the .txt extension.
::
set TargetFile=%@formatn[02.0,%num1]%@formatn[02.0,%num2]%@formatn[02.0,%num3]%@formatn[02.0,%num4]%@formatn[02.0,%num5]%@formatn[02.0,%num6].txt
echo +------------------------------------------------------------------
echo + Checking numbers %@formatn[02.0,%num1] %@formatn[02.0,%num2] %@formatn[02.0,%num3] %@formatn[02.0,%num4] %@formatn[02.0,%num5] %@formatn[02.0,%num6] for Draw Date %DrawDate
echo.
::
:: Default to not getting the "numbers ever won" from the web site.
::
set GetFromWebSite=N
::
:: Does the file for my ticket exist?
::
iff exist %TargetFile then
::
:: Was the file for my ticket created today?
::
iff %@filedate[%TargetFile] eq %_date then
:: Next Sentence
else
::
:: Set Flag to Get the "numbers ever won" from the web site.
::
set GetFromWebSite=Y
endiff
else
::
:: Set Flag to Get the "numbers ever won" from the web site.
::
set GetFromWebSite=Y
endiff
iff %GetFromWebSite eq Y then
echo +-------------------------------------------------------
echo + Downloading winning numbers from http://lottery.olg.ca
echo.
::
:: I use the lynx web browser, which is a text-based Web Browser;
::
:: https://cygwin.com/cgi-bin2/package-grep.cgi?grep=lynx&arch=x86_64
::
:: This browser has the command line option -dump,
:: which dumps the formatted output of the default document or those specified on the command line to standard output.
::
iff %@len[%@search[lynx.exe]] gt 0 then
lynx -dump -accept_all_cookies http://lottery.olg.ca/en-ca/winning-numbers/lottario/have-your-numbers-won?num1=%num1&num2=%num2&num3=%num3&num4=%num4&num5=%num5&num6=%num6 > %TargetFile
else
echo The lynx.exe web browser is required, but cannot be found.
quit
endiff
::
:: Pause for dramatic effect
::
delay 1
endiff
::
:: Now, check and see when my numbers last won.
::
Gosub LastWin
return
::
:: Check and see when my numbers last won.
::
:LastWin
do theline in @%TargetFile
::
:: I am looking for the first word in the line
::
set thedow=%@word[0,%theline]
::
:: If the first word in the line is Sat
::
iff %thedow eq Sat then
echo + Numbers last won on:
::
:: I want to display the next 8 lines from the file
::
head /N+%@dec[%_do_loop] /N 8 %TargetFile
iff %@trimall[%theline] eq %DrawDate then
::
:: We have a winner, so make sure I notice.
::
scrput %_row 0 BRI WHI on BLA + Winner! Winner! Winner! Winner! Winner! Winner! Winner! Winner! Winner! Winner! Winner!
echo.
pause
endiff
echo.
::
:: Nothing else to do, might as well leave now.
::
Leave
endiff
enddo
return