'  IRISH ,U.K. and EURO ,lotto random number generator with bonus balls
' by Hugh Mc Afee


	'define the variables wi,hi = screen width & height, c & r = column & row numbers, y = button width & height
	'l,t,w,h = window left,top,width & height its for getsize of controls for rect and elipse, fs = font size
	'bfsize = big font size for displaying large random number to call
	int wi,hi,c,r,y,rnum,l,t,w,h,fs
    window w1: ' define the id of the window as "w1"
	GETSCREENSIZE wi,hi:  'get the size of the monitor screen
				c=80:    'start column for our controls
					r=100:    'start row for our controls
					if wi > 800 then	y=40 else y=30:     'width and height of our control, ie 40 pixels sq
					if wi > 800 then fs = 22 else fs = 16:  'font size for controls
'define irish lotto numbers
	int irishlot [46]:    		'46 numbers, its zero based
		for j = 1 to 45:      	'so we just require 45
			irishlot[j] = 0:    'set the numbers to = zero
				next j:         'continue until # 45 has been set to zero

'define the euro lotto numbers
	int eurolot [51]
		for j = 1 to 50
			eurolot[j] = 0
				next j

'define the euro 2 star numbers 1 to 11
	int eurostar [10]
		for j = 1 to 11
			eurostar[j] = 0
				next j

'define the UK lotto numbers
	int picked[50]
		for j=1 to 49
			picked[j]=0
				next j
		'open the w1 window
		OPENWINDOW w1,0,0,wi,hi,@SIZE|@MINBOX|@maxbox,0,"",&w1handler
			SETWINDOWCOLOR w1, RGB(50,110,6)

	CONTROL w1,@STATIC, " LUCKY ,IRISH  +  BRITISH  +  EURO  LOTTERY RANDOM NUMBER GENERATOR",((wi/2)-(wi/2)),10,wi,30,1,99
		SETCONTROLCOLOR (w1,99, rgb(250,250,0),rgb(0,170,0))
			SETFONT( w1, "MS Sans Serif", 16, 700, 0, 99 )

	if wi = 800 then f$="IRISH" else f$="IRISH LOTTERY"
	if wi = 800 then v = 80 else v = 180
	  control w1,@static,f$+" ->",10,r+5,v,20,1,888
		SETCONTROLCOLOR ( w1, 888, RGB( 250,150,0), RGB(255,255,255) ): 'gold on green
			SETFONT( w1, "MS Sans Serif", 12, 900, 0, 888 )
              getsize w1,l,t,w,h,888: ' get the size of the control number j
               SETLINESTYLE w1, @LSSOLID, 12: 'thick line for the ellipse (circle)
                  rect w1,l-5,t-30,w,h,rgb(0,255,0),rgb(255,255,255)
if wi = 800 then 
	r = 200 
		f$ = "BRITISH" 
			v = 80
		elseif wi > 800
			r = 260
				f$ = "BRITISH LOTTERY"
					v = 180
	ENDIF

	control w1,@static,f$,10,r,v,20,1,889
		SETCONTROLCOLOR (w1,889, rgb(255,255,255),rgb(0,0,255))
			SETFONT( w1, "MS Sans Serif", 12, 900, 0, 889 )
              getsize w1,l,t,w,h,889: ' get the size of the control number j
                SETLINESTYLE w1, @LSSOLID, 12: 'thick line for the rectangle
                  rect w1,l-5,t-30,w,h,rgb(255,0,0),rgb(0,0,255)
	if wi = 800 then 
		r = 300 
			f$ = "EURO" 
				v = 80
	elseif wi > 800
		r = 410
			f$ = "EURO LOTTERY"
				v = 180
	ENDIF


	control w1,@static,f$,10,r,v,20,1,900: 'text to show this line is the euro random #s
		SETCONTROLCOLOR (w1,900, rgb(225,255,255),rgb(255,0,0))
			SETFONT( w1, "MS Sans Serif", 12, 900, 0, 900 )
               getsize w1,l,t,w,h,900: ' get the size of the control number j
                 SETLINESTYLE w1, @LSSOLID, 12: 'thick line for the ellipse (circle)
                    rect w1,l-5,t-30,w,h,rgb(0,0,255),rgb(255,0,0)


