Hello Guest it is April 16, 2024, 04:20:40 AM

Author Topic: Ignoring While loops unless Stepping thru code  (Read 2900 times)

0 Members and 1 Guest are viewing this topic.

Ignoring While loops unless Stepping thru code
« on: June 08, 2012, 11:09:44 PM »
I have a number of while loops in my code where it checks for position after a pneumatic cyl. move for example. When I run the code, it blows by the code like it isn't there. When I step through the code it seems to loop as I would expect it to. any ideas? Here is some sample code.

while not isactive(input4)
  message("still going")
  Sleep 50
Wend
  Message("you made it")

tbyrd
Re: Ignoring While loops unless Stepping thru code
« Reply #1 on: June 10, 2012, 03:05:25 PM »
Hi tbyrd,
i found the same problem with my toolchange macro. everything is fine in mdi or autorun, but in single it does not wait for the input to be true.
what i did is at the begin in the macro switch off single block then run the macro to the end then switch single block on again.
for me that works well. Your macro may look like 

SetVar 500, getoemled(82)
If (getoemled(82) =-1)Or(getoemled(82) =-1) Then
DoOembutton(1004)
end If

while not isactive(input4)
  message("still going")
  Sleep 50
Wend
  Message("you made it")

If (GetVar(500)=-1)Or(GetVar(500)=-1) Then
DoOembutton(1004)
end If


be sure not to use Var 500 for other operations in this case.
alex
Re: Ignoring While loops unless Stepping thru code
« Reply #2 on: June 10, 2012, 09:57:24 PM »
Thanks Alex, I'll give it a try first thing Monday Morning. I could just put a huge pause after every cyl. move, and hope all things work properly, but I would like to think that the switches will work.  Thanks again.
 tbyrd

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Ignoring While loops unless Stepping thru code
« Reply #3 on: June 10, 2012, 10:37:38 PM »
You may want to give this a try.

while not isactive(input4)
  message("still going")
  Sleep 50
Wend
While Ismoving()
Sleep(20)
Wend
  Message("you made it")


Re: Ignoring While loops unless Stepping thru code
« Reply #4 on: June 11, 2012, 07:49:35 AM »
Good replies. I already tried the while ismoving with no results, although I did add it after my G90 moves.
What seems to work is below:

If  not getoemled(82) Then
   DoOembutton(1004)
end If

thanks Alex for the code

I also had to add some Sleep 1000's after some of the moves, then all seems good now

tbyrd
Re: Ignoring While loops unless Stepping thru code
« Reply #5 on: June 11, 2012, 05:32:13 PM »
Looks like I still have the same issue, but it gets there sometimes with the second pause I have inserted into the code.
tbyrd