I've left it for nearly half an hour before and it was still going.

I think that is the issue.

This is the line that is generating the error.

Set sc=..%BuildObjectGraph(related+2) If ('sc) ZTrap "SG"

 

Maybe Java, C# or even javascript could be translated. This could allow us to reuse some existing code.