Pro text/hex editor
with Binary Templates

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";
         else
             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.




Newsletter - Receive special offers, tips, tricks and news. Join now

010 Editor v15.0.1 is here!
What's new?



E-mail: info@sweetscape.com