Jump to content

Where can I find info about write to a txt file?


 Share

Recommended Posts

The only problem I have with this is:

FileWrite($file, "Line1")

FileWrite($file, "Still Line1" & @CRLF)

FileWrite($file, "Line2")

I want my application to always use the next line. Hmmm

Any ideas? thanks

Main purpose is a log file.

Edited by jbennett
Link to comment
Share on other sites

Link to comment
Share on other sites

Forgot to mention.

This log file will be on a server and a couple of PCs may access it at the same time.

Can this possibly work?

I'm wondering if I can put some sort of wait command in the code so that the code will wait if another user is accessing it.

thanks

Edited by jbennett
Link to comment
Share on other sites

It can but if it's on a server the best thing would be to have a database, also it's incredibly rude to triple post. Edit your posts,don't make new ones.

Link to comment
Share on other sites

Well if the file is only going to be accessed and not edited then you should be fine as is but if you're going to edit it then yeah you should go for a database. They're not as hard as you think.

Link to comment
Share on other sites

Check out using this- http://www.autoitscript.com/forum/index.php?showtopic=20814

There are many other databases available on the forum.

Your other option is to have a server write the logs, and your clients tell the server what to write. If you wish to do that, check out Kip's TCP On Event script- http://www.autoitscript.com/forum/index.php?showtopic=74325

Cheers,

Brett

Link to comment
Share on other sites

I have MySQL setup for the forums on my website but most SQL databases should be functionally the same. There are built in functions for SQLite and there's a UDF for MySQL. As long as you know the syntax of the commands you need you'll be fine.

Link to comment
Share on other sites

Ummm my brain can't handle that code tonight :-(

I still feel like using the txt file, mainly because the code is very simple and there will only be about 3 entry's per every 2 weeks.

Just want to get a simple idea in place that I can try tomorrow. It's 1:31am here now, OUCH

Sorry, hope i'm not being a pain.

Edited by jbennett
Link to comment
Share on other sites

If it's going to be that infrequent you should be ok with a text file. A database works better for multiple simultaneous connections and I thought that's what you were doing.

Link to comment
Share on other sites

Nah it's very basic.

Just for my own personal use to see if it's actually working on client PCs.

Want to be sure that if 2 PCs are running it then they will both put in the info, even if running the schedule at the same time. Mainly will be about 3 PCs per every 2 weeks though, just trying to be safe.

Just can't find the code in the help files to wait for txt file to close before writting to it.

Cheers

Edited by jbennett
Link to comment
Share on other sites

I come up with an idea, considering I would only have 3 PCs

$computername = EnvGet("computername")

$file = FileOpen(@Scriptdir & "-" & $computername & ".txt", 1)

Seems to put the @scriptdir in the file name though lol, but almost there.

cheers

UPDATE

--------

Figured it out

$computername = EnvGet("computername")

$file = FileOpen(@Scriptdir & "\" & "Backup_Log" & "-" & $computername & ".txt", 1)

Edited by jbennett
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...