'IRISH LOTTO
	select 1
		case wi > 800  
			c = 250 
				r = 250 
		case wi = 800
			c=150 
				r = 200
	ENDSELECT
	'U.K. lotto numbers

for j = 1 to 6 : '6 controls for the random numbers to be displayed on for British lottery
	CONTROL w1,@STATIC,str$(j),c,r,y,y,1, j: 'str$(j)=text (1 to 6),c=column#, r=row#,y=width+height,1=flags,j=id 
		SETFONT( w1, "MS Sans Serif", fs, 400, 0, j )
		  SETCONTROLCOLOR ( w1, j, RGB( 255,255,255), RGB(0,0,255) )
             getsize w1,l,t,w,h,j: ' get the size of the control number j start @ #1 end @ #6
               SETLINESTYLE w1, @LSSOLID, 2: 'thick line for the ellipse (circle)
                  ellipse w1,l-20,t-50,w+40,h+35,rgb(255,0,0),rgb(0,0,250): 'put a circle around the control # j colour green
                    c=c+(y+60): 'add (y+60)= column 200+(60+60)=320  = next column to display the next control number
                      next j: 'continue until 6 control buttons with numbers 1 to 6 on them

	'U.K.LOTTO BONUS number

	control w1,@static,"7",c+y+10,r,y,y,1,7
	  getsize w1,l,t,w,h,7: ' get the size of the control number j
         SETLINESTYLE w1, @LSSOLID, 3: 'thick line for the ellipse (circle)
           ellipse w1,l-20,t-50,w+40,h+35,rgb(250,0,0),rgb(0,0,250): 'put a circle around the control # j red & blue
		        SETCONTROLCOLOR ( w1, 7, RGB( 250,0,0), RGB(0,0,250) ): 'white on blue
					SETFONT( w1, "MS Sans Serif", fs, 700, 0, 7 ): ' and we make the number 22 pixels

	if wi > 800 then c=c else c = c - 20
		control w1,@static,"BONUS",c+50,r-40,50,15,1,70: 'text above the bonus #
			SETFONT( w1, "MS Sans Serif", 8, 700, 0, 70 )
				SETCONTROLCOLOR ( w1, 70, RGB( 255,255,255), RGB(0,0,255) )

'THE IRISH LOTTO
	select 1
		case wi > 800  
			c = 250 
				r = 100 
		case wi = 800
			c=150 
				r = 100
					ENDSELECT

	'Irish Lotto random Numbers
for j = 8 to 13: '6 controls for the random numbers to be displayed on for irish lotto
	CONTROL w1,@STATIC,str$(j),c,r,y,y,1, j: 'str$(j)=(number),c=column, r=row,y=width+height,1=[center]flags,j=id 
		  SETCONTROLCOLOR ( w1, j, RGB( 50,90,6), RGB(0,255,0) )
            getsize w1,l,t,w,h,j: ' get the size of the control number j
              SETLINESTYLE w1, @LSSOLID, 3: 'thick line for the ellipse (circle)
                ellipse w1,l-20,t-50,w+40,h+35,rgb(0,255,0),rgb(255,255,255): 'put a circle around the control # j colour green
                   SETCONTROLCOLOR w1,j,rgb(255,155,0),rgb(2555,255,255)
					  SETFONT( w1, "MS Sans Serif", fs, 700, 0, j ): ' and we make the number 32 pixels
						c=c+(y+60)
						  next j
	'Irish Lotto Bonus Number
	control w1,@static,"14",c+y+10,r,y,y,1,14: 'irish bonus # 

