KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Lotto Analyzer

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Jun 16, 2006 5:49 am    Post subject: Lotto Analyzer Reply with quote

Just having some fun....
Comments, golfing, or any other remarks are most welcome....

Lonk, thanks for the help on the Control array's for this, makes it look so much cleaner.

Oh and Yes I know that there is still some uncaptured outputs to the console, but wanted opinions.
Code:

Break On
$nul = Setoption(NoVarsinStrings, ON)
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf
$nul = $System.Application.EnableVisualStyles

$Form1 = $System.Form()
$Form1.Left = 0
$Form1.StartPosition = 0  ;FormStartPosition_Manual
$Form1.Size = $System.Size(1000,899) ;(Width,Height)
$Form1.Text = "Powerball Analysis"
$Form1.Top = 0

$lbl_RF = $System.Label()
$lbl_RF.Left = 15
$lbl_RF.Text = "Reading file: "
$lbl_RF.Top = 15
$lbl_RF.Width = 900
$lbl_RF.Visible = 0
$nul = $Form1.Controls.Add($lbl_RF)

$lbl_DR = $System.Label
$lbl_DR.left = 15
$lbl_DR.Top = 40
$lbl_DR.Width = 900
$nul = $Form1.Controls.Add($lbl_DR)


$BTN_Exit = $System.Button()
$BTN_Exit.FlatStyle = 1  ;Popup
$BTN_Exit.Left = 540
$BTN_Exit.Text = "Exit"
$BTN_Exit.Top = 815
$BTN_Exit.Click = "Over()"
$nul = $Form1.Controls.Add($BTN_Exit)

$BTN_Open = $System.Button()
$BTN_Open.FlatStyle = 1  ;Popup
$BTN_Open.Left = 20
$BTN_Open.Text = "Open File"
$BTN_Open.Top = 820
$BTN_OPen.Click = "DoOpen()"
$nul = $Form1.Controls.Add($BTN_Open)

Global $LBL_Num[55], $LBL_Text1[55], $LBL_Text2[55], $LBL_Perc[55],
     $LBL_PNum[42], $LBL_PText1[42], $LBL_PText2[42], $LBL_PPerc[42]
$top = 65
$left = 15
for $ = 1 to 55

  $LBL_Num[$]=$Form1.Controls.Add($System.Label)
  $LBL_Num[$].BorderStyle = 1 ;FixedSingle
  $LBL_Num[$].Left = $Left
  $LBL_Num[$].Text = $
  $LBL_Num[$].Top = $top
  $LBL_Num[$].Width = 20

  $LBL_Text1[$] = $Form1.Controls.Add($System.Label)
  $LBL_Text1[$].Left = $left+20
  $LBL_Text1[$].Text = 'Has been selected'
  $LBL_Text1[$].Top = $Top
   
  $LBL_Perc[$] = $Form1.Controls.Add($System.Label)
  $LBL_Perc[$].Left = $left+125
  $LBL_Perc[$].Top = $Top
  $LBL_Perc[$].Width = 25 
   
  $LBL_Text2[$] = $Form1.Controls.Add($System.Label)
  $LBL_Text2[$].Left = $Left+160
  $LBL_Text2[$].Text = '% of the time'
  $LBL_Text2[$].Top =  $Top
  $LBL_Text2[$].Width = 70

  $Top = $Top + 25
  If $ = 28
   $Top = 65
   $Left = 250
  EndIf
Next

