pdf printing OFFENDING COMMAND: STACK:

Evening Team

I'm having some trouble printing out (well saving as a
pdf file actually) automated routines using ghost script.
My document is supposed to be one page, but always comes
out as three pages, with pdf printing OFFENDING COMMAND:
STACK: on the 3rd page.

Would appreciate any thoughts. If anyone would like to
have a look at all the code they'd be more than welcome to

TIA

Matt