Jump to content

Make array value unique


Recommended Posts

The above post will work fine, but here's a more optimized version :)

dim $array[69]=[3,4,5,2,3,5]
dim $array2[1]
For $i=0 To UBound($array)-1
    For $j=0 To Ubound($array2)-1
        If $array[$i]=$array2[$j] Then ContinueLoop 2
    Next
    ReDim $array2[Ubound($array2)+1]
    $array2[Ubound($array2)-1]=$array[$i]
Next

:)

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Hello again :)

I'm not quite sure how to use this i'm afraid. Well I know a littlebit how to use it but i dont get the array2 error i'm getting

C:\Program Files\AutoIt3\Projects\gofish\gofish2.au3 (39) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: 
If $players[$i]=$array2[$j] Then ContinueLoop 2 
If $players[$i]=^ ERROR

Since you know my previous script (it has all the players in an array) but i want them unique now, so I can create a listbox with it.

#include <File.Au3>
#include <array.au3>
AutoItSetOption("trayicondebug",1)
Dim $players[1]=[0]
$files=_FileListToArray("C:\Program Files\PokerStars\HandHistory\Exclusive\","*",1)

Dim $latest, $latestdate=-1
For $i=1 To UBound($files)-1
    $temp=FileGetTime("C:\Program Files\PokerStars\HandHistory\Exclusive\" & $files[$i],1,1)
    
;Msgbox(1,"info",$temp & " - : - " & $files[$i])
    If $latestdate=-1 Or $temp>$latestdate Then
        $latest=$files[$i]
        $latestdate=$temp
;       MsgBox(1,"info","Latest = " & $latest & " latestdate = " & $temp & " - : - " & $latestdate )
    EndIf
Next
MsgBox(1,"File is",$latest )
$handle=FileOpen("C:\Program Files\PokerStars\HandHistory\Exclusive\" & $latest,0)
If @error Then MsgBox(1,"Error","")

Do
    $temp=FileReadline($handle)
    ;Msgbox(1,"Error",@error)
    If @error = -1 Then ExitLoop
    If StringLeft($temp,4)="seat" Then
        ReDim $players[Ubound($players)+1]
        ;MsgBox("1","info",$players)
        $data=StringMid($temp,StringInStr($temp,":")+2,StringInstr(StringTrimLeft($temp,6),")"))
        $players[UBound($players)-1]=StringLeft($data,StringInStr($data," ")-1)
    EndIf
Until False
;_ArrayReverse($players)

;dim $array[69]=[3,4,5,2,3,5]
dim $array2[1]
For $i=0 To UBound($players)-1
    For $j=0 To Ubound($players)-1
        If $players[$i]=$array2[$j] Then ContinueLoop 2
    Next
    ReDim $array2[Ubound($array2)+1]
    $array2[Ubound($array2)-1]=$players[$i]

Next

_ArrayDisplay($array2)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...