if wi > 800 then c=c+50 else c = c+35
	  control w1,@static,"BONUS",c,r-40,50,15,1,72: 'this text goes above the bonus #
		SETFONT( w1, "MS Sans Serif", 8, 700, 0, 72 )
		  SETCONTROLCOLOR ( w1, 72, RGB( 255,255,255), RGB(0,230,0) ): 'gold on green
			getsize w1,l,t,w,h,14: ' get the size of the control number j
              SETLINESTYLE w1, @LSSOLID, 3: 'thick line for the ellipse (circle)
                ellipse w1,l-20,t-50,w+40,h+35,rgb(250,155,0),rgb(255,255,255): 'put a circle around the control # j green&white
                  SETCONTROLCOLOR w1,14,rgb(0,225,0),rgb(255,255,255): 'gold on white
					SETFONT( w1, "MS Sans Serif", fs, 700, 0, 14 ): ' and we make the number 22 pixels



'EURO LOTTO 5 NUMBERS
	select 1
		case wi > 800  
			c = 250 
				r = 400 
		case wi = 800
			c=150 
				r = 300
		ENDSELECT


for j = 15 to 19 : '6 controls for the random numbers to be displayed on
	CONTROL w1,@STATIC,str$(j),c,r,y,y,1, j: 'str$(j)=text (number),c=column, r=row,y=width+height,1=flags,j=id 
		SETFONT( w1, "MS Sans Serif", fs, 900, 0, j )
            getsize w1,l,t,w,h,j: ' get the size of the control number j
              SETLINESTYLE w1, @LSSOLID, 3: 'thick line for the ellipse (circle)
                ellipse w1,l-20,t-50,w+40,h+35,rgb(0,0,250),rgb(255,0,0): 'put a circle around the control # j colour green
                  SETCONTROLCOLOR w1,j,rgb(250,250,250),rgb(255,0,0)
					c=c+(y+60)
						next j


	'EURO LOTTO 2 STAR # = between 1 and 11
if wi > 800 then c = 800 else c = 640

for j = 20 to 21 : '2 controls for the star random numbers to be displayed on
	CONTROL w1,@STATIC,str$(j- 19),c,r,y,y,1, j: 'str$(j)=text (number),c=column, r=row,y=width+height,1=flags,j=id 
		SETFONT( w1, "MS Sans Serif", fs, 700, 0, j )
            getsize w1,l,t,w,h,j: ' get the size of the control number j
              SETLINESTYLE w1, @LSSOLID, 3: 'thick line for the ellipse (circle)
                ellipse w1,l-20,t-50,w+40,h+35,rgb(250,0,0),rgb(255,255,255): 'put a circle around the control # j colour green
                  SETCONTROLCOLOR w1,j,rgb(0,0,250),rgb(250,250,250)
					c=c+(y)+60
					  next j

if wi > 800 then c = 835 else c = 655
	control w1,@STATIC,"2 Star Numbers",c,r-40,100,12,1,333:    ' text above the 2 star numbers
		SETCONTROLCOLOR w1,333,rgb(255,255,250),rgb(255,0,0)
				SETFONT( w1, "MS Sans Serif", 8, 700, 0, 333 )


'when clicked it goes to w1 handler, checks for button #300 
'and carries out commands ,then to the sub show_lotto_numbers()

	CONTROL w1,@button,"Click Me for Your Lucky Lotto Numbers",(wi/2)-370,hi-150,740,30,0,300
		SETFONT( w1, "MS Sans Serif", 12, 700, 0, 300 )
		 SETCONTROLCOLOR ( w1, 300, RGB( 255, 170, 0), RGB(255,255,255) )
			getsize w1,l,t,w,h,300: ' get the size of the control number j
				SETLINESTYLE w1, @LSSOLID, 20: 'thick line for the rectangle around the button
					rect w1,l-5,t-30,w,h+5,rgb(0,255,0),rgb(255,255,255)

