Home AMX User Forum AMX Technical Discussion

Can't modify passed-by-reference variable in a wait

DEFINE_VARIABLE
INTEGER qwer

DEFINE_CALL'foo'(INTEGER asdf)
{
    asdf = true
    send_string 0, 'True'
    wait 50 {
	asdf = false
        send_string 0, 'False'
    }
}

BUTTON_EVENT[dvTP, 444]
{PUSH:
    {
	CALL'foo'(QWER)
    }
}

qwer never goes back to FALSE

Comments

  • Could this be the answer? Variable "cloning"?
    Using Waits - limitations
    References to STACK_VAR variables are not allowed within waits. STACK_VARs are temporary variables that cease to exist when the block in which they are declared is exited.

    Variable copies are made of functions and subroutine parameters. This can have speed/execute penalties.

    Within functions and subroutines, a RETURN is not allowed within a WAIT.

    A BREAK or CONTINUE cannot appear within a WAIT if it takes execution out of the scope of the WAIT.

    The code within a WAIT cannot reference a function or subroutine array parameter whose bounds are unspecified.
  • mpullinmpullin Posts: 949
    When the wait 50 fires inside the CALL, who knows what variable you're setting to false? :-o The pointer asdf is clearly no longer referencing qwer.

    Was there a question implied in the original post?
Sign In or Register to comment.