Jump to content

can someone help me out with my loop?


Recommended Posts

The code below reads from files based on the window name which is where it gets most of its filename. It then counts the file names lines to the end to start reading from the end and downward. It then takes all the new lines added in the file its reading from and writes them to a temp file. My problem is when it goes to read that temp file somehow old data is not getting deleted. This is I think my problem. Because it's throwing up msgbox()'s that shouldn't appear since that's old data. Can someone help me with the loop and maybe I've ordered things wrong?

I would be SO grateful if someone would help me >_<

Func Test()
    $string = "FILE" & StringReplace(StringTrimRight(_NowCalc(),8), "/","")

    $ftpname = IniRead(@ScriptDir & "\data\Config.dat", "Directory", "Log", "")
    $array = StringSplit($ftpname, "\") 
    $i = $array[0]  
    $ftpname = $array[$i]

    If $ftpname = "" Then
        MsgBox(0, "", "Please configure your log location.")
    EndIf

    $hhf_dir = IniRead(@ScriptDir & "\data\Config.dat", "Directory", "Log", "")

    $list = WinList("[CLASS:QWidget]")
    For $n = 1 To $list[0][0]   
        If $list[$n][0] <> "" AND IsVisible($list[$n][1]) Then  
            If $list[$n][0] = "Example " & $ftpname Then    ; avoid this window (skip)
            Else

                $path = $hhf_dir & "\" & $string & "" & StringTrimRight(StringReplace($list[$n][0], "/", "-"), StringLen($ftpname) + 16) & ".txt"   

                
                $hh = FileOpen($hhf_dir & "\" & $string & "" & StringTrimRight(StringReplace($list[$n][0], "/", "-"), StringLen($ftpname) + 16) & ".txt", 0)
                If $hh = -1  Then
                    MsgBox(0, "Unable to open file", "")
                EndIf

                
                FileClose($hh)

                For $t = $count To _FileCountLines($path)   ; from the first count to new last line in file 
                    $line = FileReadLine($path, $t)     ; read each new line
                    FileWrite(@ScriptDir & "\data\" & StringReplace($list[$n][0], "/", "-") & ".txt", $line & @CRLF)    ; writes the new line being read to a \data\temp.txt file
                Next
                $readtemp = FileRead(@ScriptDir & "\data\" & StringReplace($list[$n][0], "/", "-") & ".txt")    ; read data from temp file

                ; read .dat
                $aSection = IniReadSection(@ScriptDir & "\data\test.dat", "Section")

                If IsArray($aSection) Then
                    For $y = 1 To $aSection[0][0] ; for every key/value found in .dat
                        If StringInStr($readtemp, $aSection[$y][0]) Then
                            MsgBox(0,"", $aSection[$y][1] & " for " & $aSection[$y][0])
                        EndIf
                    Next
                EndIf
            EndIf
        EndIf
        $count = _FileCountLines($path) ; update count so it continues to read from EOF
        FileDelete(@ScriptDir & "\data\" & StringReplace($list[$n][0], "/", "-") & ".txt")  ; clear all temp data
    Next
EndFunc
Link to comment
Share on other sites

So... I read your description and code several times and... I've concluded that I'm going to need some example data files that you're working with.

Based on what you're saying and what you've provided I just can't quite understand the rhyme or reason to what you're doing without seeing what you're reading in and what you're outputting.

Are you working with just one file, or multiple files every time this runs? And as I gather, you're trying to read in only new lines that appear at the end of those files and write them out again?

Link to comment
Share on other sites

exodious,

Depending on how many windows are open it will write and then read that many temp files using the window name. What I am trying to do is as I am reading in only new lines that it will write only new data to the temp file thus displaying only new data.

Soo...

And as I gather, you're trying to read in only new lines that appear at the end of those files and write them out again?

The answer to the above is yes.

Here's an example data file I'm reading from: This is the basic syntax of the file. And just as a reminder this text file is constantly updated.

Full Tilt Poker Game #13741008309: Table Play Chip 1045 - 5/10 - 300 Cap No Limit Hold'em - 1:36:07 ET - 2009/08/01
Seat 4: Ahihi (6,504), is sitting out
Seat 5: KATY BABY (2,695)
Seat 6: READ_WHO (3,295)
Seat 7: texasplayer14 (600)
READ_WHO posts the small blind of 5
texasplayer14 posts the big blind of 10
The button is in seat #5
*** HOLE CARDS ***
Dealt to texasplayer14 [4s 8d]
KATY BABY calls 10
READ_WHO raises to 300, and is capped
texasplayer14 has 15 seconds left to act
texasplayer14 has timed out
texasplayer14 folds
texasplayer14 is sitting out
KATY BABY folds
Uncalled bet of 290 returned to READ_WHO
READ_WHO mucks
READ_WHO wins the pot (30)
*** SUMMARY ***
Total pot 30 | Rake 0
Seat 4: Ahihi is sitting out
Seat 5: KATY BABY (button) folded before the Flop
Seat 6: READ_WHO (small blind) collected (30), mucked
Seat 7: texasplayer14 (big blind) folded before the Flop



Full Tilt Poker Game #13741025320: Table Play Chip 1045 - 5/10 - 300 Cap No Limit Hold'em - 1:37:18 ET - 2009/08/01
Seat 5: KATY BABY (2,655)
Seat 6: READ_WHO (3,345)
Seat 7: texasplayer14 (590)
READ_WHO posts the small blind of 5
texasplayer14 posts the big blind of 10
The button is in seat #5
*** HOLE CARDS ***
Dealt to texasplayer14 [7s 5d]
KATY BABY calls 10
READ_WHO calls 5
texasplayer14 checks
*** FLOP *** [4d 2d 9c]
READ_WHO checks
texasplayer14 checks
KATY BABY bets 10
READ_WHO calls 10
texasplayer14 has 15 seconds left to act
texasplayer14 folds
*** TURN *** [4d 2d 9c] [Jh]
READ_WHO bets 280, and is capped
KATY BABY has 15 seconds left to act
KATY BABY folds
Uncalled bet of 280 returned to READ_WHO
READ_WHO mucks
READ_WHO wins the pot (50)
*** SUMMARY ***
Total pot 50 | Rake 0
Board: [4d 2d 9c Jh]
Seat 5: KATY BABY (button) folded on the Turn
Seat 6: READ_WHO (small blind) collected (50), mucked
Seat 7: texasplayer14 (big blind) folded on the Flop



Full Tilt Poker Game #13741041821: Table Play Chip 1045 - 5/10 - 300 Cap No Limit Hold'em - 1:38:28 ET - 2009/08/01
Seat 5: KATY BABY (2,635)
Seat 6: READ_WHO (3,375)
Seat 7: texasplayer14 (580)
texasplayer14 posts the small blind of 5
KATY BABY posts the big blind of 10
The button is in seat #6
*** HOLE CARDS ***
Dealt to texasplayer14 [Ks 6s]
READ_WHO calls 10
texasplayer14 folds
KATY BABY checks
*** FLOP *** [3d Jd 9s]
KATY BABY checks
READ_WHO bets 25
KATY BABY calls 25
*** TURN *** [3d Jd 9s] [4s]
KATY BABY checks
READ_WHO bets 10
KATY BABY calls 10
*** RIVER *** [3d Jd 9s 4s] [9c]
KATY BABY checks
READ_WHO checks
*** SHOW DOWN ***
READ_WHO shows [Qs 8d] a pair of Nines
KATY BABY mucks
READ_WHO wins the pot (95) with a pair of Nines
*** SUMMARY ***
Total pot 95 | Rake 0
Board: [3d Jd 9s 4s 9c]
Seat 5: KATY BABY (big blind) mucked [Qd 7d] - a pair of Nines
Seat 6: READ_WHO (button) showed [Qs 8d] and won (95) with a pair of Nines
Seat 7: texasplayer14 (small blind) folded before the Flop
Edited by Hypertrophy
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...