Accessing struct argument inside read functuon

typedef struct(NameEntry &names)
{
    int32 Index <read=Str("%s", this[0] > 0 ? names[this[0]].Name : "None")>;
} StructData <optimize=false>;

names array is invalid/non-existent

It’s important to understand that the ‘read’ functions are called only when the Template Results displays data, meaning the ‘read’ functions are called after the Template has finished executing. In this case the names array is no longer available so you have to save the data you want to display into a local variable like this:

typedef struct(NameEntry names[])
{
    int32 Index;
    local string localName = Index > 0 ? names[Index].Name : "None";
} StructData <optimize=false, read=localName>;

This puts the read function on StructData but it could be placed on Index if you wanted. Cheers!

Graeme
SweetScape Software