Jump to content

Newbie here, New Line?


Recommended Posts

What is the script I use to make a new line?

FileWrite($file, "["& @Year&"."&@mon&"."&@mday&" "&@HOUR & ":" &@MIN & ":" &@SEC & '] Window: "'& $window& '"'& $what2log & )

I need to make a new line so every time the date/time is desplayed, it is on a new line.

Link to comment
Share on other sites

  • Moderators

What is the script I use to make a new line?

FileWrite($file, "["& @Year&"."&@mon&"."&@mday&" "&@HOUR & ":" &@MIN & ":" &@SEC & '] Window: "'& $window& '"'& $what2log & )

I need to make a new line so every time the date/time is desplayed, it is on a new line.

@LF

@CR

@CRLF

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

@CR/@LF/@CRLF

[edit] i hate you ron [/edit]

:D:D:):D:wacko:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Argg. I thought I had it, but something is wrong

FileWrite(@CRLF & $file, "["& @Year&"."&@mon&"."&@mday&" "&@HOUR & ":" &@MIN & ":" &@SEC & '] Window: "'& $window& "'"

& $what2log)

I want the results to come up like:

[May 21, 2006 @ 4:40]

[Window - Google.com - Microsoft Internet Explorer]

BLAH BLAH BALHY (you know, the what2log var)

[May 21, 2006 @ 4:40]

[Window - Google.com - Microsoft Internet Explorer]

BLAH BLAH BALHY (you know, the what2log var)

[May 22, 2006 @ 4:40]

[Window - Google.com - Microsoft Internet Explorer]

BLAH BLAH BALHY (you know, the what2log var)

[May 23, 2006 @ 4:40]

[Window - Google.com - Microsoft Internet Explorer]

BLAH BLAH BALHY (you know, the what2log var)

Can someone help me format this?

Link to comment
Share on other sites

What is the script I use to make a new line?

FileWrite($file, "["& @Year&"."&@mon&"."&@mday&" "&@HOUR & ":" &@MIN & ":" &@SEC & '] Window: "'& $window& '"'& $what2log & )

I need to make a new line so every time the date/time is desplayed, it is on a new line.

As you've already heard, you can add "& @CRLF" to your string, but you can also use FileWriteLine(). Which does that for you. From your formatting, it looks like a log file entry, for which you can use _FileWriteLog(), adding the timestamp automaticaly:

#include <file.au3>

$LogFile = "C:\Logs\MyLog.log"
_FileWriteLog($LogFile, "This is the first log entry.")
_FileWriteLog($LogFile, "This is the second line in the log..." & @CRLF & _
     @Tab & "...and this is the third line!.")
$LogMsg = "This is the fourth line of the log."
_FileWriteLog($LogFile, $LogMsg)

Cheers! :D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • Moderators

Your using @CRLF in the file location?

Try this:

FileWrite($file, @CRLF & "["& @Year&"."&@mon&"."&@mday&" "&@HOUR & ":" &@MIN & ":" &@SEC & ']' & _
            @CRLF & 'Window: "'& $window & '"' & _
            @CRLF & $what2log)

Edit:

PsaltyDS's suggestion is a better one IMO... I also edited "'" to '"' because you had a double quote leading and a single quote ending.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I see, You define the FileWrite, then display it. Okay, now I want to add a message before anything happens that is a msgbox saying they are being logged for IT purposes. Just with an OK button.

MsgBox?

I might be stuck in VB mode :D

Link to comment
Share on other sites

  • Moderators

I see, You define the FileWrite, then display it. Okay, now I want to add a message before anything happens that is a msgbox saying they are being logged for IT purposes. Just with an OK button.

MsgBox?

I might be stuck in VB mode :D

I think you can handle that one on your own, the help file is pretty detailed.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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