Sign in to follow this  
Followers 0
SjaakTV

Every second a new .txt

2 posts in this topic

Hi,

So yesterday with some help i made this.

$fname = "processes.txt"
$file = FileOpen($fname, 9)

$list = ProcessList()

for $i = 1 to $list[0][0]
    FileWriteLine($file, "Process Name: " & $list[$i][0] & " PID: " & $list[$i][1] & @CRLF)
next

FileClose($file)

So what i want to make is that it logs every second the procces.

I know i can wend it and sleep 1000 it but is there a way to let the $fname = "processes.txt change every time. So it becomes processes.txt then processes1.txt then processes2.txt and so on.

I have no clue how to do that.

Thnx for your time.

Share this post


Link to post
Share on other sites



This would be one way to do it.

I'm using AdlibRegister as Sleep(1000) would add to the time is takes the function to run. I don't know how precise you want it to be. Another way to do it would to check the @SEC macro and run the function when it's value changes.

AdlibRegister( "_WriteFile" ,1000)
Global $Seconds = 0

While 1
    Sleep(100)
WEnd

Func _WriteFile()
    Local $fname = "processes" & $Seconds & ".txt"
    Local $file = FileOpen($fname, 9)
    Local $list = ProcessList()
    for $i = 1 to $list[0][0]
        FileWriteLine($file, "Process Name: " & $list[$i][0] & " PID: " & $list[$i][1] & @CRLF)
    next
    FileClose($file)
    $Seconds += 1
EndFunc

Share this post


Link to post
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
Sign in to follow this  
Followers 0