Jump to content

Write date & time to a logfile


 Share

Recommended Posts

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)
Link to comment
Share on other sites

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)
Link to comment
Share on other sites

;) 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)
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...