Home AMX User Forum AMX General Discussion

WAIT_UNTIL... comparison question

Is this:

IF( nACTION_1 = 1 ) // REPRESENTING A FLAG INSIDE A FUNCTION fnACTION_1 ()
			{
			WAIT_UNTIL ( nACTION_1 = 0 ) 'WAIT UNTIL fnACTION_1 IS COMPLETE'
			fnACTION_2 () 
			}
		    ELSE
			{
			fnACTION_2 ()
			}


Fundamentally the same as this:
IF( !nACTION_1 )
			{
			fnACTION_2 ()
			}

or, as I suspect, not.

TO CLARIFY:

In the second segment, the fnACTION_2 will fire ONLY if nACTION_1 = 0, but won't hang around until it is; I suspect it won't fire at all if nACTION_1 suddenly goes from 1 to 0, whereas the top one will. Am I right in that assumption?

Do I even make sense at this hour???

Comments

  • mpullinmpullin Posts: 949
    Is this:

    IF( nACTION_1 = 1 ) // REPRESENTING A FLAG INSIDE A FUNCTION fnACTION_1 ()
    			{
    			WAIT_UNTIL ( nACTION_1 = 0 ) 'WAIT UNTIL fnACTION_1 IS COMPLETE'
    			fnACTION_2 () 
    			}
    		    ELSE
    			{
    			fnACTION_2 ()
    			}
    


    Fundamentally the same as this:
    IF( !nACTION_1 )
    			{
    			fnACTION_2 ()
    			}
    
    If nACTION_1 == 0, the two blocks do the same thing. If nACTION_1 == 1, the second block does nothing and the first block sets up a wait that executes as soon as nACTION_1 becomes 0. Incidentally, I believe the outermost IF in the first block is not necessary. Just
    WAIT_UNTIL ( nACTION_1 = 0 ) fnACTION_2 ()
    
    should do the trick as fnACTION_2 will fire right away (or at least very very soon) if nACTION_1 == 0.
  • Coolio, cheers, good tip!


    The first IF in the first block is a flag inside a function that resets the whole system, so I abolutely don't want the second action to fire while thats happening. If it was a standalone statement I probably wouldnt need it but its part of a series of SELECT...ACTIVES inside a DATA_EVENT that is parsing a buffer...

    I guess Im just covering all bases!


    Thanks :-)
  • ericmedleyericmedley Posts: 4,177
    One little thing...
    IF( !nACTION_1 )
      {
      // do something
      }
    
    
    is the same as
    IF(nACTION_1<>0 )
      {
      // do something
      }
    

    Any number beside zero will trigger it.
Sign In or Register to comment.