You can use mc.mcCntlSetLastError() function to print out information into the history log to help you learn what's going on in the code.
You can find out more information about the API functions from the Mach4CoreAPI.chm document located in the Docs folder in the Mach4 installation directory. Pay attention only to what the LUA syntax examples show.
Here is some example code reworked from your original post:
--Set the probe position to some value
mc.mcCntlSetPoundVar(0, mc.SV_PROBE_POS_A, -3.14)
mc.mcCntlSetPoundVar(0, mc.SV_PROBE_POS_Z, -2.579)
-- print #var number of probe position vars
mc.mcCntlSetLastError(inst, string.format('SV_PROBE_POS_A #var: %5.0f SV_PROBE_POS_Z #var: %5.0f', mc.SV_PROBE_POS_A, mc.SV_PROBE_POS_Z))
local pVal = mc.mcCntlGetPoundVar(0, mc.SV_PROBE_POS_Z) -- Get the Probe position of Z-Axis and put in local var P
local tVal = mc.mcCntlGetPoundVar(0, mc.SV_PROBE_POS_A) -- Get the Probe position of A-Axis and put in local var T
mc.mcCntlSetLastError(inst, string.format('pVal: %s tVal: %s', pVal, tVal))
--Swap Z-A axis code
mc.mcCntlSetPoundVar(0, mc.SV_PROBE_POS_A, pVal) --Get the Val P (Probe Z position) and put it in Probe Pos A value
mc.mcCntlSetPoundVar(0, mc.SV_PROBE_POS_Z, tVal) --Get the Val T (Probe A position) and put it in Probe Pos Z value
pVal = mc.mcCntlGetPoundVar(0, mc.SV_PROBE_POS_Z) -- Get the Probe position of Z-Axis and put in local var P
tVal = mc.mcCntlGetPoundVar(0, mc.SV_PROBE_POS_A) -- Get the Probe position of Z-Axis and put in local var T
mc.mcCntlSetLastError(inst, string.format('pVal: %s tVal: %s', pVal, tVal))