Here is my code that I am trying to do.  Like it says below.  Turning off a solenoid.  Waiting for it to move back and hit the switch.  Then turn on output 2 which will be a solenoid.  Wait for the switch and then display a message.  
This code works when I step through it, however when I try and run it Via MDI it locks up Mach 4 and closes it.  ANY IDEAS???
-Chad
--TEST CODE INPUTS AND OUTPUTS!!
--Example of a solenoid shutting off and waiting for the switch.
--Turn on output 1 and wait for switch then display message.
function m1002()
local rc = 0;
local inst = 0; -- mc.mcGetInstance(mInst)
-- Turns off output 1
hsig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1);  
mc.mcSignalSetState(hsig, 0); --sets OUTPUT_1 to False
-- Turns off output 2: SOLENOID 1
hsig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT0);  
mc.mcSignalSetState(hsig, 0); --sets OUTPUT_0 to False
--Messages are written like this.
mc.mcCntlSetLastError(inst, "Output 2 Off");
function Input1IsFalse () --Solenoid 1 back switch.
    hsig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT1);  --set hsig variable to handle input 1
    sigState = mc.mcSignalGetState(hsig);
    if sigState == 0 then
        return true; --Not active yet.
    else
        return false; --Input is active.
    end
end --Input1IsFalse
while Input1IsFalse() do
mc.mcCntlSetLastError(inst, "Solenoid 1 is Moving.");
end  --waits until input1 is true
mc.mcCntlSetLastError(inst, "Solenoid 1 is back.");
-- Turns on output 1
hsig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1);  
mc.mcSignalSetState(hsig, 1); --sets OUTPUT_1 to True
function Input2IsFalse () --Output 1 is active switch.
    hsig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT2);  --set hsig variable to handle input 2
    sigState = mc.mcSignalGetState(hsig);
    if sigState == 0 then
        return true; --Not active yet.
    else
        return false; --Input is active.
    end
end --Input2IsFalse
while Input2IsFalse() do
mc.mcCntlSetLastError(inst, "Output1 is turing on.");
end  --waits until input2 is true
mc.mcCntlSetLastError(inst, "Output 1 ON");
end --This is for the end of the function m1002()
--This next part does not have to be in here 
--it is for testing and steping through macros
--it runs the macro in Mach 4 fine without it.
if (mc.mcInEditor() == 1) then
   m1002()
end