Capturing the outcome of Compare Data

Discussions about tools to complement CSPro data processing
Post Reply
Guest

Capturing the outcome of Compare Data

Post 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?
Gregory Martin
Posts: 1792
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Capturing the outcome of Compare Data

Post 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;


Last bumped by Anonymous on March 23rd, 2012, 8:23 pm.
Post Reply