Good morning,
I added another end to the end and am no longer getting an error. Thanks for the tip on checking the code. Unfortunately when I run it in either MDI or in a program it  makes the buttons on the screen blank for a second like you are normally running a program but it does not trigger an output. This is what I have now.
function m121() --Save the name of the Signal (as stored inside of Mach4)
local inst = mc.mcGetInstance() --Get the instance of Mach4
ActivateSignalTime = 10000 --Time in milliseconds that we want the signal to be active.
local hReg = mc.OSIG_OUTPUT5 --The handle to the signal
-----------------------------
hReg = mc.mcIoGetHandle(inst, IOName)
if hReg == 0 then
   wx.wxMessageBox("Could not locate signal!")
else
   local rc = mc.mcIoGetState(hReg)
   if rc == 1 then --If rc equals 1, then the signal is active.
      wx.wxMessageBox("Signal is already active!")
   else --If rc does not equal 1, then the signal is not active.
      mc.mcIoSetState(hReg, true) --Activate a signal.
      wx.wxMilliSleep(ActivateSignalTime) --Sleep for the commanded time (so that the output stays on as long as we want).
      mc.mcIoSetState(hReg, false) --Set the state of the signal back to false.
   end
end
end
dan