Edit Anything

Professional text and hex editing
with Binary Templates technology.

SweetScape Knowledgebase
KB1003: How can I display a value beside a struct or array in the Template Results?

In 010 Editor version 2.0 and higher, it is possible to display a value beside a structure or array in the 'Template Results' panel by writing a custom 'read' function for the variable. The 'read' function is responsible for returning a string which is then displayed in the 'Template Results' panel. For example, if you want to define a struct type that returns 'Invalid' if the first item is zero or 'Valid' otherwise, something like this can be used:

     typedef struct {
         int a;
         int b;
         int c;
     } MYSTRUCT <read=MYSTRUCTRead>;
     string MYSTRUCTRead( MYSTRUCT &m )
         if( m.a == 0 )
             return "Invalid";
             return "Valid";
     MYSTRUCT m1; 
     MYSTRUCT m2; 

After running this template, the 'Template Results' could appear like this:

Note that the MYSTRUCTRead function has to be defined after the typedef statement and the function should return a string. It is also possible to write custom 'write' functions that can modify the struct when the user edits the value and presses the Enter key.

For more information, see the Custom Variables topic. An example of this functionality is contained in the 'ZIPTemplate.bt' file installed with 010 Editor.

Back to knowledgebase index
Back to main support page

Our Products

Latest News

- 010 Editor
is now available.

Download it now!
What's New in 8.0?

Join our newsletter to receive tips and tricks on hex editing, special offers, and news from SweetScape Software Inc.

Sign-up Now...