/* ELDB v3.5 1995 Brian Mitter */ /* 17-3-95 */ /* 'E' Lottery DataBase.... */ /*OPT OSVERSION=37*/ /* Checks for OS 2.0+ */ /**** modules needed.... *****/ MODULE 'gadtools','libraries/gadtools','intuition/intuition', 'intuition/screens','intuition/gadgetclass','graphics/text', 'exec/lists','exec/nodes','utility/tagitem' CONST MYIMAGE_LEFT = 0 CONST MYIMAGE_TOP = 0 CONST MYIMAGE_WIDTH = 24 CONST MYIMAGE_HEIGHT = 10 CONST MYIMAGE_DEPTH = 1 /**** Returns for any errors encountered ****/ ENUM NONE,NOCONTEXT,NOGADGET,NOWB,NOVISUAL,OPENGT,NOWINDOW /**** methods for picking numbers *****/ ENUM GASH,RAND,HOT,COLD,LOW,HIGH,LUCKY /**** Gadget ID's ****/ ENUM METHOD_CYCLE,GO_BUTTON,LINES_CYCLE,ABOUT_BUTTON, QUIT_BUTTON,LUCKY_INTEGER,RESULTS_LIST /**** Assorted DEF's *****/ DEF win:PTR TO window,glist,scr:PTR TO screen,visual=NIL,offx,offy, tattr,randnum,g:PTR TO gadget,perms=1,lastperm,method=1, temp,count,ordered,a,b,c,i,j,file, list=NIL:PTR TO mlh, listView=NIL:PTR TO gadget, stringGadget=NIL:PTR TO gadget, stringGadgetValue:PTR TO LONG,lucky DEF pn[6]:ARRAY, total[49]:ARRAY, copytotals[49]:ARRAY, highnums[20]:ARRAY, lownums[20]:ARRAY, buffer[20]:STRING PROC initList(l:PTR TO mlh) /*-- Initialize an exec list. --*/ l.head:=l+4 l.tail:=NIL l.tailpred:=l ENDPROC /**** Sets up our screen, opens libs and gets visual infos ****/ PROC setupscreen() IF (gadtoolsbase:=OpenLibrary('gadtools.library',37))=NIL THEN RETURN OPENGT IF (scr:=LockPubScreen('Workbench'))=NIL THEN RETURN NOWB IF (visual:=GetVisualInfoA(scr,NIL))=NIL THEN RETURN NOVISUAL offy:=scr.wbortop+Int(scr.rastport+58)-10 tattr:=['topaz.font',8,0,0]:textattr ENDPROC /**** Routine for closing screens, libs and freeing visual ****** ***** info on exit of program normally or because of an error *****/ PROC closedownscreen() IF visual THEN FreeVisualInfo(visual) IF scr THEN UnlockPubScreen(NIL,scr) IF gadtoolsbase THEN CloseLibrary(gadtoolsbase) ENDPROC /**** Opens the main window, sets up gadgets, prints out ***** *****the lottery numbers, and draws bevel boxs (recessed) ****/ PROC openMywindow() DEF stringInfo:PTR TO stringinfo /*-- Init exec list to hold listview items. Starts out empty. --*/ list:=New(SIZEOF mlh) initList(list) IF (g:=CreateContext({glist}))=NIL THEN RETURN NOCONTEXT IF (g:=CreateGadgetA(CYCLE_KIND,g, [offx+302,offy+32,91,15,'Pick Method',tattr,METHOD_CYCLE,4,visual,0]:newgadget, [GTCY_LABELS,['Random','Hot','Cold', 'Low','High','Lucky',0], NIL]))=NIL THEN RETURN NOGADGET IF (g:=CreateGadgetA(BUTTON_KIND,g, [offx+310,offy+55,75,15,'_Go!',tattr,GO_BUTTON,16,visual,0]:newgadget, [GT_UNDERSCORE,"_", NIL]))=NIL THEN RETURN NOGADGET IF (g:=CreateGadgetA(CYCLE_KIND,g, [offx+325,offy+137,93,15,'Lines',tattr,LINES_CYCLE,1,visual,0]:newgadget, [GTCY_LABELS,['x1 lines','x2 lines','x3 lines','x4 lines','x5 lines',0], NIL]))=NIL THEN RETURN NOGADGET IF (g:=CreateGadgetA(BUTTON_KIND,g, [offx+275,offy+158,67,14,'_About',tattr,ABOUT_BUTTON,16,visual,0]:newgadget, [GT_UNDERSCORE,"_", NIL]))=NIL THEN RETURN NOGADGET IF (g:=CreateGadgetA(BUTTON_KIND,g, [offx+355,offy+158,67,14,'_Quit',tattr,QUIT_BUTTON,16,visual,0]:newgadget, [GT_UNDERSCORE,"_", NIL]))=NIL THEN RETURN NOGADGET IF (g:=stringGadget:=CreateGadgetA(INTEGER_KIND,g, [offx+135,offy+155,112,16,'Lucky Number:',tattr,LUCKY_INTEGER,1,visual,0]:newgadget, [GTIN_MAXCHARS,15, NIL]))=NIL THEN RETURN NOGADGET IF (g:=listView:=CreateGadgetA(LISTVIEW_KIND,g, [offx+438,offy+29,185,91,'',tattr,RESULTS_LIST,4,visual,0]:newgadget, [GTLV_LABELS,list, GTLV_READONLY,1, NIL]))=NIL THEN RETURN NOGADGET stringInfo:=stringGadget.specialinfo stringGadgetValue:=stringInfo.buffer IF (win:=OpenWindowTagList(NIL, [WA_LEFT,0, WA_TOP,11, WA_WIDTH,offx+640, WA_HEIGHT,offy+512, WA_IDCMP,(IDCMP_GADGETUP OR IDCMP_CLOSEWINDOW OR IDCMP_VANILLAKEY OR LISTVIEWIDCMP OR SCROLLERIDCMP OR IDCMP_MENUPICK), WA_FLAGS,(WFLG_DRAGBAR OR WFLG_DEPTHGADGET OR WFLG_CLOSEGADGET OR WFLG_SMART_REFRESH OR WFLG_ACTIVATE), WA_TITLE,'ELDB v3.5 © 1995 Brian Mitter', WA_CUSTOMSCREEN, scr, WA_MINWIDTH,67, WA_MINHEIGHT,21, WA_MAXWIDTH,$280, WA_MAXHEIGHT,256, WA_AUTOADJUST,1, WA_GADGETS,glist, NIL]))=NIL THEN RETURN NOWINDOW PrintIText(win.rport, [1,0,0,21,28,tattr,'01 02 03 04 05 06 07 08 09 10',NIL]:intuitext,offx,offy) PrintIText(win.rport, [1,0,0,21,48,tattr,'11 12 13 14 15 16 17 18 19 20',NIL]:intuitext,offx,offy) PrintIText(win.rport, [1,0,0,21,68,tattr,'21 22 23 24 25 26 27 28 29 30',NIL]:intuitext,offx,offy) PrintIText(win.rport, [1,0,0,21,88,tattr,'31 32 33 34 35 36 37 38 39 40',NIL]:intuitext,offx,offy) PrintIText(win.rport, [1,0,0,22,108,tattr,'41 42 43 44 45 46 47 48 49',NIL]:intuitext,offx,offy) PrintIText(win.rport, [1,0,0,75,16,tattr,'Number Occurance',NIL]:intuitext,offx,offy) /* 'x weeks of data bevel box */ DrawBevelBoxA(win.rport,57,136,160,14, [GT_VISUALINFO,visual,GTBB_RECESSED,1,NIL]) /* permiatate bevel box */ DrawBevelBoxA(win.rport,272,134,151,21, [GT_VISUALINFO,visual,GTBB_RECESSED,1,NIL]) /* method bevel box */ DrawBevelBoxA(win.rport,279,15,139,36, [GT_VISUALINFO,visual,GTBB_RECESSED,1,NIL]) /* picked numbers bevel box */ DrawBevelBoxA(win.rport,272,74,151,56, [GT_VISUALINFO,visual,GTBB_RECESSED,1,NIL]) /* database numbers bevel box */ DrawBevelBoxA(win.rport,12,25,251,105, [GT_VISUALINFO,visual,GTBB_RECESSED,1,NIL]) /* graph bevel box */ DrawBevelBoxA(win.rport,7,175,435,77, [GT_VISUALINFO,visual,/*GTBB_RECESSED,1,*/NIL]) PrintIText(win.rport, [1,0,0,446,19,tattr,'1',NIL]:intuitext,offx,offy) DrawBevelBoxA(win.rport,438,17,22,11, [GT_VISUALINFO,visual,NIL]) PrintIText(win.rport, [1,0,0,469,19,tattr,'2',NIL]:intuitext,offx,offy) DrawBevelBoxA(win.rport,462,17,22,11, [GT_VISUALINFO,visual,NIL]) PrintIText(win.rport, [1,0,0,493,19,tattr,'3',NIL]:intuitext,offx,offy) DrawBevelBoxA(win.rport,486,17,22,11, [GT_VISUALINFO,visual,NIL]) PrintIText(win.rport, [1,0,0,517,19,tattr,'4',NIL]:intuitext,offx,offy) DrawBevelBoxA(win.rport,510,17,22,11, [GT_VISUALINFO,visual,NIL]) PrintIText(win.rport, [1,0,0,541,19,tattr,'5',NIL]:intuitext,offx,offy) DrawBevelBoxA(win.rport,534,17,22,11, [GT_VISUALINFO,visual,NIL]) PrintIText(win.rport, [1,0,0,565,19,tattr,'6',NIL]:intuitext,offx,offy) DrawBevelBoxA(win.rport,558,17,22,11, [GT_VISUALINFO,visual,NIL]) PrintIText(win.rport, [1,0,0,589,19,tattr,'B',NIL]:intuitext,offx,offy) DrawBevelBoxA(win.rport,582,17,22,11, [GT_VISUALINFO,visual,NIL]) DrawBevelBoxA(win.rport,428,14,203,105, [GT_VISUALINFO,visual,GTBB_RECESSED,1,NIL]) Gt_RefreshWindow(win,NIL) /**** Calls the routine that reads in the data from the ***** ***** file 'eldb.dat (See the actual PROC for more info... *****/ readdata() doGraph() doBars() doTop6() ENDPROC PROC addToList() DEF newNode=NIL:PTR TO ln, node:PTR TO ln, len, itemPosition=0 IF (len:=StrLen(buffer))=0 THEN RETURN newNode:=New(SIZEOF ln) newNode.name:=String(len) StrCopy(newNode.name, buffer, ALL) Gt_SetGadgetAttrsA (listView, win, NIL, [GTLV_LABELS, -1, TAG_DONE]) node:=list.head AddTail(list, newNode) Gt_SetGadgetAttrsA (listView, win, NIL, [GTLV_LABELS, list, GTLV_TOP, itemPosition, TAG_DONE]) ENDPROC /**** Closes the main window and frees gadgets on exit of program **** ***** either because of a normal exit or an error occurred ****/ PROC closeMywindow() IF win THEN CloseWindow(win) IF glist THEN FreeGadgets(glist) ENDPROC /**** Routine that displays any errors that occur ****/ PROC reporterr(er) DEF erlist:PTR TO LONG IF er erlist:=['get context','create gadget','lock wb','get visual infos', 'open "gadtools.library" v37+','open window'] EasyRequestArgs(0,[20,0,0,'Could not \s!','ok'],0,[erlist[er-1]]) ENDIF ENDPROC /**** Main part that calls the other routines when needed ***** ***** and checks for buttons pressed and for errors ****/ PROC main() DEF class,code,iaddress,mes:PTR TO intuimessage, clicked:PTR TO gadget,gadgetid DEF listItemPosition=-1 IF reporterr(setupscreen())=0 reporterr(openMywindow()) LOOP class:=FALSE REPEAT IF mes:=Gt_GetIMsg(win.userport) class:=mes.class code:=mes.code iaddress:=mes.iaddress Gt_ReplyIMsg(mes) IF class=IDCMP_REFRESHWINDOW Gt_BeginRefresh(win) Gt_EndRefresh(win,TRUE) class:=FALSE ELSEIF ((class<>IDCMP_CLOSEWINDOW) AND (class<>IDCMP_GADGETUP) AND (class<>IDCMP_VANILLAKEY)) class:=FALSE ENDIF ELSEIF WaitPort(win.userport) ENDIF UNTIL class SELECT class CASE IDCMP_CLOSEWINDOW BRA x CASE IDCMP_VANILLAKEY SELECT code CASE "g" SELECT method CASE RAND randmethod() CASE HOT hotmethod() CASE COLD coldmethod() CASE LOW lowmethod() CASE HIGH highmethod() CASE LUCKY luckymethod() ENDSELECT CASE "a" about() CASE "q" BRA x ENDSELECT CASE IDCMP_GADGETUP clicked:=iaddress gadgetid:=clicked.gadgetid SELECT gadgetid CASE METHOD_CYCLE methodproc() CASE GO_BUTTON SELECT method CASE RAND randmethod() CASE HOT hotmethod() CASE COLD coldmethod() CASE LOW lowmethod() CASE HIGH highmethod() CASE LUCKY luckymethod() ENDSELECT CASE LINES_CYCLE lines() CASE ABOUT_BUTTON about() CASE LUCKY_INTEGER lucky:=stringGadgetValue CASE RESULTS_LIST listItemPosition:=clicked.gadgetid CASE QUIT_BUTTON BRA x ENDSELECT ENDSELECT ENDLOOP ENDIF x:closedownscreen() closeMywindow() CleanUp(0) ENDPROC /**** Routine that reads in the data from 'eldb.dat', calculates **** ***** how many times each number has come out, how many weeks of **** ***** data there is and then outputs the information into the **** ***** bevel boxes ****/ PROC readdata() DEF number,count,weeks=0,count2,gashnum[2]:STRING stdrast:=win.rport FOR count:=0 TO 48 total[count]:=0 ENDFOR IF file:=Open('eldb.dat',OLDFILE) WHILE Fgets(file,buffer,ALL)<>NIL StrCopy(buffer,buffer,ALL) addToList() INC weeks a:=0 WHILE a<19 MidStr(gashnum,buffer,a,2) number:=Val(gashnum) total[number-1]:=total[number-1]+1 a:=a+3 ENDWHILE ENDWHILE ELSE WriteF('Could not open data file...\n') BRA x ENDIF Close(file) Colour(2,0) count2:=0 FOR count:=0 TO 230 STEP 24 TextF(21+count,44,'\z\d[2] ',total[count2]) INC count2 ENDFOR FOR count:=0 TO 230 STEP 24 TextF(21+count,64,'\z\d[2] ',total[count2]) INC count2 ENDFOR FOR count:=0 TO 230 STEP 24 TextF(21+count,84,'\z\d[2] ',total[count2]) INC count2 ENDFOR FOR count:=0 TO 230 STEP 24 TextF(21+count,104,'\z\d[2] ',total[count2]) INC count2 ENDFOR FOR count:=0 TO 210 STEP 24 TextF(21+count,124,'\z\d[2] ',total[count2]) INC count2 ENDFOR TextF(70,145,'\d Weeks Of Data',weeks) ENDPROC PROC methodproc() IF method=LUCKY THEN method:=GASH INC method ENDPROC PROC lines() IF perms=5 THEN perms:=0 INC perms ENDPROC /* Puts the pn[] array into ascending order...at last!!! */ PROC order() IF ordered=0 count:=6 i:=0 j:=1 WHILE i<5 j:=i+1 WHILE j<6 IF pn[i] > pn[j] temp:=pn[i] pn[i]:=pn[j] pn[j]:=temp ENDIF INC j ENDWHILE INC i ENDWHILE TextF(280,c,'\z\d[2] \z\d[2] \z\d[2] \z\d[2] \z\d[2] \z\d[2]',pn[0],pn[1],pn[2],pn[3],pn[4],pn[5]) ENDIF ordered:=1 RETURN ENDPROC /* This proc opens a window that tell's the user a little about the ** ** program, needs work to stop activity elsewhere whilst it is ** ** displayed!!! */ PROC about() DEF w IF w:=OpenW(170,70,290,75,$200,$1008,'ELDB v3.5 © 1995 Brian Mitter',NIL,2,NIL) Box(10,13,279,70,3) Colour(1,3) TextF(20,21,' E Lottery DataBase v3.5 ') Colour(2,3) TextF(20,31,' >>> Brian Mitter <<<') Colour(2,3) TextF(20,42,' 17-03-95 ') Colour(1,3) TextF(20,53,' Written in the E language') TextF(20,63,' Learn it! You\all like it!') WaitIMessage(w) CloseW(w) ENDIF ENDPROC /* Random method of picking numbers... */ PROC randmethod() stdrast:=win.rport TextF(280,84,' ') TextF(280,94,' ') TextF(280,104,' ') TextF(280,114,' ') TextF(280,124,' ') IF perms=1 THEN lastperm:=85 IF perms=2 THEN lastperm:=95 IF perms=3 THEN lastperm:=105 IF perms=4 THEN lastperm:=115 IF perms=5 THEN lastperm:=125 FOR c:=84 TO lastperm STEP 10 ordered:=0 FOR a:=0 TO 5 pn[a]:=0 ENDFOR FOR a:=0 TO 5 again: randnum:=Rnd(49)+1 IF randnum=pn[0] THEN JUMP again IF randnum=pn[1] THEN JUMP again IF randnum=pn[2] THEN JUMP again IF randnum=pn[3] THEN JUMP again IF randnum=pn[4] THEN JUMP again IF randnum=pn[5] THEN JUMP again pn[a]:=randnum ENDFOR order() ENDFOR ENDPROC /* Selects 20 hottest numbers then 6 from them... */ PROC hotmethod() DEF highest stdrast:=win.rport TextF(280,84,' ') TextF(280,94,' ') TextF(280,104,' ') TextF(280,114,' ') TextF(280,124,' ') IF perms=1 THEN lastperm:=85 IF perms=2 THEN lastperm:=95 IF perms=3 THEN lastperm:=105 IF perms=4 THEN lastperm:=115 IF perms=5 THEN lastperm:=125 FOR a:=0 TO 48 copytotals[a]:=total[a] ENDFOR FOR a:=0 TO 19 i:=0; highest:=copytotals[i] REPEAT IF copytotals[i] > copytotals[highest] highest:=i ENDIF INC i UNTIL i=49 highnums[a]:=highest copytotals[highest]:=0 ENDFOR FOR c:=84 TO lastperm STEP 10 ordered:=0 FOR a:=0 TO 5 pn[a]:=0 ENDFOR FOR a:=0 TO 5 again: randnum:=Rnd(19) IF highnums[randnum]=pn[0] THEN JUMP again IF highnums[randnum]=pn[1] THEN JUMP again IF highnums[randnum]=pn[2] THEN JUMP again IF highnums[randnum]=pn[3] THEN JUMP again IF highnums[randnum]=pn[4] THEN JUMP again IF highnums[randnum]=pn[5] THEN JUMP again pn[a]:=highnums[randnum] ENDFOR order() ENDFOR ENDPROC /* Selects 20 coldest numbers then 6 from them... */ PROC coldmethod() DEF lowest stdrast:=win.rport TextF(280,84,' ') TextF(280,94,' ') TextF(280,104,' ') TextF(280,114,' ') TextF(280,124,' ') IF perms=1 THEN lastperm:=85 IF perms=2 THEN lastperm:=95 IF perms=3 THEN lastperm:=105 IF perms=4 THEN lastperm:=115 IF perms=5 THEN lastperm:=125 FOR a:=0 TO 48 copytotals[a]:=total[a] ENDFOR FOR a:=0 TO 19 lownums[a]:=0 ENDFOR FOR a:=0 TO 19 i:=0; lowest:=copytotals[i] REPEAT IF copytotals[i] < copytotals[lowest] lowest:=i ENDIF INC i UNTIL i=49 lownums[a]:=lowest copytotals[lowest]:=999 ENDFOR FOR c:=84 TO lastperm STEP 10 ordered:=0 FOR a:=0 TO 5 pn[a]:=0 ENDFOR FOR a:=0 TO 5 again: randnum:=Rnd(19) IF lownums[randnum]=pn[0] THEN JUMP again IF lownums[randnum]=pn[1] THEN JUMP again IF lownums[randnum]=pn[2] THEN JUMP again IF lownums[randnum]=pn[3] THEN JUMP again IF lownums[randnum]=pn[4] THEN JUMP again IF lownums[randnum]=pn[5] THEN JUMP again pn[a]:=lownums[randnum] ENDFOR order() ENDFOR ENDPROC /* Picks numbers from 1 to 24 */ PROC lowmethod() stdrast:=win.rport TextF(280,84,' ') TextF(280,94,' ') TextF(280,104,' ') TextF(280,114,' ') TextF(280,124,' ') IF perms=1 THEN lastperm:=85 IF perms=2 THEN lastperm:=95 IF perms=3 THEN lastperm:=105 IF perms=4 THEN lastperm:=115 IF perms=5 THEN lastperm:=125 FOR c:=84 TO lastperm STEP 10 ordered:=0 FOR a:=0 TO 5 pn[a]:=0 ENDFOR FOR a:=0 TO 5 again: randnum:=Rnd(24)+1 IF randnum=pn[0] THEN JUMP again IF randnum=pn[1] THEN JUMP again IF randnum=pn[2] THEN JUMP again IF randnum=pn[3] THEN JUMP again IF randnum=pn[4] THEN JUMP again IF randnum=pn[5] THEN JUMP again pn[a]:=randnum ENDFOR order() ENDFOR ENDPROC /* Picks numbers from 25 to 49 */ PROC highmethod() stdrast:=win.rport TextF(280,84,' ') TextF(280,94,' ') TextF(280,104,' ') TextF(280,114,' ') TextF(280,124,' ') IF perms=1 THEN lastperm:=85 IF perms=2 THEN lastperm:=95 IF perms=3 THEN lastperm:=105 IF perms=4 THEN lastperm:=115 IF perms=5 THEN lastperm:=125 FOR c:=84 TO lastperm STEP 10 ordered:=0 FOR a:=0 TO 5 pn[a]:=0 ENDFOR FOR a:=0 TO 5 again: randnum:=Rnd(25)+25 IF randnum=pn[0] THEN JUMP again IF randnum=pn[1] THEN JUMP again IF randnum=pn[2] THEN JUMP again IF randnum=pn[3] THEN JUMP again IF randnum=pn[4] THEN JUMP again IF randnum=pn[5] THEN JUMP again pn[a]:=randnum ENDFOR order() ENDFOR ENDPROC /* Picks numbers from an inputted 'lucky' seed... */ PROC luckymethod() lucky:=Val(stringGadgetValue) IF lucky>5 AND lucky>100 REPEAT lucky:=lucky/2 UNTIL lucky<100 ENDIF IF lucky=1 OR lucky=0 THEN lucky:=Rnd(25) stdrast:=win.rport TextF(280,84,' ') TextF(280,94,' ') TextF(280,104,' ') TextF(280,114,' ') TextF(280,124,' ') IF perms=1 THEN lastperm:=85 IF perms=2 THEN lastperm:=95 IF perms=3 THEN lastperm:=105 IF perms=4 THEN lastperm:=115 IF perms=5 THEN lastperm:=125 FOR c:=84 TO lastperm STEP 10 ordered:=0 FOR a:=0 TO 5 pn[a]:=0 ENDFOR FOR a:=0 TO 5 again: FOR b:=0 TO lucky randnum:=Rnd(49)+1 ENDFOR IF randnum=pn[0] THEN JUMP again IF randnum=pn[1] THEN JUMP again IF randnum=pn[2] THEN JUMP again IF randnum=pn[3] THEN JUMP again IF randnum=pn[4] THEN JUMP again IF randnum=pn[5] THEN JUMP again pn[a]:=randnum ENDFOR order() ENDFOR ENDPROC PROC doGraph() Line(35,232,427,232) Line(35,232,35,182) FOR a:=182 TO 222 STEP 10 Line(32,a,35,a,1) Line(36,a,427,a,3) ENDFOR Colour(1,0) TextF(15,185,'25') TextF(15,195,'20') TextF(15,205,'15') TextF(15,215,'10') TextF(15,225,'05') TextF(38,240,'0000000001111111111222222222233333333334444444444') TextF(38,248,'1234567890123456789012345678901234567890123456789') count:=0 FOR a:=37 TO 427 STEP 8 Line(a+4,232,a+4,232-(total[count]*2),2) INC count ENDFOR Line(40,232,427,232) ENDPROC PROC doBars() DEF totalcount=0,percent DEF lowcount=0,highcount=0 DEF oddcount=0,evencount=0 DEF primecount, nonprime DEF primenums[16]:ARRAY /************************************************************************/ /***** LOW/HIGH BAR *****/ FOR a:=0 TO 48 IF a<=24 THEN lowcount:=lowcount+total[a] IF a>=25 THEN highcount:=highcount+total[a] totalcount:=totalcount+total[a] ENDFOR percent:=!totalcount/100 lowcount:=!lowcount/percent highcount:=!highcount/percent Box(487,190,487+lowcount,195,3) ; Box(487+lowcount,190,587,195,1) TextF(457,195,'\d%',lowcount) ; TextF(592,195,'\d%',highcount) TextF(472,205,' LOW HIGH') /*************************************************************************/ /***** ODD/EVEN BAR *****/ totalcount:=0 ; percent:=0 ; a:=0 REPEAT oddcount:=oddcount+total[a] totalcount:=totalcount+total[a] INC a IF a=49 THEN JUMP getout evencount:=evencount+total[a] totalcount:=totalcount+total[a] INC a getout: UNTIL a=49 percent:=!totalcount/100 oddcount:=!oddcount/percent evencount:=!evencount/percent Box(487,210,487+oddcount,215,3) ; Box(487+oddcount,210,587,215,1) TextF(457,215,'\d%',oddcount) ; TextF(592,215,'\d%',evencount) TextF(472,225,' ODD EVEN') /**********************************************************************/ /***** PRIME/NON-PRIME BAR *****/ primenums[0]:=2 primenums[1]:=3 primenums[2]:=5 primenums[3]:=7 primenums[4]:=11 primenums[5]:=13 primenums[6]:=17 primenums[7]:=19 primenums[8]:=23 primenums[9]:=29 primenums[10]:=31 primenums[11]:=37 primenums[12]:=41 primenums[13]:=43 primenums[14]:=47 primenums[15]:=49 totalcount:=0 primecount:=0 nonprime:=0 percent:=0 FOR a:=0 TO 15 primecount:=(primecount+total[primenums[a]-1]) ENDFOR FOR a:=0 TO 48 totalcount:=totalcount+total[a] ENDFOR nonprime:=totalcount-primecount percent:=!totalcount/100 primecount:=!primecount/percent nonprime:=!nonprime/percent Box(487,230,487+primecount,235,3) ; Box(487+primecount,230,587,235,1) TextF(457,235,'\d%',primecount) ; TextF(592,235,'\d%',nonprime) TextF(457,245,' PRIME NON-PRIME') /***********************************************************************/ ENDPROC PROC doTop6() DEF hottest,coldest /**********************************************/ /*********** HOTTEST BOX **********/ FOR a:=0 TO 48 copytotals[a]:=total[a] ENDFOR FOR a:=0 TO 5 i:=0; hottest:=copytotals[i] REPEAT IF copytotals[i] > copytotals[hottest] hottest:=i ENDIF INC i UNTIL i=48 pn[a]:=hottest+1 copytotals[hottest]:=0 ENDFOR statsorder() FOR a:=470 TO 590 STEP 20 Line(a,125,a,145,1) ENDFOR FOR a:=125 TO 145 STEP 10 Line(470,a,590,a,1) ENDFOR Colour(1,0) TextF(473,132,'\z\d[2]',pn[0]) TextF(493,132,'\z\d[2]',pn[1]) TextF(513,132,'\z\d[2]',pn[2]) TextF(533,132,'\z\d[2]',pn[3]) TextF(553,132,'\z\d[2]',pn[4]) TextF(573,132,'\z\d[2]',pn[5]) Colour(2,0) TextF(473,143,'\z\d[2]',total[pn[0]-1]) TextF(493,143,'\z\d[2]',total[pn[1]-1]) TextF(513,143,'\z\d[2]',total[pn[2]-1]) TextF(533,143,'\z\d[2]',total[pn[3]-1]) TextF(553,143,'\z\d[2]',total[pn[4]-1]) TextF(573,143,'\z\d[2]',total[pn[5]-1]) Colour(2,0) TextF(495,154,'6 HOTTEST') /********************************************************/ /*********** COLDEST BOX ************/ FOR a:=0 TO 48 copytotals[a]:=total[a] ENDFOR FOR a:=0 TO 5 i:=0; coldest:=copytotals[i] REPEAT IF copytotals[i] < copytotals[coldest] coldest:=i ENDIF INC i UNTIL i=49 pn[a]:=coldest+1 copytotals[coldest]:=999 ENDFOR statsorder() FOR a:=470 TO 590 STEP 20 Line(a,157,a,177,1) ENDFOR FOR a:=157 TO 177 STEP 10 Line(470,a,590,a,1) ENDFOR Colour(1,0) TextF(473,165,'\z\d[2]',pn[0]) TextF(493,165,'\z\d[2]',pn[1]) TextF(513,165,'\z\d[2]',pn[2]) TextF(533,165,'\z\d[2]',pn[3]) TextF(553,165,'\z\d[2]',pn[4]) TextF(573,165,'\z\d[2]',pn[5]) Colour(2,0) TextF(473,175,'\z\d[2]',total[pn[0]-1]) TextF(493,175,'\z\d[2]',total[pn[1]-1]) TextF(513,175,'\z\d[2]',total[pn[2]-1]) TextF(533,175,'\z\d[2]',total[pn[3]-1]) TextF(553,175,'\z\d[2]',total[pn[4]-1]) TextF(573,175,'\z\d[2]',total[pn[5]-1]) Colour(2,0) TextF(495,186,'6 COLDEST') ENDPROC PROC statsorder() count:=6 i:=0 j:=1 WHILE i<5 j:=i+1 WHILE j<6 IF pn[i] > pn[j] temp:=pn[i] pn[i]:=pn[j] pn[j]:=temp ENDIF INC j ENDWHILE INC i ENDWHILE ENDPROC