Faleira Posted October 20, 2005 Share Posted October 20, 2005 expandcollapse popup#include <file.au3> #include <Array.au3> Dim $alogs[1000] $file = FileOpen("html.body", 0) $head = FileOpen("html.head", 0) $tail = FileOpen("html.tail", 0) $writing = Fileopen(@ScriptDir & "/logs/Log.html", 2) $htmlhead = FileRead("html.head", FileGetSize("html.head")) $htmltail = FileRead("html.tail", FileGetSize("html.tail")) $htmlbody = FileRead("html.body", FileGetSize("html.body")) $start = StringInStr($htmlbody, "<SPAN id=s_Chat> ") $logging = StringMid($htmlbody, $start, StringLen($htmlbody)) $logging = StringMid($logging, StringInStr($logging, "<FONT"), StringLen($logging)) $end = StringInStr($logging, "<BR>") $logging = StringMid($logging, 1, $end - 1) ;pm $pmexist = StringInStr($logging, "javascript:pm") If $pmexist <> 0 Then $startname = StringInStr($logging, ">") $name = StringMid($logging, $startname, StringLen($logging)) $name = StringMid($name, StringInStr($name, "<a href"), StringLen($name)) $endname = StringInStr($name, "')"">") $name = StringMid($name, 1, $endname + 3) $logging = StringReplace($logging, $name, "<font color = ""C89468"">") $logging = StringReplace($logging, "</a>", "</font>") EndIf ;/pm _FileWriteLog(@ScriptDir & "\log.lsz", $logging & "<BR>") _FileReadToArray(@scriptdir & "\log.lsz", $alogs) _ArrayReverse($alogs, 1) FileWrite($writing, $htmlhead) _FileWriteFromArray(@ScriptDir & "/logs/Log.html",$alogs) FileClose($writing) $writing = FileOpen(@ScriptDir & "/logs/Log.html", 1) FileWrite($writing, $htmltail) FileClose($writing) FileClose($file) I made that to log the chatwindow of a game for me. Now there are 2 problems right now... 1st is declaring the array... since i can only set it to a certain number... is there a way i can make it so that it extends as more values are added to the array? 2nd for some reason, the beginning chunk of the stuff isn't actually getting logged, like so: :58:13 : Your character does not currently have a proper account key. If you are the owner of the account please use Options menu to set one. Use a combination of letters and numbers! 2005-10-19 22:58:08 : Your character does not currently have a proper account key. If you are the owner of the account please use Options menu to set one. Use a combination of letters and numbers! 2005-10-19 22:57:55 : Your character does not currently have a proper account key. If you are the owner of the account please use Options menu to set one. Use a combination of letters and numbers! Could someone explain why taht happens? [quote]If whenever you feel small, useless, offended, depressed, and just generally upset always remember......you were once the fastest and most vicious sperm out of hundreds of millions![/quote] Link to comment Share on other sites More sharing options...
A.B.Ames Posted October 20, 2005 Share Posted October 20, 2005 Hi, I'm not familiar with what your trying/doing (i'm still learning) but for changing the array size without losing data in it you are looking for reDim in the help, also you may need Ubound to read the size as needed (for knowing when to increase it with reDim). Hope this helps a bit, sorry but unfamiliar with your other question. A.B.Ames Link to comment Share on other sites More sharing options...
Faleira Posted October 20, 2005 Author Share Posted October 20, 2005 It's kind of hard, since it runs, writes into a file, then does wtvr, so if i run it multiple times, it still loads those items into the array, it's not creating and loading new stuff in the array every time the script it's run, it's new stuff + old stuff... [quote]If whenever you feel small, useless, offended, depressed, and just generally upset always remember......you were once the fastest and most vicious sperm out of hundreds of millions![/quote] Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 20, 2005 Share Posted October 20, 2005 why don't you dim your array to a very high value e.g. dim $array[1000000000] this should work and you don't have the problem of 2 little arrays maybe 1 billion is a bit high, but thats your decission my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
LxP Posted October 20, 2005 Share Posted October 20, 2005 (edited) Some pointers:You don't need to use FileOpen() on a file if you're only going to use it once. If you do FileOpen() a file then you should refer to it via the handle returned via the FileOpen() call.Dim is so yesterday. Use Local or Global depending on the task. Local is generally the way to go.You don't have to pass a declared array to _FileReadToArray().Declaring an array of an extremely large size consumes scary amounts of RAM. Don't do it unless you plan to use most of it.Comments are good, mmkay?If you need to place double quotes within a string, why not surround the string with single quotes? It means that you don't need to worry about escaping the double quotes.The third parameter to StringMid() is optional -- it defaults to the end of the string.Try out this code:Edit: Fixed the UBound() line,expandcollapse popup#Include <Array.au3> #Include <File.au3> Local Const $LOG_PATH = @ScriptDir & '\log.lsz' ; Read HTML data into variables Local $HTMLBodyData = FileRead('html.body', FileGetSize('html.body')) ; Find the location of the first <FONT> tag after the first ; <SPAN id=s_Chat> tag and trim all data before it Local $LogData = StringMid($HTMLBodyData, StringInStr($HTMLBodyData, '<SPAN id=s_Chat> ')) $LogData = StringMid($LogData, StringInStr($LogData, '<FONT')) ; Find the first <BR> tag and remove it and all trailing data $LogData = StringLeft($LogData, StringInStr($LogData, '<BR>')) ; Check that $LogData contains the desired information MsgBox(0x40, '$LogData', $LogData) If StringInStr($LogData, 'javascript:pm') Then ; Find the data coming after the first <A> tag after the first tag $Name = StringMid($LogData, StringInStr($LogData, '>')) $Name = StringMid($Name, StringInStr($Name, '<a href')) ; Remove all data past the end of the tag $Name = StringLeft($Name, StringInStr($Name, "')" + '">') + 3) ; Do some tag replacement $LogData = StringReplace($LogData, $Name, '<font color="#C89468">') $LogData = StringReplace($LogData, '</a>', '</font>') EndIf ; Append the information to the log _FileWriteLog($LOG_PATH, $LogData & '<BR>') ; Load all log details in reverse-chronological order Local $LogArray _FileReadToArray($LOG_PATH, $LogArray) _ArrayReverse($LogArray, 1) ; Open log for overwriting $LogHandle = Fileopen(@ScriptDir & "\logs\Log.html", 2) ; Write out the HTML header FileWrite($LogHandle, FileRead("html.head", FileGetSize("html.head"))) ; Can't use _FileWriteFromArray() because it will overwrite the header ; No big deal FileWrite($LogHandle, $LogArray[0]) Local $I For $I = 1 To UBound($LogArray) - 1 FileWrite($LogHandle, @CRLF & $LogArray[$I]) Next ; Write out the HTML footer FileWrite($LogHandle, FileRead("html.tail", FileGetSize("html.tail"))) ; Close the file FileClose($LogHandle) Edited October 21, 2005 by LxP Link to comment Share on other sites More sharing options...
Faleira Posted October 20, 2005 Author Share Posted October 20, 2005 (edited) thankx, but doesn't using the for loop and the filewrite function like that, make it kind of slow? And for some reason, when i try to run the script, it gets up to the for loop, and gives an error ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: FileWrite($LogHandle, @CRLF & $LogArray[$I]) FileWrite($LogHandle, @CRLF & ^ ERROR ::edit:: nvm, i just shoved a -1 to the ubound, and it's fine now, thankx for the help =D Edited October 20, 2005 by Faleira [quote]If whenever you feel small, useless, offended, depressed, and just generally upset always remember......you were once the fastest and most vicious sperm out of hundreds of millions![/quote] Link to comment Share on other sites More sharing options...
LxP Posted October 21, 2005 Share Posted October 21, 2005 doesn't using the for loop and the filewrite function like that, make it kind of slow?Nope -- in fact this is exactly how _FileWriteFromArray() does its job. If anything it would be quicker because you're not calling another function, opening another file handle, validating arguments etc.Better fix that UBound() line in my other post! 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