$Top = 65
$Left = $Left + 250
For $ = 1 to 42

  $LBL_PNum[$]=$Form1.Controls.Add($System.Label)
  $LBL_PNum[$].BorderStyle = 1 ;FixedSingle
  $LBL_PNum[$].Left = $Left
  $LBL_PNum[$].Text = $
  $LBL_PNum[$].Top = $top
  $LBL_PNum[$].Width = 20
  $LBL_PNum[$].Backcolor = $System.Color.FromName("Red")

  $LBL_PText1[$] = $Form1.Controls.Add($System.Label)
  $LBL_PText1[$].Left = $left+20
  $LBL_PText1[$].Text = 'Has been selected'
  $LBL_PText1[$].Top = $Top
   
  $LBL_PPerc[$] = $Form1.Controls.Add($System.Label)
  $LBL_PPerc[$].Left = $left+125
  $LBL_PPerc[$].Top = $Top
  $LBL_PPerc[$].Width = 20 
   
  $LBL_PText2[$] = $Form1.Controls.Add($System.Label)
  $LBL_PText2[$].Left = $Left+155
  $LBL_PText2[$].Text = '%of the time'
  $LBL_PText2[$].Top =  $Top
  $LBL_PText2[$].Width = 70


   $Top = $Top + 25
If $ = 28
   $Top = 65
   $Left = $left + 250
EndIf

Next

$Form1.Show  ;Displays the Form

While $Form1.Visible
   $Nul = Execute($Form1.DoEvents())
Loop
Exit 0


Function DoOpen()

Dim $NumArray[55],$PnumArray[42],$Array[],$Count

$Count = 1

$OF = $system.OpenFileDialog()
$OF.DefaultExt = "txt"
$OF.Filter = "Saved Prefs(*.txt)|*.txt"
$OF.InitialDirectory = @scriptdir
$OF.Title = "Save Preferences"
$OF.AddExtension = "True"
$OF.RestoreDirectory = "True"
$OF.Showdialog


$LBL_RF.Visible = -1
$LBL_RF.Text = $LBL_RF.Text + $OF.Filename
$FH = FreeFileHandle()

If Open($FH,$OF.Filename,2) = 0
   $ = Readline($FH)
   $ = ReadLine($FH)

   While @error = 0
      $Array = Split($,"  ")

       For $Val = 1 to 5
         $In = $Array[$val]
         $NumArray[$IN] = $NumArray[$IN] + 1
      Next
      $IN = $Array[6]
      $PNumArray[$IN] = $PNumArray[$IN] + 1

      $Count = $Count + 1
      $ = Readline($FH)
   Loop
Else

?@error + @serror

EndIf

Close ($FH)

$lbl_DR.Text = "Total # of draws = " +$Count

For $ = 1 to 55
   $Num = ($NumArray[$]*100)/$count
   $LBL_Perc[$].text = $Num
Next

For $ = 1 to 42
   $Num = ($PNumArray[$]*100)/$count
   $LBL_PPerc[$].text = $Num
Next

EndFunction

Function Over()
  Quit(1)
EndFunction



powerball2.kix
 Description:
The code so you don't have to copy and paste

Download
 Filename:  powerball2.kix
 Filesize:  4.19 KB
 Downloaded:  680 Time(s)


num.txt
 Description:
The seed file, that is needed to make it all work.

Download
 Filename:  num.txt
 Filesize:  35.16 KB
 Downloaded:  999 Time(s)


_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Jun 19, 2006 10:30 pm    Post subject: Reply with quote

Okay here is the most recent update.

I have one more ? on how to accomplish 1 more item on it.

If you examine the seed file from the prior post you will see that the 51-55 were added to the equation not that long ago. How would I weight it properly to show correct percentage and least picked.

Another point would be that twice a week the numbers change. So whatever the solution is, has to be dynamic.

Code:
Break On
$nul = Setoption(NoVarsinStrings, ON)
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf
$nul = $System.Application.EnableVisualStyles

$Form1 = $System.Form()
$Form1.Left = 0
$Form1.StartPosition = 0  ;FormStartPosition_Manual
$Form1.Size = $System.Size(1000,950) ;(Width,Height)
$Form1.Text = "Powerball Analysis"
$Form1.Top = 0

$lbl_RF = $System.Label()
$lbl_RF.Left = 15
$lbl_RF.Text = "Reading file: "
$lbl_RF.Top = 15
$lbl_RF.Width = 900
$lbl_RF.Visible = 0
$nul = $Form1.Controls.Add($lbl_RF)

$lbl_DR = $System.Label
$lbl_DR.left = 15
$lbl_DR.Top = 40
$lbl_DR.Width = 900
$nul = $Form1.Controls.Add($lbl_DR)


