Is there any way to open the log file and check for certain strings while it's logging?
Question regarding the log file
Posted by Stoned00d on Wed 16 Jan 2002 11:29 PM — 6 posts, 27,666 views.
You might be able to open a disk file from within VBscript - I don't remember the syntax but I think Krenath knows it.
However why not just make a trigger to match on the text as it arrives?
However why not just make a trigger to match on the text as it arrives?
Microsoft's samples for using the FileSystem Object in VBscript/Javascript can be found at
To open and read a file from disk (in vbscript):
Does MUSHclient close the logfile between logwrites, Nick? If not, the above script might have trouble accessing the logfile.
Similarly, if MUSHclient opens, writes, and closes the log file, it may have trouble reopening it again if the above script is busy looking for something.
Like Nick says, you're best off just setting a trigger directly against the input from the world.
http://msdn.microsoft.com/library/en-us/script56/html/sgworkingwithfiles.asp To open and read a file from disk (in vbscript):
Const ForReading=1
'Const ForWriting=2 'Not needed here
Dim oFS,oFile,sText
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFile = OpenTextFile("c:\Program Files\MUSHclient\Logs\world.log",ForReading)
While not oFile.AtEndOfFile
sText = oFile.ReadLine()
'Here's where you'd check the text line for
'some specific text
Wend
oFile.Close
Set oFile=Nothing
Set oFS = Nothing
Does MUSHclient close the logfile between logwrites, Nick? If not, the above script might have trouble accessing the logfile.
Similarly, if MUSHclient opens, writes, and closes the log file, it may have trouble reopening it again if the above script is busy looking for something.
Like Nick says, you're best off just setting a trigger directly against the input from the world.
Quote:
Does MUSHclient close the logfile between logwrites, Nick? If not, the above script might have trouble accessing the logfile.
Does MUSHclient close the logfile between logwrites, Nick? If not, the above script might have trouble accessing the logfile.
No it doesn't. That would be too time-consuming. However some programs can open files that are in use, and some can't. I would try it and see.
However I agree that using a trigger seems the simpler option (especially as I suggested it in the first place!).
well, I guess I should have asked the following question in the first place: how can I trigger off of more than 1 line of text? I tried to copy/paste and clicked on the little "..." box next to the condition field, but when I tried it, the trigger didn't work.
You can't directly, because the triggers are matched at the end of each line (a multiple-line paragraph is counted as one line).
If you wanted to do that you would have to use multiple triggers. eg. if you wanted to match on:
You could make one trigger that matched on "AAA" and set a flag (eg. a variable). Ditto with "BBB", and then when you get "CCC" you check to see if the flag is set. Of course the variable would need to be cleared if neither "AAA" or "BBB" arrived. You can do that by using trigger sequence numbers.
If you wanted to do that you would have to use multiple triggers. eg. if you wanted to match on:
AAA
BBB
CCC
You could make one trigger that matched on "AAA" and set a flag (eg. a variable). Ditto with "BBB", and then when you get "CCC" you check to see if the flag is set. Of course the variable would need to be cleared if neither "AAA" or "BBB" arrived. You can do that by using trigger sequence numbers.