shanet Posted December 16, 2010 Share Posted December 16, 2010 I have a log file, which has different lines for different events. Each line contains different properties for that event, as such: date:hour:minute|Title|Description|Priority What I need done, is for each line, it is identified as a unique event, then each property identified somewhat as such: $date1, $hour1, $minute 1, $title1, $description1, $priority1 And then two and three and four as required. Are you with me? An example log file would contain something as follows: 27/12/10|13|15|Event Title|Event Description|Event Priority 28/12/10|09|00|New Event|New Event Description|New Event Priority 10/12/10|00|00|Midnight Event|This event will trigger at midnight|My Event Priority EndofFile EndofFile lets the program know it has reached the end of the file and that there are no more programs to display. Just to add to the confusion, the file may be anywhere on the computer, including an external device or on a network share. Really? No, not really. It is located here: @UserProfileDir & "\" & @Username & ".log" So how would I go about implementing this? Thanks guys, shanet [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 16, 2010 Share Posted December 16, 2010 Just FileReadLine() in a loop and apply StringSplit() to each line. See help file. 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 More sharing options...
fett8802 Posted December 16, 2010 Share Posted December 16, 2010 (edited) Wow, I misread his post and just spent a couple of minutes coding an example logging program. I feel stupid. Well, I'm posting the code anyway!!! $Number_Of_Events = 100 For $i = 1 To $Number_Of_Events ;Mostly for the sake of this example. You probably won't have a For loop here $Title = "Loop_" & $i ;Creates the Title for this example, Loop_1 or Loop_2, you'll have to get your own titles $Description = "Description_" & $i ;Same as the title $Priority = "Priority_" & $i ;Same as above $File_Handle = FileOpen("TestLogFile.txt",1) ;The location of your file. Setting the parameter to 1 will open in write mode and create the file it isn't created FileWrite($File_Handle, @MON & "/" & @MDAY & "/" & @YEAR & "|" & @HOUR & "|" & @MIN & "|" & $Title & "|" & $Description & "|" & $Priority & @CRLF) ;I just use macros and variables for the entire thing. The @CRLF creates a new line. Add more for line breaks Next FileClose($File_Handle) ;Make sure to close your file after you're done writing to it Edited December 16, 2010 by fett8802 [sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub] Link to comment Share on other sites More sharing options...
iamtheky Posted December 16, 2010 Share Posted December 16, 2010 #Include <File.au3> $count = _FileCountLines ("log.txt") $MAX = $count - 1 For $i = 1 to $MAX $line = FileReadLine ("log.txt" , $i) $newline = StringRegExpReplace ($line , "\|" , "(" & $i & ")|") _FileWritetoLine ("log.txt" , $i , $newline , 1) next ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 16, 2010 Share Posted December 16, 2010 Wow, I misread his post and just spent a couple of minutes coding an example logging program.You may have read it better than me. I thought it was about reading the log and breaking out the values, but the OP may be about writing those values in that format. 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 More sharing options...
shanet Posted December 16, 2010 Author Share Posted December 16, 2010 You may have read it better than me. I thought it was about reading the log and breaking out the values, but the OP may be about writing those values in that format.It is. I want the log file read and values given appropriately.Thanks guys, this is good stuff! [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm Link to comment Share on other sites More sharing options...
MvGulik Posted December 16, 2010 Share Posted December 16, 2010 (edited) EndofFile lets the program know it has reached the end of the file and that there are no more programs to display.Don't do that, adding unneeded and unrelated data to a other data set in the same file. (unless you main "untill [EOF]" which makes way more sense if you also write it like that.) - - - (I feel a possible SQLite .import reply coming.) or not. Edited December 17, 2010 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
shanet Posted December 17, 2010 Author Share Posted December 17, 2010 Don't do that, adding unneeded and unrelated data to a other data set in the same file. (unless you main "untill [EOF]" which makes way more sense if you also write it like that.) - - - (I feel a possible SQLite .import reply coming.) or not. Yes, that is what I have done... did I not mention that? [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm 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