Forum Discussion
Hi Ory,
Often, HTML is parsed by using regular expressions. For instance:
fileText = LogParams.AdditionalText;
var re = /<p>.*<\/p>/;
Log.Message(fileText.match(re));
However, after more thorough thinking, I would suggest that you just use an HTML file to log errors in the OnLogError event handler. Below, is a sample script that creates a file with a two-column table. The first column contains error messages, the second column contains corresponding additional information text. The sample uses an existing HTML file as a template. The template file contains one empty table (<table border="1" style="width: 100%;"></table>).
function makeRow(errText, additionalInfo)
{
var aRow = new String("<tr><td>errData</td><td>aiData</td></tr>\r\n");
aRow = aRow.replace("errData", errText);
aRow = aRow.replace("aiData", additionalInfo);
return aRow;
}
function GeneralEvents_OnLogError(Sender, LogParams)
{
var ForReading = 1, ForWriting = 2;
var fso = new ActiveXObject("Scripting.FileSystemObject");
filename = "d:\\Results\\HTMLPage1.htm";
var f = fso.OpenTextFile(filename, ForReading);
var fileText = new String();
fileText = f.ReadAll();
f.Close();
var pos = fileText.lastIndexOf("</table>");
var newFileText = fileText.slice(0, pos-1);
newFileText += makeRow(LogParams.Str, LogParams.StrEx);
newFileText += fileText.slice(pos);
f = fso.OpenTextFile(filename, ForWriting, true);
f.Write(newFileText);
f.Close();
}
function Test()
{
fso = new ActiveXObject("Scripting.FileSystemObject");
fso.DeleteFile("d:\\Results\\HTMLPage1.htm");
fso.CopyFile ("d:\\Results\\SampleFiles\\HTMLPage1.htm", "d:\\Results\\HTMLPage1.htm")
var notepad;
notepad = Aliases.notepad;
//notepad.wndNotepad.MainMenu.Click("Help|About Notepad");
notepad.dlgAboutNotepad.btnOK.ClickButton();
}
Related Content
- 8 years ago
- 12 years ago
- 8 years ago
- 8 years ago
- 12 months ago
Recent Discussions
- 3 days ago
- 3 days ago
- 7 days ago