run=1:           'run = 1 until the CLOSE program is SELECTED or EXIT button is clicked then it = 0 zero
WAITUNTIL run=0: ' run = 0 then the program has been ended
END:             'close selected from menu, red [x] clicked to close window,or button to exit is clicked


	'THIS SUBROUTINE PICKS THE RANDOM LUCKY NUMBERS  FOR IRISH, U.K., AND ,EURO LOTTO'S   

	sub show_lotto_numbers()
			'GET U.K. RANDOM NUMBERS
	for j = 1 to 7: ' start at control #1 include the bonus ball as number has to be different from lotto numbers
		do :  ' do everything from  here until picked[rnum] = 0                              
			rnum = rand 1,49:  '  random number generator from 1 to 49
				until picked[rnum]=0: ' no numbers picked yet
					picked[rnum]=1: ' now we have got our first random number
                      setcontroltext w1,j,str$(rnum): 'so we place it on control number [j] = 1 at start
						SETFONT( w1, "MS Sans Serif", fs, 700, 0, j ): ' and we make the number 22 pixels
							next j

		'GET IRISH LOTTO RANDOM NUMBERS
	for j = 8 to 14: 'the bonus ball is include as it has to be different from lotto numbers
		do :  ' do everything from  here until picked[rnum] = 0                              
			rnum = rand 1,45:  '  random number generator from 1 to 49
				until picked[rnum]=0: ' no numbers picked yet
					picked[rnum]=1: ' now we have got our first random number
						setcontroltext w1,j,str$(rnum): 'so we place it on control number j = 1 at start
							SETFONT( w1, "MS Sans Serif", fs, 700, 0, j ): ' and we make the number 32 pixels
								next j
									SETCONTROLCOLOR w1,14,rgb(0,200,0),rgb(255,255,255): 'colour the bonus ball different

	'GET EURO LOTTO RANDOM NUMBERS
	for j = 15 to 19: 'just the lotto numbers as the 2 bonus [star] #s are between 1 and 11
		do :  ' do everything from  here until picked[rnum] = 0                              
			rnum = rand 1,50:  '  random number generator from 1 to 49
				until picked[rnum]=0: ' no numbers picked yet
					picked[rnum]=1: ' now we have got our first random number
						setcontroltext w1,j,str$(rnum): 'so we place it on control number j = 1 at start
							SETFONT( w1, "MS Sans Serif", fs, 700, 0, j ): ' and we make the number 32 pixels
								next j

	'GET 2 EURO STAR RANDOM NUMBERS between 1 and 11
	for j = 20 to 21
		do :  ' do everything from  here until picked[rnum] = 0                              
			rnum = rand 1,11:  '  random number generator from 1 to 11
				until picked[rnum]=0: ' no numbers picked yet
					picked[rnum]=1: ' now we have got our first random number
						setcontroltext w1,j,str$(rnum): 'so we place it on control number j = 1 at start
							SETFONT( w1, "MS Sans Serif", fs, 700, 0, j ): ' and we make the number 22 pixels
								next j
	SHOWWINDOW w1,@SWRESTORE,300

	'when the button to select random lotto numbers is clicked, then 
	'display the EXIT  or [another go] button 
		CONTROL w1,@button,"CLICK ME TO EXIT, or, [Click the Button Above] for another go",(wi/2)-300,hi-80,600,20,0,310
			SETFONT( w1, "MS Sans Serif", 12, 600, 0, 310 )
				SETCONTROLCOLOR ( w1, 310, RGB( 0, 255, 0), RGB(0,0,0) )
					getsize w1,l,t,w,h,310: ' get the size of the control number j
						SETLINESTYLE w1, @LSSOLID, 20: 'thick line for the ellipse (circle)
							rect w1,l-5,t-30,w,h+5,rgb(255,0,0),rgb(0,0,0)

RETURN
ENDSUB


' this is the main routine which waits for button clicks, mouse movement, etc
sub w1handler
				select @MESSAGE:          '@message means listen for mouse clicks,etc and send id of item clicked
					case @IDCREATE
                        CENTERWINDOW w1

					case @IDCLOSEWINDOW:  ' red x  clicked
						run = 0:       :  ' run = 0 zero, exit and close program
								

	case @IDCONTROL
		select @CONTROLID
			case 300:     'select random numbers has been clicked
				for x=1 to 49
					picked[x] = 0: 'zero everything
						next x
							SHOWWINDOW w1,300,@SWHIDE
								'wait 1000000000000
                         show_lotto_numbers(): 'and select new random lotto numbers

        case 310:   'exit button has been clicked, so run = 0, close the window = exit game
          run=0:    ' exit
			
ENDSELECT
ENDSELECT
RETURN
ENDSUB

