Export byte differences in csv

Is it possible to export byte differences in csv from comparing results?

Currently, it can only export from cells like “Difference, 2436C74h, 4h, 2436C74h, 4h” buf I wanted it to be like “Difference, 2436C74h, 4h, 21 00 01 CB, 2436C74h, 4h, E1 03 1F AA” excluding matched results

There is no way currently to export the Compare results and include the bytes that are different. You can support the Compare table by ‘Result’ so that all the differences are grouped together but you cannot include the bytes. If you really need the bytes as well, it would be possible to create a short script to do the output using the ‘Compare’ function and let us know if you would like more details on how this would work.

Graeme
SweetScape Software

I could go with the script. Do you have a good sample of it for beginners?
I like to output something like this like the other hex editor does. Sadly, it lacks some features I need, I still prefer 010 editor

image

Here is a script that should do roughly what you want:

int i, f1, f2, outputFile;
string hexStr1, hexStr2;

// Get the files to compare - could use InputOpenFileName or different technique
FileOpen( "C:\\temp\\comp.1" );
f1 = GetFileNum();
FileOpen( "C:\\temp\\comp.2" );
f2 = GetFileNum();

// Create the output file
outputFile = FileNew( "Text", false );

// Function to read data and convert to a hex string
string ReadHexString( int file, int64 start, int64 size )
{
    if( size == 0 )
        return "";
    FileSelect( file );
    if( size > 1024 )
        size = 1024; // use some kind of limit
    string str;
    uchar buffer[size];
    uchar temp[16];
    ReadBytes( buffer, start, size );
    int i;
    for( i = 0; i < size; i++ )
    {
        SPrintf( temp, "%02X ", buffer[i]);
        str += temp;
    }
    return str;
}

// Do the compare and output the results
TCompareResults r = Compare( COMPARE_SYNCHRONIZE, f1, f2 );
for( i = 0; i < r.count; i++ )
{
    if( r.record[i].type == COMPARE_DIFFERENCE ) // could do COMPARE_ONLY_IN_A/B as well
    {
        hexStr1 = ReadHexString( f1, r.record[i].startA, r.record[i].sizeA );
        hexStr2 = ReadHexString( f2, r.record[i].startB, r.record[i].sizeB );
        FPrintf( outputFile, "%LX - %LX, %LX - %LX, %s -> %s\n", 
            r.record[i].startA, 
            r.record[i].startA + r.record[i].sizeA - 1, 
            r.record[i].startB, 
            r.record[i].startB + r.record[i].sizeB - 1,
            hexStr1, 
            hexStr2 ); 
    }
}

FileSelect( outputFile );
// Could use FileSave to save the output file to a filename

In 010 Editor you can click ‘Scripts > New Script’ and copy this in. Feel free to modify the script and let us know if you have any questions.

Graeme
SweetScape Software

Thanks! I think I can improve it on my own now with a help of AI

Then why didn’t You use AI in the first place?
:thinking:

I didn’t think about it first, and also AI isn’t really smart, they only works better if you provide them snippets, links or proper info, otherwise they come up with 50% of things that doesn’t work or exist. I will also use other public scripts for learning too

Would it by possible to add Max Output Rows for TCompareResults? it doesn’t seems to be supported. I work with large files with many differences, it won’t be slow as long as long as I use Byte by Byte (Simple)

We’ve found that AI is not great for writing new scripts and seems to get confused about which functions to call and how to call them. It seems to be better at modifying an existing script. There is no built-in way with the Compare function to limit the number of rows and we’ll had to add that in the future. You can limit the number of rows in the script by modifying the ‘for’ statement:

Or you could run the compare on just part of the file using start/size.

Graeme
SweetScape Software