$BTN_Exit = $System.Button()
$BTN_Exit.FlatStyle = 1  ;Popup
$BTN_Exit.Left = 850
$BTN_Exit.Text = "Exit"
$BTN_Exit.Top = 850
$BTN_Exit.Click = "Over()"
$nul = $Form1.Controls.Add($BTN_Exit)

$BTN_Open = $System.Button()
$BTN_Open.FlatStyle = 1  ;Popup
$BTN_Open.Left = 750
$BTN_Open.Text = "Open File"
$BTN_Open.Top = 850
$BTN_OPen.Click = "DoOpen()"
$nul = $Form1.Controls.Add($BTN_Open)

Global $LBL_Num[55], $LBL_Text1[55], $LBL_Text2[55], $LBL_Perc[55],
     $LBL_PNum[42], $LBL_PText1[42], $LBL_PText2[42], $LBL_PPerc[42]
$top = 65
$left = 15
for $ = 1 to 55

  $LBL_Num[$]=$Form1.Controls.Add($System.Label)
  $LBL_Num[$].BorderStyle = 1 ;FixedSingle
  $LBL_Num[$].Left = $Left
  $LBL_Num[$].Text = $
  $LBL_Num[$].Top = $top
  $LBL_Num[$].Width = 20
  $LBL_Num[$].Backcolor = $System.Color.FromName("White")

  $LBL_Text1[$] = $Form1.Controls.Add($System.Label)
  $LBL_Text1[$].Height = 30
  $LBL_Text1[$].Left = $left+20
  $LBL_Text1[$].Text = 'Has been selected  It has been drawn'
  $LBL_Text1[$].Top = $Top
   
  $LBL_Perc[$] = $Form1.Controls.Add($System.Label)
  $LBL_Perc[$].Height = 30
  $LBL_Perc[$].Left = $left+125
  $LBL_Perc[$].Top = $Top
  $LBL_Perc[$].Width = 25 
   
  $LBL_Text2[$] = $Form1.Controls.Add($System.Label)
  $LBL_Text2[$].Height = 30
  $LBL_Text2[$].Left = $Left+160
  $LBL_Text2[$].Text = '% of the time     total times'
  $LBL_Text2[$].Top =  $Top
  $LBL_Text2[$].Width = 70

  $Top = $Top + 30
  If $ = 28
   $Top = 65
   $Left = 250
  EndIf
Next

$Top = 65
$Left = $Left + 250
For $ = 1 to 42

  $LBL_PNum[$]=$Form1.Controls.Add($System.Label)
  $LBL_PNum[$].BorderStyle = 1 ;FixedSingle
  $LBL_PNum[$].Left = $Left
  $LBL_PNum[$].Text = $
  $LBL_PNum[$].Top = $top
  $LBL_PNum[$].Width = 20
  $LBL_PNum[$].Backcolor = $System.Color.FromName("Red")

  $LBL_PText1[$] = $Form1.Controls.Add($System.Label)
  $LBL_PText1[$].Height = 30
  $LBL_PText1[$].Left = $left+20
  $LBL_PText1[$].Text = 'Has been selected  It has been drawn'
  $LBL_PText1[$].Top = $Top
   
  $LBL_PPerc[$] = $Form1.Controls.Add($System.Label)
  $LBL_PPerc[$].Height = 30
  $LBL_PPerc[$].Left = $left+125
  $LBL_PPerc[$].Top = $Top
  $LBL_PPerc[$].Width = 25 
   
  $LBL_PText2[$] = $Form1.Controls.Add($System.Label)
  $LBL_PText2[$].Height = 30
  $LBL_PText2[$].Left = $Left+155
  $LBL_PText2[$].Text = '% of the time     total times'
  $LBL_PText2[$].Top =  $Top
  $LBL_PText2[$].Width = 70


   $Top = $Top + 30
If $ = 28
   $Top = 65
   $Left = $left + 250
EndIf

Next

