Sign in to follow this  
Followers 0
nyxx24

Write date & time to a logfile

9 posts in this topic

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



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

#4 ·  Posted (edited)

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

Edited by snowmaker

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

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

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

How about _Now()?

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