Pro text/hex editor
with Binary Templates

SweetScape Knowledgebase

KB1019: Can I modify a variable using a template?

When working with Templates there are two types of variables and it is important to understand the difference between the two. Firstly there are Template variables which are defined in a template using the regular C syntax, for example:

     int a;

However, these variables do not behave exactly like C variables. Templates variables are mapped to bytes in a binary file so that reading the value of 'a' reads data from a file and assigning to 'a' writes data to a file. Since Templates are meant to be read-only for a file these type of variables cannot be assigned in the Template but they can be assigned in a script. For example, in a script you can execute:

     a = 5;

and this will modify bytes in your binary file. (Note that there is nothing special you need to include in your script to access the variables defined in a Template, as long as you run your Script after the Template you should be able to access all the Template variables).

The second type of variables in a Template are local variables. These variables behave just like regular C variables and can be assigned like normal. Local variables are defined using the 'local' keyword:

     local int i; 
     for( i = 0; i < 4; i++ )
     {
       //...
     }

If you are trying to assign to a variable in a Template, make sure the variable is declared with the 'local' keyword.




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