$LBL_Least = $Form1.Controls.Add($System.Label)
$LBL_Least.Left = 750
$LBL_Least.Top = 500
$LBL_Least.Width = 250
$LBL_Least.Height = 30
$LBL_Least.Text = "The numbers that have been picked the least are:"

$Form1.Show  ;Displays the Form

While $Form1.Visible
   $Nul = Execute($Form1.DoEvents())
Loop
Exit 0


Function DoOpen()

Dim $NumArray[55],$PnumArray[42],$Array[],$Count, $LBL_LNum[5]

$Count = 1

$OF = $system.OpenFileDialog()
$OF.DefaultExt = "txt"
$OF.Filter = "Saved Prefs(*.txt)|*.txt"
$OF.InitialDirectory = @scriptdir
$OF.Title = "Save Preferences"
$OF.AddExtension = "True"
$OF.RestoreDirectory = "True"
$OF.Showdialog


$LBL_RF.Visible = -1
$LBL_RF.Text = $LBL_RF.Text + $OF.Filename
$FH = FreeFileHandle()

If Open($FH,$OF.Filename,2) = 0
   $ = Readline($FH)
   $ = ReadLine($FH)

   While @error = 0
      $Array = Split($,"  ")

       For $Val = 1 to 5
         $In = $Array[$val]
         $NumArray[$IN] = $NumArray[$IN] + 1
      Next
      $IN = $Array[6]
      $PNumArray[$IN] = $PNumArray[$IN] + 1

      If $Count = 1
      $Date = $Array[0]
      EndIf

      $Count = $Count + 1
      $ = Readline($FH)
   Loop
Else

?@error + @serror

EndIf

Close ($FH)

$lbl_DR.Text = "Total # of draws = " +$Count+ "            With a Last Draw Date of:"+$Date

For $ = 1 to 55
   $Num = ($NumArray[$]*100)/$count
   $LBL_Perc[$].text = Cstr($Num) + "    "+Cstr($NumArray[$])
Next

For $ = 1 to 42
   $Num = ($PNumArray[$]*100)/$count
   $LBL_PPerc[$].text = Cstr($Num) + "    "+Cstr($PNumArray[$])
Next

indexes_of_smallest_values(5,$NumArray)

$Left = 750

For $ = 1 to Ubound($output)

  $LBL_LNum[$]=$Form1.Controls.Add($System.Label)
  $LBL_LNum[$].BorderStyle = 1 ;FixedSingle
  $LBL_LNum[$].Left = $Left
  $LBL_LNum[$].Text = $output[$]
  $LBL_LNum[$].Top = 530
  $LBL_LNum[$].Width = 20
  $LBL_LNum[$].Backcolor = $System.Color.FromName("White")
  $Left = $Left + 40
Next

indexes_of_smallest_values(1,$PNumArray)

  $LBL_LNum[0]=$Form1.Controls.Add($System.Label)
  $LBL_LNum[0].BorderStyle = 1 ;FixedSingle
  $LBL_LNum[0].Left = $Left
  $LBL_LNum[0].Text = $output[1]
  $LBL_LNum[0].Top = 530
  $LBL_LNum[0].Width = 20
  $LBL_LNum[0].Backcolor = $System.Color.FromName("Red")

EndFunction

Function Over()
  Quit(1)
EndFunction


function indexes_of_smallest_values($howMany,$InputArray)
dim $helper[0],$sc
global $output[$howmany]
 for $=0 to ubound($InputArray)
  $val = $InputArray[$]
  if $val>ubound($helper)
   redim preserve $helper[$val]
  endif
  $helper[$val] = $helper[$val] + " " + $
 next
 for $=0 to ubound($helper)
  for each $index in split($helper[$])
   if len($index)
    $output[$sc] = $index
    $sc = $sc + 1
   endif
   if $sc>$howMany
    exit 0
   endif
  next
 next
endfunction




powerball2.kix
 Description:
The recent update

Download
 Filename:  powerball2.kix
 Filesize:  6.06 KB
 Downloaded:  660 Time(s)


_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group