Histogram on variables, not selection

Hi there, thanks for this wonderful piece of software!

I’m analyzing binary data and would like to visually check for deviations outside the accepted range. For this, I wanted to use the histogram functionality.

Unfortunately, it appears it only works on a consecutive range of bytes. The values I want to graph are however members of a struct that is repeated multiple times. With that, the values are not consecutive and it appears I can’t use the histogram.

Would it be possible for you to allow the histogram to accept expressions to evaluate for its input data? Or is there a way to do it that I’m overlooking? Either way, I feel that with such a powerful expression engine that you have, not being able to use it for the histogram function is an unfortunate limitation.

Doing a histogram on a template variable is not currently supported but that would be a nice feature to have and we’ll have to look into adding it at some point in the future. Calculating a histogram on a variable could be done with a short script and we could show you how a script could be written if you are interested. The output wouldn’t be as pretty as from the interface but you still should be able to get some data using a script. Cheers!

Graeme
SweetScape Software

I’d appreciate if you could provide a snippet that I can try.

This should demonstrate how to do a simple histogram:

//------------------------------------------------
//--- 010 Editor v15.0.1 Script File
//
//      File: HistogramVariables.1sc
//   Authors: SweetScape Software
//   Version: 1.0
//   Purpose: Calculates a histogram on a set of template variables.
//  Category: 
//   History: 
//------------------------------------------------

#define COUNT       3 // could be an expression
#define EXPRESSION  record[i].frVersion // some expression with 'i' in it
#define MIN_VALUE   0
#define MAX_VALUE   1000
#define NUM_BUCKETS 100

int i, index, numExcluded, maxCount;
int buckets[ NUM_BUCKETS ];

// Iterate through all the expressions and add 1 to each bucket the value is in
for( i = 0; i < COUNT; i++ )
{
    index = (EXPRESSION - MIN_VALUE) / (double)(MAX_VALUE - MIN_VALUE) * NUM_BUCKETS;
    if( index >= 0 && index < NUM_BUCKETS )
    {
        buckets[index]++;
        if( buckets[index] > maxCount )
            maxCount = buckets[index];
    }
    else
        numExcluded++;
}

// Draw the graph with '-' to indicate how many were found
// Output after - indicates how many values were in the bucket
// and the starting value of the bucket
int tick, numTicks;
if( maxCount == 0 )
{
    Printf( "No values found." );
    return;    
}
for( i = 0; i < NUM_BUCKETS; i++ )
{
    numTicks = buckets[i] / (double)maxCount * 40.0; // max 40 ticks wide
    for( tick = 0; tick < numTicks; tick++ )
        Printf( "-" );
    Printf( "%d [%.2lf]\n", buckets[i], MIN_VALUE + i * (MAX_VALUE - MIN_VALUE) / (double)NUM_BUCKETS );
}
Printf( "%d values were excluded", numExcluded );

You can adjust the histogram using the constants at the top of the file. The template variables you want to access should be in an expression in EXPRESSION and let us know if you have any questions.

Graeme
SweetScape Software