Jump to content
Sign in to follow this  
nyxx24

Write date & time to a logfile

Recommended Posts

nyxx24

Hello,

I understand and am able to get this code to work..

And I know @MDAY @MON @HOUR @MIN, are for the date & time

But where it says line 1 I want it to write the date and time and I don't know how to put the two together..

Any assistance please..

$file = FileOpen("restartlog.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then
    Exit
EndIf

FileWrite($file, "Line1")

FileClose($file)

Share this post


Link to post
Share on other sites
nyxx24

To concatenate use &

Sadly I had to google that word..

The code below simply produces a line of text that says: Restarted, @MDAY & @MON & @HOUR & @MIN

I want something like Restarted 01 Jan 17:05

$file = FileOpen("c:\restartlog.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then
    Exit
EndIf

FileWrite($file, "Restarted, @MDAY & @MON & @HOUR & @MIN")

FileClose($file)

Share this post


Link to post
Share on other sites
nyxx24

Excellent..

1 More question.. how do I make it write to the next line down each additional entry instead of:

Restarted, 01/01 17:14Restarted, 01/01 17:16Restarted, 01/01 17:16

Share this post


Link to post
Share on other sites
nyxx24

;) Well I did use the helpfile to find fielwrite.. just shoulda read the next line..

This works.. thanks Guys! :evil:

$file = FileOpen("c:\restartlog.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then
    Exit
EndIf

FileWriteLine($file, "Restarted, " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & @CRLF)

FileClose($file)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.