Mastercam passes the work offset integer through work_ofs$.
pwcs$ #Work Coordinate System
if work_ofs$ = 0, "G54"
if work_ofs$ = 1, "G55"
if work_ofs$ = 2, "G56"
# ... and so on
Before you open a file in a text editor, you must understand what you are looking at. Mastercam posts typically have the .pst or .psb extension. mastercam post processor editing
The simplest debugging method is inserting diagnostic prints. Mastercam passes the work offset integer through work_ofs$
"(" + "Debug: Tool number is " + tool$ + ")" #Comments in parentheses