Home AMX User Forum NetLinx Studio

Multiple 'Wait Until' Complications

Has anyone had any complications when dealing with multiple "Wait Until" situations? Consider the following:
define_function myFunction() {
  if(something) {
	wait_until(nAnotherVariable) {
	  select {
		active(nAnotherVariable == 100): {
		  nSomeVariable = 1;
		}
		active(nAnotherVariable == 235): {
		  nSomeVariable = 2;
		}
	  }
	}
  }
}
define_function myActiveFunction() {
  myFunction()

  wait_until(nSomeVariable) {
	select {
	  active(nSomeVariable == 1): {
	  }
	  active(nSomeVariable == 2): {
	  }
	}
  }
}
Assume that it's already running through myActiveFunction, and myFunction is therefore subsequently called. I'm having a difficult time telling, but it seems as though the first WAIT_UNTIL is called, but once it reaches the second, it drops the first - the WAIT_UNTIL myFunction is then satisfied, but by that point the WAIT_UNTIL within myActiveFunction doesn't...care?

I'm really not sure and I'm still trying to figure this out, but wondered if anyone else has perhaps had any complication in this area as well. Incidentally, I apologize that my tabs are crazy inconsistent.

Thanks!

Comments

  • DHawthorneDHawthorne Posts: 4,584
    Just name the waits according to which function called them.
  • Pardon? Do you mean do a Cancel_Wait_Until to the names...?
  • viningvining Posts: 4,368
    I may be wrong but I wouldn't think the wait_until in myFunction() would suspend the return of that function until the wait_until executes but instead just return to myActiveFunction() and the value of nSomeVariable will be what it was unless nAnotherVariable was already true when the wait_until in myFunction() ran.

    Me thinks that when the wait_until in myFunction() finally if ever executes it just runs the code in the select active and stops and doesn't return to myActiveFunction() because that's already been done.
  • vining wrote: »
    I may be wrong but I wouldn't think the wait_until in myFunction() would suspend the return of that function until the wait_until executes but instead just return to myActiveFunction() and the value of nSomeVariable will be what it was unless nAnotherVariable was already true when the wait_until in myFunction() ran.

    Me thinks that when the wait_until in myFunction() finally if ever executes it just runs the code in the select active and stops and doesn't return to myActiveFunction() because that's already been done.
    Yes, it would continue to run the rest of the code in myActiveFunction, however it would simply hit another WAIT_UNTIL and then be stuck waiting for the two Waits, in which the latter would only be satisfied after the first as been - at least that's what I want it to do.
  • Spire_JeffSpire_Jeff Posts: 1,917
    Only one instance of a Wait can exist. This might be causing the problem. The second time through the function, the wait will not be executed since one wait is already waiting.

    Jeff
  • jjamesjjames Posts: 2,908
    Spire_Jeff wrote: »
    Only one instance of a Wait can exist. This might be causing the problem. The second time through the function, the wait will not be executed since one wait is already waiting.

    Jeff

    Gosh Jeff, you say things that I think so eloquently- I'd be sitting here trying to explain stuff for days! Haha!
  • DHawthorneDHawthorne Posts: 4,584
    Only one instance of an unnamed wait can exist. If the two waits have different names, two instances are created and they will run independently. An unnamed wait is really just given a default handle that only the running program knows, which is why they don't stack ... it has a name, you just don't know what it is. When you give them names, they are queued up separately.
  • Spire_Jeff wrote: »
    Only one instance of a Wait can exist. This might be causing the problem. The second time through the function, the wait will not be executed since one wait is already waiting.
    Is this particular to all sorts of waits? It seems as though timed waits and such would be able to handle multiple instances thereof. In which case, would it work if I placed it into a solid wait and disabled it via name?
  • viningvining Posts: 4,368
    Those waits are in different section of code so they are given different names by the master when compiled. If jason actually named the waits the same name the only one instance thing could be true but I don't think it would even compile if a named wait was used in more than one location in the code.
Sign In or Register to comment.