I’m new to 010, and have absolutely fallen in love with binary templates. However, I ran into an issue that took me quite a bit of time to solve, and I’m wondering if I’m missing something.
I’m working with a format that has relative offsets, and it is significantly more helpful to me to see those as absolute offsets, so I wrote this function:
uint32 returnAbsoluteOffset() {
return (startof(this) + 4) + this;
}
Which was supposed to get invoked like:
uint32 offset <read=returnAbsoluteOffset(), format=hex>;
But the format attribute doesn’t work; the value just gets displayed as decimal. The solution I ended up with was:
string returnAbsoluteOffset() {
return Str("%Xh", (startof(this) + 4) + this);
}
And that works! But it’s uglier than what I originally wrote, I think. Is there a more elegant way to do this, or am I doing it the best way?