< Back to IRCAM Forum

Assignment of Values

Is there a way to have an expression be evaluated immediately in an assignment? E.g.

forall $i in 3 {
	let $receiver := "OneOfTwo"+(($i%2)+1)
	print intended receiver ($receiver)
	($somedelay)ms @command($receiver) dosomething
	print invoked receiver ($receiver)
	let $somedelay := @rand(100)
}

prints

intended receiver OneOfTwo1
invoked receiver OneOfTwo1
intended receiver OneOfTwo2
intended receiver OneOfTwo1
invoked receiver OneOfTwo1
invoked receiver OneOfTwo1

instead of alternating OneOfTwo1 and OneOfTwo2.

Is there a way to force the assignment of the value of expression instead of the expression itself, similar to delimiting an expression by putting it into round brackets?

Of course, the above example could be rewritten into something like that:

forall $i in 3 {
	let $receiver := "OneOfTwo"+(($i%2)+1)
	if ($receiver = "OneOfTwo1") {
		($somedelay)ms OneOfTwo1 dosomething
	} else {
		($somedelay)ms OneOfTwo2 dosomething
	}
	let $somedelay := @rand(100)
}

However, it would be convenient to be able to force evaluation on assignment, as there are other use cases for that (I could give other examples) which are not reformulated so easily.

Hi Kyl,

I presume you’d better assign the antescofo category to your post otherwise the antescofo team won’t receive a notification…

Bye,

N.

Thank you, Nadir, for the hint. I thought to be in the Antescofo category, but obviously I posted a drift bottle… However, after having posted it, it seems not to be possible to change the category of a topic. So I will post a link. All the best, Kai Yves

See the answer in the “Antescofo” category.