Innovation
9 years agoNew Contributor
Verifying .Pix Files with variable Parts
Hello Smartbearcommunity,
i'm trying to verifying 2 .pix files and in thispix files the "id" is changing.
How do i get my script working?
Example PIX File
File1 <? xml version"1.0! encoding="UTF-8"?><!--comment--><METADATA><CONSIGNOR AppVersion="xx.xx.xx" DBStructure="4.0" ID="123"/></METADATA> File 2 <? xml version"1.0! encoding="UTF-8"?><!--comment--><METADATA><CONSIGNOR AppVersion="xx.xx.xx" DBStructure="4.0" ID="456"/></METADATA>
my DelphiScript
function CompareFiles(fileName1, fileName2);
const
ForReading = 1;
var
fso, regEx;
file1, file2;
fileText1, fileText2, newText1, newText2;
begin
// Creates the FileSystemObject object
fso := Sys.OleObject('Scripting.FileSystemObject');
// Reads the first text file
file1 := fso.OpenTextFile(fileName1, ForReading);
fileText1 := file1.ReadAll;
file1.Close;
// Reads the second text file
file2 := fso.OpenTextFile(fileName1, ForReading);
fileText2 := file2.ReadAll;
file2.Close;
// Creates the regular expression object
regEx := HISUtils.RegExpr;
// Specifies the pattern for the date/time mask
// MM/DD/YYYY HH:MM:SSLL (for example: 4/25/2006 10:51:35AM)
regEx.Expression := '(?i)\d{1,2}.\d{1,2}.\d{2,4}\s\d{1,2}:\d{2}:\d{2}\w{2}';
// Replaces the text matching the specified date/time format with <ignore>
newText1 := regEx.Replace(fileText1, '<ignore>');
newText2 := regEx.Replace(fileText2, '<ignore>');
// Compares the text
Result := (newText1 = newText2);
end;
procedure CompareMethodVersuch1;
var
fileName1, fileName2;
begin
fileName1 := 'C:\Users\Admin\Desktop\MasterReport.pix';
fileName2 := 'C:\Users\Admin\Desktop\MasterReport2.pix';
if CompareFiles(fileName1, fileName2) then
Log.Message('The files are equal')
else
Log.Error('The files are different');
end;I'm using this Example
I think i have to change this line of code
"regEx.Expression := '(?i)\d{1,2}.\d{1,2}.\d{2,4}\s\d{1,2}:\d{2}:\d{2}\w{2}';"
best regards :)