I need to create new struct and temp array each time because these are unique objects. So I can’t move them outside of FOR scope. But I also can’t use them inside FOR scope because it complains it is defined.
What do.
Typically in Templates you don’t define functions that create structs, you just define the structs directly. The logic for reading the data is usually directly inside the struct. For example, to create an array of FSHAHash structures you could use:
typedef struct { uchar Hash[20] <format=hex>; } FSHAHash;
typedef struct {
int arrayNum; // or however the array size is calculated
local int i;
for(i = 0; i < arrayNum; i++)
{
FSHAHash hash;
FSkip( 8 );
}
} FSHAHashArray;
FSHAHashArray array;
No, because I simplified example, the actual logic is much more complex and if I’d try ti put it inside typedef struct it would just make it an unreadable, ugly and unmanageable mess. The logic in template would need to be updated often in most subtle and specific ways and readability is key