jbennett Posted October 16, 2008 Share Posted October 16, 2008 Hey, Does anyone know where I can find some info on writing to a text file? Just want my code to log the date and computer name in a .txt file thanks Link to comment Share on other sites More sharing options...
TehWhale Posted October 16, 2008 Share Posted October 16, 2008 FileOpen() FileWrite() FileClose() Link to comment Share on other sites More sharing options...
jbennett Posted October 16, 2008 Author Share Posted October 16, 2008 cheers ;-) Link to comment Share on other sites More sharing options...
jbennett Posted October 16, 2008 Author Share Posted October 16, 2008 (edited) 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 October 16, 2008 by jbennett Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 16, 2008 Share Posted October 16, 2008 (edited) Open in write mode 1. Edit: Also checkout FileWriteLine(). Edited October 16, 2008 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
jbennett Posted October 17, 2008 Author Share Posted October 17, 2008 filewriteline() does the job very nicely. Is there any way I can include the name of the computer in the code? thanks Link to comment Share on other sites More sharing options...
jbennett Posted October 17, 2008 Author Share Posted October 17, 2008 got it...$computername = EnvGet("computername") Link to comment Share on other sites More sharing options...
jbennett Posted October 17, 2008 Author Share Posted October 17, 2008 (edited) 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 October 17, 2008 by jbennett Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 17, 2008 Share Posted October 17, 2008 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. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
jbennett Posted October 17, 2008 Author Share Posted October 17, 2008 Sorry, I will remember to edit my posts from now on I see what you're saying about a database but just want to keep it simple :-) Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 17, 2008 Share Posted October 17, 2008 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. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
jbennett Posted October 17, 2008 Author Share Posted October 17, 2008 (edited) Oh my. Do you mean a database with access? I've never worked with a database before :-( Edited October 17, 2008 by jbennett Link to comment Share on other sites More sharing options...
BrettF Posted October 17, 2008 Share Posted October 17, 2008 Check out using this- http://www.autoitscript.com/forum/index.php?showtopic=20814There 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=74325Cheers,Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
jbennett Posted October 17, 2008 Author Share Posted October 17, 2008 My script is very simple and just runs a backup program. The log just records the users computer name and the date and time. Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 17, 2008 Share Posted October 17, 2008 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. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
jbennett Posted October 17, 2008 Author Share Posted October 17, 2008 (edited) 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 October 17, 2008 by jbennett Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 17, 2008 Share Posted October 17, 2008 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. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
jbennett Posted October 17, 2008 Author Share Posted October 17, 2008 (edited) 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 October 17, 2008 by jbennett Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 17, 2008 Share Posted October 17, 2008 That's because there isn't code for that. That's why we suggested databases. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
jbennett Posted October 17, 2008 Author Share Posted October 17, 2008 (edited) 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.cheersUPDATE--------Figured it out$computername = EnvGet("computername")$file = FileOpen(@Scriptdir & "\" & "Backup_Log" & "-" & $computername & ".txt", 1) Edited October 17, 2008 by jbennett Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now