Page 1 of 1

Capturing the outcome of Compare Data

Posted: March 6th, 2012, 7:44 pm
by Guest
When two data files are compared using 'Compare Data (CSDiff)' on the 'tools' menu, is there any parameter passed (stored) somewhere to imply data files are different or have no different? I imagine if the data files are different then a parameter like diffFound = 1 or diffFound = 0 for vice versa.

Or, how else will I trap a status of a data file having difference or not?

Re: Capturing the outcome of Compare Data

Posted: March 23rd, 2012, 8:23 pm
by Gregory Martin
I assume that you're doing this in the context of a menu program and you want to identify, after the comparison runs, whether or not there were any problems. Unfortunately, you can't easily get an error code that returns the results, but you can parse the listing file to identify whether or not there were errors. You can do this by counting the number of lines in the file and determining whether more than six lines of text are in the output file, in which case there were errors. The code might look like this:
PROC GLOBAL

file pffFile,listingFile;

alpha (300) filename1,filename2,
            listingReport =
".\diffReport.lst",
            str;



// PROC ...........

    
// write out the PFF file
    setfile(pffFile,"compare.pff");
    
    
filewrite(pffFile,"[Run Information]");
    
filewrite(pffFile,"Version=CSPro 4.1");
    
filewrite(pffFile,"AppType=Compare");
    
    
filewrite(pffFile,"[Files]");
    
filewrite(pffFile,"Application=.\comparisonSpecs.cmp");
    
filewrite(pffFile,"Listing=%s",strip(listingReport));
    
filewrite(pffFile,"InputData=%s",strip(filename1));
    
filewrite(pffFile,"ReferenceData=%s",strip(filename2));
    
    
filewrite(pffFile,"[Parameters]");
    
filewrite(pffFile,"ViewListing=Never"); 
    
    
close(pffFile);

    
// run the PFF
    execpff(filename(pffFile),wait);
    
    
// the listing report, if there were no differences, will only be six lines
    setfile(listingFile,listingReport);
    
    
numeric numLinesRead;
    
    
while fileread(listingFile,str) and inc(numLinesRead) <= 6 do
    
enddo;
    
    
close(listingFile);
    
    
if numLinesRead > 6 then
        
// there were errors
    
    
else
        
// no errors
    
    
endif;